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-50792][SQL][FOLLOWUP] Improve the push down information for binary #49555

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

Conversation

beliefer
Copy link
Contributor

What changes were proposed in this pull request?

This PR proposes to improve the push down information for binary.

Why are the changes needed?

Before this PR. the push down information for binary looks like below.
PushedFilters: [binary_col IS NOT NULL, binary_col = [B@6e5af973]

After this PR, the push down information will be:
PushedFilters: [binary_col IS NOT NULL, binary_col = X'123456']

Does this PR introduce any user-facing change?

'Yes'.
Fix the bug.

How was this patch tested?

GA

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

'No'.

@github-actions github-actions bot added the SQL label Jan 17, 2025
@beliefer
Copy link
Contributor Author

ping @cloud-fan cc @sunxiaoguang

case BinaryType =>
assert(value.isInstanceOf[Array[Byte]])
val bytes = value.asInstanceOf[Array[Byte]]
bytes.map("%02X".format(_)).mkString("X'", "", "'")
Copy link
Member

Choose a reason for hiding this comment

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

Seems like X literal isn't universal and depends on dialect (#49452)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. you said right. The output information is just a generic represent like the others.

Copy link
Member

Choose a reason for hiding this comment

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

How about to use ApacheHex.encodeHexString(binary, ... as in other places in the file.

Copy link
Contributor

Choose a reason for hiding this comment

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

where else do we use encodeHexString?

Copy link
Contributor

Choose a reason for hiding this comment

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

Anyway, this is for display only, we just need a popular binary value pretty string format.

Copy link
Contributor Author

@beliefer beliefer Jan 21, 2025

Choose a reason for hiding this comment

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

Spark SQL already parsed the format X'123456'.

The binary literal show the format 0x123456.

  override def toString: String = value match {
    case null => "null"
    case binary: Array[Byte] => "0x" + ApacheHex.encodeHexString(binary, false)

Which one is the better?

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.

4 participants