-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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-21247][SQL] Type comparison should respect case-sensitive SQL conf #18460
Closed
+102
−5
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
037120b
[SPARK-21247][SQL] Allow case-insensitive type equality in Set operation
dongjoon-hyun cded719
Add comments.
dongjoon-hyun 180e1b3
Address comments.
dongjoon-hyun 2343d97
Add test case.
dongjoon-hyun 8fa884e
Move to findTightestCommonType.
dongjoon-hyun b2d1338
Move testcase, too.
dongjoon-hyun c72aa18
Add test cases.
dongjoon-hyun 67a037c
Update test cases.
dongjoon-hyun 52d19d3
Address comments.
dongjoon-hyun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,14 +131,17 @@ class TypeCoercionSuite extends AnalysisTest { | |
widenFunc: (DataType, DataType) => Option[DataType], | ||
t1: DataType, | ||
t2: DataType, | ||
expected: Option[DataType]): Unit = { | ||
expected: Option[DataType], | ||
isSymmetric: Boolean = true): Unit = { | ||
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. @gatorsmile . I extended this function for using non-symmetric tests and addressed your comments. |
||
var found = widenFunc(t1, t2) | ||
assert(found == expected, | ||
s"Expected $expected as wider common type for $t1 and $t2, found $found") | ||
// Test both directions to make sure the widening is symmetric. | ||
found = widenFunc(t2, t1) | ||
assert(found == expected, | ||
s"Expected $expected as wider common type for $t2 and $t1, found $found") | ||
if (isSymmetric) { | ||
found = widenFunc(t2, t1) | ||
assert(found == expected, | ||
s"Expected $expected as wider common type for $t2 and $t1, found $found") | ||
} | ||
} | ||
|
||
test("implicit type cast - ByteType") { | ||
|
@@ -385,6 +388,47 @@ class TypeCoercionSuite extends AnalysisTest { | |
widenTest(NullType, StructType(Seq()), Some(StructType(Seq()))) | ||
widenTest(StringType, MapType(IntegerType, StringType, true), None) | ||
widenTest(ArrayType(IntegerType), StructType(Seq()), None) | ||
|
||
widenTest( | ||
StructType(Seq(StructField("a", IntegerType))), | ||
StructType(Seq(StructField("b", IntegerType))), | ||
None) | ||
widenTest( | ||
StructType(Seq(StructField("a", IntegerType, nullable = false))), | ||
StructType(Seq(StructField("a", DoubleType, nullable = false))), | ||
None) | ||
|
||
widenTest( | ||
StructType(Seq(StructField("a", IntegerType, nullable = false))), | ||
StructType(Seq(StructField("a", IntegerType, nullable = false))), | ||
Some(StructType(Seq(StructField("a", IntegerType, nullable = false))))) | ||
widenTest( | ||
StructType(Seq(StructField("a", IntegerType, nullable = false))), | ||
StructType(Seq(StructField("a", IntegerType, nullable = true))), | ||
Some(StructType(Seq(StructField("a", IntegerType, nullable = true))))) | ||
widenTest( | ||
StructType(Seq(StructField("a", IntegerType, nullable = true))), | ||
StructType(Seq(StructField("a", IntegerType, nullable = false))), | ||
Some(StructType(Seq(StructField("a", IntegerType, nullable = true))))) | ||
widenTest( | ||
StructType(Seq(StructField("a", IntegerType, nullable = true))), | ||
StructType(Seq(StructField("a", IntegerType, nullable = true))), | ||
Some(StructType(Seq(StructField("a", IntegerType, nullable = true))))) | ||
|
||
withSQLConf(SQLConf.CASE_SENSITIVE.key -> "true") { | ||
widenTest( | ||
StructType(Seq(StructField("a", IntegerType))), | ||
StructType(Seq(StructField("A", IntegerType))), | ||
None) | ||
} | ||
withSQLConf(SQLConf.CASE_SENSITIVE.key -> "false") { | ||
checkWidenType( | ||
TypeCoercion.findTightestCommonType, | ||
StructType(Seq(StructField("a", IntegerType), StructField("B", IntegerType))), | ||
StructType(Seq(StructField("A", IntegerType), StructField("b", IntegerType))), | ||
Some(StructType(Seq(StructField("a", IntegerType), StructField("B", IntegerType)))), | ||
isSymmetric = false) | ||
} | ||
} | ||
|
||
test("wider common type for decimal and array") { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Since we already have
DataType.equalsIgnoreCaseAndNullability
, we can use this according to the SQL configuration.