Skip to content

0.4.0

Compare
Choose a tag to compare
@max-sixty max-sixty released this 16 Jan 04:50
· 2389 commits to main since this release
a212519

0.4.0 brings lots of new features including switch, select ![] and numbers with underscores. We have initial (unpublished) bindings to Elixir. And there's the usual improvements to fixes & documentation (only a minority are listed below in this release).

0.4.0 also has some breaking changes: table is let, dialect is renamed to target, and the compiler's API has changed. Full details below.

Features:

  • Defining a temporary table is now expressed as let rather than table (@aljazerzen, #1315). See the tables docs for details.

  • Experimental: The switch function sets a variable to a value based on one of several expressions (@aljazerzen, #1278).

    derive var = switch [
      score <= 10 -> "low",
      score <= 30 -> "medium",
      score <= 70 -> "high",
      true -> "very high",
    ]
    

    ...compiles to:

    SELECT
      *,
      CASE
        WHEN score <= 10 THEN 'low'
        WHEN score <= 30 THEN 'medium'
        WHEN score <= 70 THEN 'high'
        ELSE 'very high'
      END AS var
    FROM
      bar

    Check out the switch docs for more details.

  • Experimental: Columns can be excluded by name with select (@aljazerzen, #1329)

    from albums
    select ![title, composer]
    
  • Experimental: append transform, equivalent to UNION ALL in SQL. (@aljazerzen, #894)

    from employees
    append managers
    

    Check out the append docs for more details.

  • Numbers can contain underscores, which can make reading long numbers easier (@max-sixty, #1467):

    from numbers
    select [
        small = 1.000_000_1,
        big = 5_000_000,
    ]
    
  • The SQL output contains a comment with the PRQL compiler version (@aljazerzen, #1322)

  • dialect is renamed to target, and its values are prefixed with sql. (@max-sixty, #1388); for example:

    prql target:sql.bigquery  # previously was `dialect:bigquery`
    
    from employees
    

    This gives us the flexibility to target other languages than SQL in the long term.

  • Tables definitions can contain a bare s-string (@max-sixty, #1422), which enables us to include a full CTE of SQL, for example:

    let grouping = s"""
      SELECT SUM(a)
      FROM tbl
      GROUP BY
        GROUPING SETS
        ((b, c, d), (d), (b, d))
    """
    
  • Ranges supplied to in can be half-open (@aljazerzen, #1330).

  • The crate's external API has changed to allow for compiling to intermediate representation. This also affects bindings. See prql_compiler docs for more details.

Fixes:

[This release, the changelog only contains a subset of fixes]

Documentation:

[This release, the changelog only contains a subset of documentation improvements]

Web:

  • The playground allows querying some sample data. As before, the result updates
    on every keystroke. (@aljazerzen, #1305)

Integrations:

[This release, the changelog only contains a subset of integration improvements]

Internal changes:

[This release, the changelog only contains a subset of internal changes]

New contributors: