Skip to content

[SPARK-58554][SQL] Block MySQL double cast pushdown - #57756

Closed
alekjarmov wants to merge 1 commit into
apache:masterfrom
alekjarmov:alekjarmov/block-mysql-double-cast-pushdown
Closed

[SPARK-58554][SQL] Block MySQL double cast pushdown#57756
alekjarmov wants to merge 1 commit into
apache:masterfrom
alekjarmov:alekjarmov/block-mysql-double-cast-pushdown

Conversation

@alekjarmov

@alekjarmov alekjarmov commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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

MariaDB rejects CAST(... AS DOUBLE PRECISION). Stop pushing DoubleType
casts in MySQLDialect so Spark evaluates them locally instead.
@alekjarmov alekjarmov changed the title [SQL] Block MySQL double cast pushdown [SPARK-58554][SQL] Block MySQL double cast pushdown Aug 4, 2026

@cloud-fan cloud-fan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 PRECISION cast to the database.

@cloud-fan cloud-fan closed this in 00ea1ab Aug 4, 2026
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>
@cloud-fan

Copy link
Copy Markdown
Contributor

Merge Summary:

Posted by merge_spark_pr.py

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.

2 participants