Allow backtick-quoted names in expressions - #155
Open
hadley wants to merge 1 commit into
Open
Conversation
A table or column could be declared with any non-empty name, but only a
plain identifier could be referenced from an assertion or a `join`, so a
column called `creation date` was declarable and then unreachable. Names
of any other shape — a space or punctuation, a leading digit, or a clash
with a reserved word — now go in backticks:
- assert: '`creation date` <= `end`'
- join: '`other studies`.`study id` = study.id'
A quoted name may hold any character, doubling a backtick to embed one,
and each side of a join's `.` is quoted on its own, so a `.` between
backticks is part of the name. Quoting changes only how a name is read,
never how it is matched, so backticks are optional on a name that doesn't
need them. Malformed quoting lands on the existing S19/S04 rather than a
new code.
A backtick can't open a plain YAML scalar, so an expression that starts
with one needs YAML quotes; site/expressions.md says so alongside the new
`Column references` section.
Fixes #148, #137
Member
There are no backticks in this example. :) |
gaborcsardi
approved these changes
Jul 31, 2026
gaborcsardi
left a comment
Member
There was a problem hiding this comment.
Maybe we should de-duplicate the two parsers? E.g. this PR adds parse_quoted_name() to both, and the two implementations are exactly identical. Which makes sense, they are supposed to be identical. But then we should probably merge the two.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A table or column could be declared with any non-empty name, but only a plain identifier (
[A-Za-z_][A-Za-z0-9_]*) could be referenced from an assertion or ajoin— so a column calledcreation datewas declarable and then unreachable, with no quoting syntax to bridge the gap.Names of any other shape — containing a space or punctuation, starting with a digit, or colliding with a reserved word — now go in backticks:
A quoted name may hold any character, doubling a backtick to embed one. Each side of a join's
.is quoted on its own, so a.between backticks is part of the name. Quoting changes only how a name is read, never how it's matched, so backticks are optional on a name that doesn't need them. Malformed quoting (unterminated, empty) lands on the existing S19/S04 rather than a new check code, sovalidation.mdandschema.yamlare unchanged.Backticks rather than SQL's
"because'…'is already a string literal (andCOLUMNS('regex')a regex), and because it matches the analytics mini-languages users come from — pandasquery(), dplyr, Spark. One wrinkle documented in the spec: a backtick can't open a plain YAML scalar, so an expression starting with one needs YAML quotes; one merely containing a backtick doesn't.Spec first:
site/expressions.mdgains aColumn referencessection, plus grammar andCOLUMNS([...])updates.Tests: quoted names, reserved-word names, embedded backtick/dot/non-ASCII, spans, and the unterminated/empty rejections in both parsers;
tests/fixtures/spec/quoted-names-ok.yamlexercises the whole path through the CLI.Fixes #148, #137
🤖 Generated with Claude Code