Proposal: dialect spellings for the expression language - #156
Closed
hadley wants to merge 1 commit into
Closed
Conversation
Member
Author
|
Moved to #157 for discussion — a proposal is better debated as an issue than a doc PR. |
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.
What this is
A design proposal (not spec, not implementation):
site/expression-dialects.md, following thesemantic-models.mdpattern of a design doc insite/outside the navbar. It proposes letting expressions be written in R, pandas, polars, or Python spelling as well as SQL — one language, one AST, one semantics; the dialects are alternative spellings that parse to identical nodes and may be mixed freely.Highlights
None/NAbecoming reserved words; everything else gives meaning to syntax that is an error today. A table covers where SQL instincts will be wrong ("…"is a string not an identifier,||is OR not concat,%is floored not truncated,&/|are logical).==,!/~,&/&&,|/||,%in%, all at the canonical operator's precedence (R agrees almost exactly; pandas/polars divergences are called out).MOD(x, y)keeps its truncated (SQL/C) semantics unchanged;%/%%arrive as a new floored operation (Python/R semantics). The one place dialects add an operation rather than a spelling.x.f(a)≡f(x, a)for every function, sox.trim().length() <= 10works; parens required, inert.straccessor accepted,.in numbers only between digits.nchar,len_chars,tolower,trimws,ceiling,is_null,is_in,between,ifelse, lubridate-styleweeks(2), …), chained comparisons (lo <= x <= hi, single-direction only),None/NAnull spellings, double-quoted strings, andINlist forms[…]/c(…).WHERE (expr) IS FALSE) andCHECKemission, with a node-by-node DuckDB/Postgres table —NULLIFguards to preserve totality, explicit casts for temporal literals,COLUMNS(...)expanded at translation time.||on strings,pl.col('x'),is.na(x), mixed chains).Open questions (in the doc)
NAreally be reserved case-insensitively (nais a plausible column name)?.strqualifier, or hint it away?fmt.Conceptually builds on #155 (backtick-quoted names): backticks quoting identifiers is what frees
"…"to be a string literal, and is the escape hatch for columns namedna. No textual dependency — this PR is a single new doc based onmain.Per AGENTS.md this is phase 1: nothing is implemented, and the spec text itself is untouched pending sign-off on this wording.
🤖 Generated with Claude Code