Skip to content

Boolean operators #50

Closed
Closed

Description

@max-sixty

Some discussion on discord about these.

Two forms:

  • In SQL expressions — filter salary > 0 and title = "Architect" — these can compile straight to SQL; there's no need for prql to do anything beyond forward them through.
  • In PRQL code, where we have to evaluate the expression in PRQL to decide what SQL to produce:
    func foo x y = (x or y) ? salary : total_comp  # (assuming we have a tertiary operator, separate discussion!)
    
    from employees
    derive [
      salary: foo 1 0
      also_salary: foo 0 1
      total_comp: foo 0 0
    ]

For the latter, the default would be to have and and or as infix operators, like they are in most languages.

But my sense is that having these in PRQL is not that important, and we probably don't need them in the first version. If there are example queries that do require them, feel free to post them here.

CC @qorrect

Activity

  1. added
    language-design
    on Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    language-design

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions