Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-49856][SQL] Refactor the compileExpression of JdbcDialect for simplify the subclass. #48322

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

beliefer
Copy link
Contributor

@beliefer beliefer commented Oct 2, 2024

What changes were proposed in this pull request?

This PR proposes to refactor the compileExpression of JdbcDialect so that simplify the subclass.

Why are the changes needed?

Current definition of compileExpression works with the JDBCSQLBuilder. The JDBC dialect should override the compileExpression with almost identical code if JDBC dialect want supports special SQL syntax.
This PR adds the function jdbcSQLBuilder(): JDBCSQLBuilder, so that the subclass could reuse the code come from parent.

Does this PR introduce any user-facing change?

'No'.
New feature.

How was this patch tested?

GA tests.

Was this patch authored or co-authored using generative AI tooling?

'No'.

@beliefer
Copy link
Contributor Author

beliefer commented Oct 8, 2024

ping @cloud-fan

/**
* Converts V2 expression to String representing a SQL expression.
* @param expr The V2 expression to be converted.
* @return Converted value.
*/
@Since("3.3.0")
def compileExpression(expr: Expression): Option[String] = {
val jdbcSQLBuilder = new JDBCSQLBuilder()
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if it's worthwhile to add a new API for saving like copying 10 line of code... but I don't have a strong preference on this.

cc @milastdbx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants