F-strings

F-strings are a readable approach to building new strings from existing strings. Currently PRQL supports this for concatenating strings:

PRQL

  1. from employees
  2. select full_name = f"{first_name} {last_name}"

SQL

  1. SELECT
  2. CONCAT(first_name, ' ', last_name) AS full_name
  3. FROM
  4. employees

This can be much easier to read for longer strings, relative to the SQL approach:

PRQL

  1. from web
  2. select url = f"http{tls}://www.{domain}.{tld}/{page}"

SQL

  1. SELECT
  2. CONCAT(
  3. 'http',
  4. tls,
  5. '://www.',
  6. domain,
  7. '.',
  8. tld,
  9. '/',
  10. page
  11. ) AS url
  12. FROM
  13. web

Note that interpolations can only contain plain variable names and not whole expression like Python.

Roadmap

In the future, f-strings may incorporate string formatting such as datetimes, numbers, and padding. If there’s a feature that would be helpful, please post an issue.