镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Add Dialect::parse_table_factor_name hook - #2610

Open
edmondop wants to merge 2 commits into
apache:mainfrom
edmondop:dialect-table-factor-name
Open

edmondop wants to merge 2 commits into
apache:mainfrom
edmondop:dialect-table-factor-name

Conversation

@edmondop

@edmondop edmondop commented Oct 3, 2026 •

Copy link
Copy Markdown

Closes #2604.

Dialect can override expression, statement and column-option parsing, but not table names: parse_table_factor always calls parse_object_name(true). A downstream dialect with syntax like FROM events:analytics has to rewrite tokens before parsing.

This adds parse_table_factor_name, which works like parse_prefix/parse_statement: return None to fall back to the default parser. Only the name is replaced; alias, joins, sampling and hints still go through the core parser. Note that ObjectName prints its parts joined with ., so custom separators don't round-trip.

derive_dialect's generated imports gain ObjectName so derived dialects compile.

Dialects: none

Tests: custom_table_factor_name_parser in tests/sqlparser_custom_dialect.rs.

Implemented with AI assistance (Claude Code).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Hb9YMy3Ay2oNWagfTz2KzZ

Lets a dialect parse the name of a table in a table factor, falling back
to parse_object_name when it returns None.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hb9YMy3Ay2oNWagfTz2KzZ
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown

No dialect label was applied because the title does not name a SQL dialect.

If this change targets one or more dialects, edit the title to <Dialect>[, <Dialect>]: <description>, add a Dialects: <Dialect>[, <Dialect>] line to the description, or reply with one. Reply Dialects: none if the change is dialect-agnostic.

@edmondop
edmondop marked this pull request as ready for review October 4, 2026 12:35
@LucaCappelletti94

Copy link
Copy Markdown
Contributor

A downstream dialect with syntax like FROM events:analytics has to rewrite tokens before parsing.

Yeah in my opinion the clean solution will be at some point to refactor the tokenizer dialect-generic, so tokenization can be optimally implemented for each dialect.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.13%. Comparing base (14cbf75) to head (3407a3d).

Files with missing lines Patch % Lines
src/dialect/mod.rs 50.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2610      +/-   ##
==========================================
- Coverage   81.14%   81.13%   -0.02%     
==========================================
  Files          42       42              
  Lines       33736    33748      +12     
  Branches    33736    33748      +12     
==========================================
+ Hits        27376    27382       +6     
- Misses       2797     2803       +6     
  Partials     3563     3563              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@edmondop

edmondop commented Oct 4, 2026

Copy link
Copy Markdown
Author

Agreed that a dialect-specific tokenizer is the right long-term fix for lexing. For Presto, is_identifier_part already covers it (#2611), since its grammar allows : in every identifier. This hook targets a different case: a dialect that only wants special syntax in table position, or wants the name split into parts, which the tokenizer can't decide without parser context.

I'm open to working on the tokenizer side too. If useful, I can open an issue sketching it, for example a Dialect hook that can emit a token before the default tokenizer runs, with the same "return None to fall back" contract as parse_prefix. Would you merge this hook in the meantime, or rather wait for that?

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.

Let a Dialect override how a table name in FROM is parsed

3 participants