[SPARK-58554][SQL] Block MySQL double cast pushdown - #57756
Closed
alekjarmov wants to merge 1 commit into
Closed
Conversation
MariaDB rejects CAST(... AS DOUBLE PRECISION). Stop pushing DoubleType casts in MySQLDialect so Spark evaluates them locally instead.
cloud-fan
approved these changes
Aug 4, 2026
cloud-fan
left a comment
Contributor
There was a problem hiding this comment.
0 blocking, 0 non-blocking, 0 nits.
The dialect-local fallback is narrowly scoped, uses the existing unsupported-expression path, and is covered at both unit and integration levels.
Verification
The MySQL builder delegates every non-DoubleType cast to the shared JDBC implementation. For DoubleType, it throws inside expression compilation; MySQLDialect.compileExpression catches the non-fatal failure and returns None, so the JDBC V2 scan leaves the filter for Spark evaluation. The added tests cover both that compilation result and the end-to-end local-filter behavior.
PR description suggestions
- Clarify the user-facing change: affected MySQL/MariaDB queries now fall back to Spark evaluation and succeed instead of sending an invalid
DOUBLE PRECISIONcast to the database.
cloud-fan
pushed a commit
that referenced
this pull request
Aug 4, 2026
MariaDB rejects CAST(... AS DOUBLE PRECISION). Stop pushing DoubleType casts in MySQLDialect so Spark evaluates them locally instead. ### What changes were proposed in this pull request? Block pushdown of cast to DOUBLE. Without this fix I got the error ``` [JDBC_EXTERNAL_ENGINE_SYNTAX_ERROR.DURING_QUERY_EXECUTION] JDBC external engine syntax error. The error was caused by the query SELECT `name` FROM `employee` WHERE (`salary` IS NOT NULL) AND (CAST(`salary` AS DOUBLE PRECISION) > 10000.5) . (conn=584) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PRECISION) > 10000.5)' at line 1. The error occurred during query execution. SQLSTATE: 42000 ``` ### Why are the changes needed? Fix a wrong query. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Added tests. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Opus 5 Closes #57756 from alekjarmov/alekjarmov/block-mysql-double-cast-pushdown. Authored-by: Alek Jarmov <alek.jarmov@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit 00ea1ab) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
cloud-fan
pushed a commit
that referenced
this pull request
Aug 4, 2026
MariaDB rejects CAST(... AS DOUBLE PRECISION). Stop pushing DoubleType casts in MySQLDialect so Spark evaluates them locally instead. ### What changes were proposed in this pull request? Block pushdown of cast to DOUBLE. Without this fix I got the error ``` [JDBC_EXTERNAL_ENGINE_SYNTAX_ERROR.DURING_QUERY_EXECUTION] JDBC external engine syntax error. The error was caused by the query SELECT `name` FROM `employee` WHERE (`salary` IS NOT NULL) AND (CAST(`salary` AS DOUBLE PRECISION) > 10000.5) . (conn=584) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'PRECISION) > 10000.5)' at line 1. The error occurred during query execution. SQLSTATE: 42000 ``` ### Why are the changes needed? Fix a wrong query. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Added tests. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Opus 5 Closes #57756 from alekjarmov/alekjarmov/block-mysql-double-cast-pushdown. Authored-by: Alek Jarmov <alek.jarmov@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit 00ea1ab) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
Contributor
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.
MariaDB rejects CAST(... AS DOUBLE PRECISION). Stop pushing DoubleType casts in MySQLDialect so Spark evaluates them locally instead.
What changes were proposed in this pull request?
Block pushdown of cast to DOUBLE. Without this fix I got the error
Why are the changes needed?
Fix a wrong query.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added tests.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Opus 5