Repository navigation
fix(partiql): refuse AT or BY with no name after a FROM table - #1389
LeeroyHannigan wants to merge 1 commit into
Conversation
After a PartiQL FROM table, Amazon DynamoDB requires a name after AT and after BY. A quoted name is a name there. Anything else gets "Statement wasn't well formed, can't be processed: Expected identifier for AT-alias", or the same text with BY-alias. The end of the statement gets it too, and a lower-case at or by gets the same upper-case text. DynamoDB was measured in us-east-1 on 23 November 2026 on a table that does not exist, each statement twice. source_aliases read AT or BY as an alias only before an unquoted name. It left any other AT or BY in place, and the parser then answered it as a token after the statement. It now checks the token after AT or BY with name_follows and refuses anything that is not a name with the keyword's text. Fixes #1384
demohan
left a comment
There was a problem hiding this comment.
A FROM table followed by AT or BY with no name now gets the service's refusal at 0a04304. Of 165 ExecuteStatement shapes sent twice to us-east-1 and to this head, base and main, this head matches the service byte for byte on 160, and on 15 of 15 BatchExecuteStatement and ExecuteTransaction shapes; every one of the 113 answers that changed from base moved to the service's, and the 5 that differ are UPDATE, DELETE and EXISTS shapes that base and main answer the same way. An AT or BY at the end of the statement, after a new line or comment, before a bad WHERE, LIMIT or ORDER BY, in an IN subquery and after a FROM path all match, and the AT or BY syntax error wins over the deferred refusals, as on the service. Four of five controls fail as they should, the core lib tests (1152 passed), fmt, clippy and the 1.91.1 check are clean, CI is green on 59 of 59, and it merges onto main at d4dd0ba without conflict, where the build, the core lib tests (1248 passed) and the 1.94.0 check pass.
In the body, 9 of the committed table's first 11 rows fail on base (8 was the first commit's 11), main gives the service's answer on 2 of the body table's first 12 (3 of the issue's 12), and tests/test_partiql_grammar.py gives 1014 passed, 3 skipped on base too and has no AT or BY row, so it shows only that nothing regressed.
| for sql in [ | ||
| "SELECT * FROM \"t\" AT x WHERE pk = 'p'", | ||
| "SELECT * FROM \"t\" BY x WHERE pk = 'p'", | ||
| fn at_and_by_after_a_table_take_a_name() { |
There was a problem hiding this comment.
Optional. Nothing here holds AT being read before BY: with ["BY", "AT"] at parser.rs:523 the 38 statement tests pass. Three rows the service answers would hold it: AT x BY y gets Aliasing is not supported, AT x BY 1 gets Statement wasn't well formed, can't be processed: Expected identifier for BY-alias, and BY x AT y gets Statement wasn't well formed, can't be processed: Unexpected token after expression; with them, the swapped order fails at AT x BY y.
What
After a PartiQL FROM table,
ATandBYnow need a name after them. A quoted name counts. Any other token, and the end of the statement, getsStatement wasn't well formed, can't be processed: Expected identifier for AT-alias, or the same text withBY-alias. Before, ExtendDB tookATorBYas an alias only before an unquoted name. Any otherATorBYstayed in the statement, and the parser answered it as a token after the end.source_aliasesincrates/core/src/partiql/parser.rschecks the token afterATorBYwith the existingname_follows. It refuses anything that is not a name with the keyword's text, in upper case.at_and_by_after_a_table_are_aliasesinparser/tests/statements.rsbecomes one table of the measured statements,at_and_by_after_a_table_take_a_name.The base of this PR is #1386, which makes
@a token of its own.Fixes #1384
Why
DynamoDB was measured in us-east-1 on 23 November 2026 with ExecuteStatement on a table that does not exist. Each statement went out twice, with the same answer both times. Each statement is
SELECT * FROM "<missing>" <rest>, and "not well formed" stands for the prefixStatement wasn't well formed, can't be processed:.<rest>AT x WHERE pk = 'q',BY x WHERE pk = 'q',AT "x" WHERE pk = 'q'Aliasing is not supportedAT 1 WHERE pk = 'q',at 1 WHERE pk = 'q',AT @x WHERE pk = 'q',AT WHERE pk = 'q',AT,x AT 1 WHERE pk = 'q'Expected identifier for AT-aliasBY 1 WHERE pk = 'q',BY @x WHERE pk = 'q',by @x WHERE pk = 'q',BYExpected identifier for BY-aliasAS @x WHERE pk = 'q',AS 1 WHERE pk = 'q'Expected identifier for AS-aliasExtendDB on main gave 3 of the first 12 of these statements DynamoDB's answer.
Testing done
cargo test -p extenddb-core --lib --no-fail-fast: 1152 passed, 1 ignored.cargo +1.97.0 clippy -p extenddb-core -p extenddb-engine --all-targets -- -D warningsandcargo +1.97.0 fmt --all -- --checkare clean.at 1,by @xandBYat the end, came later and pass in the unit table.tests/test_partiql_grammar.pyagainst the same build: 1014 passed, 3 skipped.Production is +14 -8, and the test is +23 -5. Only the SELECT FROM source calls
source_aliases, so UPDATE, DELETE and INSERT answer as before. This PR adds no conflict over its base.Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: n/a
By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.