Repository navigation
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #26437 +/- ##
==========================================
- Coverage 82.89% 82.89% -0.01%
==========================================
Files 1154 1154
Lines 457620 457698 +78
Branches 457620 457698 +78
==========================================
+ Hits 379352 379415 +63
- Misses 55262 55265 +3
- Partials 23006 23018 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
adriangb
force-pushed
the
session-state-sql-dialect
branch
from
October 26, 2026 22:25
89c8cc7 to
05b4aa3
Compare
adriangb
marked this pull request as ready for review
October 26, 2026 22:25
adriangb
force-pushed
the
session-state-sql-dialect
branch
from
October 29, 2026 22:37
05b4aa3 to
06f67b1
Compare
alamb
approved these changes
Nov 4, 2026
|
|
||
| /// Set the [`sqlparser`] dialect object used to parse SQL. | ||
| /// | ||
| /// Use this method for a dialect that `datafusion.sql_parser.dialect` |
Contributor
There was a problem hiding this comment.
I think this could be shorter "Use this method for custom dialects that are not supported by ..."
| /// [`sqlparser::dialect::Dialect`]. | ||
| /// | ||
| /// The dialect object takes precedence over the dialect name in the | ||
| /// session config. If it is set, [`SessionContext::sql`], |
Contributor
There was a problem hiding this comment.
do we really need to list all the (current) users of this setting?
Contributor
|
Shall we merge it? |
Contributor
Author
|
I think so! Let me address your feedback next week or feel free to push and merge before that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
This picks up the approach of #23235, which the stale bot closed without a review decision. This PR adds the clone-path,
SETand expression-path coverage, and documents the precedence rule.Rationale for this change
datafusion.sql_parser.dialectaccepts only a closed list of names.SessionState::sql_to_statementandSessionState::sql_to_expr_with_aliasresolve that name withdialect_from_stron every parse. Thus an application with its ownsqlparser::dialect::Dialect, for example one built withderive_dialect!on top ofPostgreSqlDialect(apache/datafusion-sqlparser-rs#2174), cannot plug it in. It must wrap every parse entry point itself. A call to a stock method such asSessionContext::sqlthen parses with the wrong dialect, and the query fails with a parse error.What changes are included in this PR?
SessionStateBuilder::with_sql_dialect(Arc<dyn Dialect + Send + Sync>), plus the gettersSessionState::sql_dialect()andSessionStateBuilder::sql_dialect().sql_to_statementandsql_to_expr_with_aliasuse the dialect object when it is set. All other parse paths go through these two methods:SessionContext::sql,sql_with_options,create_logical_plan,create_logical_exprandsql_to_expr.dialectargument tosql_to_statementorsql_to_expr, and a laterSET datafusion.sql_parser.dialect = ....SETstill changes the config value, but not the parser.SessionStateBuilder::new_from_existingandFrom<SessionState>keep the dialect object.datafusion-cliresolves the dialect name itself and does not expose a way to set a dialect object, so this PR does not change it.Are these changes tested?
Yes.
test_custom_sql_dialectuses a small hand-written dialect: PostgreSQL plusSELECT * EXCEPT (...). Thederive-dialectfeature of sqlparser is not enabled in this workspace. The test checks that:ctx.sql(...),create_logical_plan,sql_to_statement,sql_to_exprandcreate_logical_exprparse with the dialect object,SET datafusion.sql_parser.dialectstatement does not replace it,new_from_existingandFrom<SessionState>keep it.The rustdoc example on
with_sql_dialectruns as a doctest.Are there any user-facing changes?
Yes. This PR adds a new public builder method and two getters. There are no breaking changes.