-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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-9154][SQL] codegen StringFormat #7546
Changes from all commits
086caba
cd8322b
10b4de8
a943d3e
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 |
---|---|---|
|
@@ -351,18 +351,16 @@ class StringExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper { | |
} | ||
|
||
test("FORMAT") { | ||
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. existing: would you mind rewriting these to avoid the use of row and just use literals? using a row makes the test cases harder to follow since you have to look in multiple places to understand what is going on. 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. Thanks for cleaning this up! |
||
val f = 'f.string.at(0) | ||
val d1 = 'd.int.at(1) | ||
val s1 = 's.int.at(2) | ||
|
||
val row1 = create_row("aa%d%s", 12, "cc") | ||
val row2 = create_row(null, 12, "cc") | ||
checkEvaluation(StringFormat(Literal("aa%d%s"), Literal(123), Literal("a")), "aa123a", row1) | ||
checkEvaluation(StringFormat(Literal("aa%d%s"), Literal(123), Literal("a")), "aa123a") | ||
checkEvaluation(StringFormat(Literal("aa")), "aa", create_row(null)) | ||
checkEvaluation(StringFormat(Literal("aa%d%s"), Literal(123), Literal("a")), "aa123a", row1) | ||
checkEvaluation(StringFormat(Literal("aa%d%s"), Literal(123), Literal("a")), "aa123a") | ||
checkEvaluation(StringFormat(Literal("aa%d%s"), 12, "cc"), "aa12cc") | ||
|
||
checkEvaluation(StringFormat(f, d1, s1), "aa12cc", row1) | ||
checkEvaluation(StringFormat(f, d1, s1), null, row2) | ||
checkEvaluation(StringFormat(Literal.create(null, StringType), 12, "cc"), null) | ||
checkEvaluation( | ||
StringFormat(Literal("aa%d%s"), Literal.create(null, IntegerType), "cc"), "aanullcc") | ||
checkEvaluation( | ||
StringFormat(Literal("aa%d%s"), 12, Literal.create(null, StringType)), "aa12null") | ||
} | ||
|
||
test("INSTR") { | ||
|
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.
@marmbrus Is this what you proposed?
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.
This works. I think
StringType :: List.fill(children.size - 1)(AnyDataType)
might be a little more clear.