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-50707][SQL] Enable casting to/from char/varchar #49340

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

jovanm-db
Copy link
Contributor

@jovanm-db jovanm-db commented Dec 31, 2024

What changes were proposed in this pull request?

Enable casting to/from char/varchar.

Why are the changes needed?

Currently cast does not work correctly. It always casts to StringType. This PR enables casting to CharType and VarcharType. This only applies when spark.sql.preserveCharVarcharTypeInfo is set to true.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Added tests in:

  • CharVarcharTestSuite
  • CastSuiteBase

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

No.

@github-actions github-actions bot added the SQL label Dec 31, 2024
Copy link
Contributor

@mihailom-db mihailom-db left a comment

Choose a reason for hiding this comment

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

Left some comments, please give update and ping me again for review.

}
}

test("implicitly cast char/varchar into atomics") {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you say atomics, could you add other types as well, other than boolean.

@HyukjinKwon HyukjinKwon changed the title [SPARK-50707] Enable casting to/from char/varchar [SPARK-50707][SQL] Enable casting to/from char/varchar Jan 2, 2025
return None
}
if (!SqlApiConf.get.preserveCharVarcharTypeInfo) {
return Some(StringType(s1.collationId))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just return s2 as previous behaviour here?

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