Skip to content

Conversation

@AngersZhuuuu
Copy link
Contributor

What changes were proposed in this pull request?

Currently , ConstantFolding use Literal.create() to represent the result of constant.
If the data type is ObjectType, such as ObjectType(classOf[UTF8String]),
current Literal.create will first convert UTF8String to String, then failed to create ObjectType literal.
this pr to fix this issue.

Why are the changes needed?

Fix bug

Does this PR introduce any user-facing change?

User can create ObjectType literal use Literal.create() more safety.

How was this patch tested?

Added UT

@github-actions github-actions bot added the SQL label Jan 20, 2022
@AngersZhuuuu
Copy link
Contributor Author

ping @cloud-fan, I think we can merge this before #35207

Literal(CatalystTypeConverters.createToCatalystConverter(dataType)(v), dataType)
case _: DayTimeIntervalType if v.isInstanceOf[Duration] =>
Literal(CatalystTypeConverters.createToCatalystConverter(dataType)(v), dataType)
case _: ObjectType => Literal(v, dataType)
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we do some assertion here? e.g. v.getClass should be or a sub-class of ObjectType.cls

Copy link
Contributor Author

Choose a reason for hiding this comment

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

shall we do some assertion here? e.g. v.getClass should be or a sub-class of ObjectType.cls

Already have a check in Literal.validateLiteralValue(value, dataType) when constructing Literal

@AngersZhuuuu
Copy link
Contributor Author

ping @cloud-fan GA passed

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in f934145 Jan 21, 2022
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