Skip to content

Latest commit

 

History

History
55 lines (45 loc) · 3.03 KB

AGENTS.md

File metadata and controls

55 lines (45 loc) · 3.03 KB

Table-Model SQL Grammar Guidelines

These instructions apply to iotdb-core/relational-grammar/ and supplement the repository instructions.

Reserved and non-reserved keywords

  • For each new keyword token in the lexer portion of RelationalSql.g4, determine whether it is intentionally reserved. If it is not a reserved word, add the token to the nonReserved rule in the same change. Defining only the lexer token can make a previously valid unquoted database, table, column, or alias name stop parsing, because the identifier rule accepts these keyword tokens through nonReserved.
  • Keep nonReserved as a list of token alternatives only; do not add nested parser rules. The DataNode SQL parser's exitNonReserved implementation depends on this structure.
  • Do not reserve a word accidentally by omitting it from nonReserved, or make an existing reserved word non-reserved merely to resolve a grammar conflict. Intentional reservation must be part of the SQL change's contract and covered by compatibility tests. This rule is about keyword tokens, not operators, punctuation, whitespace, fragments, or literals.

Verification

  • Cover the new SQL syntax and non-reserved keyword use as unquoted identifiers in the relevant database/table/column/alias positions, including case variants. Quoted-only tests do not protect unquoted-name compatibility. For intentionally reserved words, verify rejection in unquoted identifier positions and acceptance with supported quoting.
  • The existing StreamKeywordTest demonstrates reserved and non-reserved identifier checks. For integration coverage, follow integration-test/AGENTS.md and use the table-model profile.
  • Edit the .g4 sources and regenerate through Maven; do not edit generated Java, .tokens, or .interp files. Rebuild the affected grammar and DataNode consumers and run the affected parser/identifier tests. Successful grammar generation alone does not establish identifier compatibility or correct AST construction.