Skip to content

Authoritative source-derived dialect census with anti-drift guards (R2a function-library audit) #248

Description

@fupelaqu

The R2a function-library audit (Epic 19) needs one machine-generated, drift-proof inventory of every construct the elasticsql SQL dialect accepts - each row anchored to real source, each example proven parseable by the real parser, each ES translation derived from the AST - so the jOOQ-render estimate rests on a counted surface instead of a guess.

This lands three test-tree sources under sql/src/test/scala/app/softnetwork/elastic/sql/census/:

  • CensusModel.scala - the row model (CensusEntry, Kind, EsConstruct, Standard with shape-checked Rule-R evidence gates) and emitters (RFC-4180 CSV, provenance-stamped JSON object, GFM markdown).
  • DialectCensus.scala - 259 hand-authored SYNTAX-FORM rows: 171 function rows covering all 95 SQLKeywords.functionTokens and all 149 accepted spellings (54 aliases, 22 of them computed at runtime by TimeField.words), 29 operators, 36 clauses, 6 literals, 17 units. Every ansi_adjacent citation was fetched from PostgreSQL 16 / MySQL 8.4 / DuckDB docs.
  • DialectCensusSpec.scala - the generator/guard: wrap-tolerant anchors resolved to file:line at emit time (exactly-one-hit), every example parsed through Parser, ES constructs derived from the parsed AST with an es_construct_source column, two-way registry coverage diffs, the 95/95/149 pins, a phantom-help corpus walk (13 phantoms incl. the 3 wired json/ ones), and the emit of sql/target/epic-19/dialect-census.{csv,json,md}. Nothing is assume-guarded; runs on every sbt sql/test.

No production or published code changes (test artifacts are not published). Notable findings recorded in the census itself: || (Pipe) and bare E are DEAD tokens (declared, never consumed by any production); bare CROSS JOIN is grammar-accepted but rejected by StandardJoin.validate; LOG is the NATURAL log (PostgreSQL/DuckDB log is base-10); STRPOS reverses PostgreSQL/DuckDB argument order; DAYOFWEEK numbering differs across all three engines.

Green on Scala 2.12.20 + 2.13.16 (548/548 sql tests per leg); SQLKeywordsSpec untouched and green.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions