-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-19254][SQL] Support Seq, Map, and Struct in functions.lit #16610
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -102,6 +102,27 @@ object functions { | |
| Column(literalExpr) | ||
| } | ||
|
|
||
| /** | ||
| * Creates a [[Column]] of literal value. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should explain when you want to use this method instead of
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay, I'll update
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated |
||
| * | ||
| * The passed in object is returned directly if it is already a [[Column]]. | ||
| * If the object is a Scala Symbol, it is converted into a [[Column]] also. | ||
| * Otherwise, a new [[Column]] is created to represent the literal value. | ||
| * | ||
| * @group normal_funcs | ||
| * @since 2.2.0 | ||
| */ | ||
| def typedLit[T : TypeTag](literal: T): Column = { | ||
|
||
| literal match { | ||
|
||
| case c: Column => return c | ||
| case s: Symbol => return new ColumnName(literal.asInstanceOf[Symbol].name) | ||
| case _ => // continue | ||
| } | ||
|
|
||
| val literalExpr = Literal.create(literal) | ||
| Column(literalExpr) | ||
| } | ||
|
|
||
| ////////////////////////////////////////////////////////////////////////////////////////////// | ||
| // Sort functions | ||
| ////////////////////////////////////////////////////////////////////////////////////////////// | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call
create(v, dataType)instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha, you're right. I'll fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, my bad. I found the code you suggested made some tests fail. Actually,
CatalystTypeConverters.convertToCatalystdoes not do the same thing withCatalystTypeConverters.createToCatalystConverter(dataType). For instance,CatalystTypeConverters.convertToCatalystdoes not convertTupleXtoGenericInternalRow.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you be going to talks :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha, actually I'm joining the dev talk now ;)