F-strings

F-strings are a readable approach to building new strings from existing strings & variables.

PRQL

from employees select full_name = f"{first_name} {last_name}"

SQL

SELECT CONCAT(first_name, ' ', last_name) AS full_name FROM employees

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

PRQL

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

SQL

SELECT CONCAT( 'http', tls, '://www.', domain, '.', tld, '/', page ) AS url FROM web

Note that currently interpolations can only contain plain variable names and not whole expressions like Python, so this won’t work:

PRQL

from tracks select length_str = f"{length_seconds / 60} minutes"

Error

Error: ╭─[:2:38] 2 │ select length_str = f"{length_seconds / 60} minutes" ╰── interpolated string expected one of ".", ":" or "}", but found " " ───╯

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.