Skip to content

feat: add Teradata dialect - #3075

Merged
benfdking merged 4 commits into
mainfrom
agent/add-teradata-dialect
Aug 8, 2026
Merged

feat: add Teradata dialect#3075
benfdking merged 4 commits into
mainfrom
agent/add-teradata-dialect

Conversation

@benfdking

Copy link
Copy Markdown
Collaborator

What changed

  • add teradata as a first-class dialect and default crate feature
  • port the Teradata lexer, keyword changes, comparison operators, DDL/DML, BTEQ, statistics, QUALIFY, NORMALIZE, TOP, query-band, session, and Teradata cast grammars from SQLFluff
  • add syntax kinds for Teradata-specific parse-tree nodes
  • import all 24 Teradata SQL fixtures from the SQLFluff revision pinned by .sqlfluff-sha (d8943f041dd53ab6b7c018e46b81c32dfd65b682) and generate Sqruff parse-tree expectations

Why

Sqruff did not expose a Teradata dialect, so Teradata-specific statements and expressions either required another dialect or produced unparsable segments. This port makes the pinned SQLFluff Teradata surface available through dialect = teradata.

Validation

  • cargo fmt --all -- --check
  • cargo test -p sqruff-lib-dialects --test dialects -- teradata (24 fixture files)
  • cargo clippy -p sqruff-lib-dialects --all-features -- -D warnings
  • confirmed the Teradata dialect and fixtures are unchanged between the initially inspected SQLFluff revision and the currently pinned d8943f0… revision

@benfdking
benfdking force-pushed the agent/add-teradata-dialect branch from be0c629 to 3d7efa8 Compare August 8, 2026 18:43
@benfdking
benfdking marked this pull request as ready for review August 8, 2026 18:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d7efa8c86

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +63 to +67
dialect.patch_lexer_matchers(vec![Matcher::regex(
"numeric_literal",
r"([0-9]+(\.[0-9]*)?)",
SyntaxKind::NumericLiteral,
)]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve scientific and leading-dot numeric literals

When Teradata SQL contains valid numeric forms such as 1e-9, 25e-03, or .0123E-6, this override replaces the inherited ANSI matcher—which supports exponents and leading decimal points—with a regex accepting only digits followed by an optional decimal fraction. The lexer consequently splits these values into multiple tokens and leaves the statement unparsable; retain the native matcher or extend this regex to cover those forms.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Benchmark for 9e2658b

Click to view benchmark
Test Base PR %
DepthMap::from_parent 122.0±4.84µs 121.3±2.82µs -0.57%
fix_complex_query 14.2±0.50ms 14.0±0.30ms -1.41%
fix_superlong 181.6±14.72ms 163.0±13.57ms -10.24%
parse_complex_query 4.3±0.09µs 4.2±0.15µs -2.33%
parse_expression_recursion 7.5±0.22µs 7.4±0.04µs -1.33%
parse_simple_query 1048.5±26.71ns 1064.7±16.08ns +1.55%

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Benchmark for d446253

Click to view benchmark
Test Base PR %
DepthMap::from_parent 117.6±1.51µs 117.8±5.41µs +0.17%
fix_complex_query 13.4±0.16ms 13.5±0.10ms +0.75%
fix_superlong 135.8±6.92ms 134.7±9.02ms -0.81%
parse_complex_query 4.2±0.09µs 4.1±0.07µs -2.38%
parse_expression_recursion 6.9±0.09µs 7.0±0.09µs +1.45%
parse_simple_query 1060.9±24.54ns 1055.2±14.98ns -0.54%

@benfdking
benfdking merged commit b655272 into main Aug 8, 2026
25 of 28 checks passed
@benfdking
benfdking deleted the agent/add-teradata-dialect branch August 8, 2026 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant