-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-26402][SQL] Accessing nested fields with different cases in case insensitive mode #23353
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 10 commits
43351df
a5998bb
4f21a36
5f1cc66
a22d13e
cd14e14
2a4ec20
5273c3c
81f5e5e
82fa2e1
1ce6487
f7a64cf
e1da199
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 |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ package org.apache.spark.sql.catalyst.expressions | |
| import org.apache.spark.SparkFunSuite | ||
| import org.apache.spark.sql.catalyst.dsl.plans._ | ||
| import org.apache.spark.sql.catalyst.plans.logical.Range | ||
| import org.apache.spark.sql.types.{IntegerType, StructField, StructType} | ||
|
|
||
| class CanonicalizeSuite extends SparkFunSuite { | ||
|
|
||
|
|
@@ -50,4 +51,32 @@ class CanonicalizeSuite extends SparkFunSuite { | |
| assert(range.where(arrays1).sameResult(range.where(arrays2))) | ||
| assert(!range.where(arrays1).sameResult(range.where(arrays3))) | ||
| } | ||
|
|
||
| test("SPARK-26402: accessing nested fields with different cases in case insensitive mode") { | ||
| val expId = NamedExpression.newExprId | ||
| val qualifier = Seq.empty[String] | ||
| val structType = StructType( | ||
| StructField("a", StructType(StructField("b", IntegerType, false) :: Nil), false) :: Nil) | ||
|
|
||
| // GetStructField with different names are semantically equal | ||
| val fieldB1 = GetStructField( | ||
| AttributeReference("data1", structType, false)(expId, qualifier), | ||
| 0, Some("b1")) | ||
|
||
| val fieldB2 = GetStructField( | ||
| AttributeReference("data2", structType, false)(expId, qualifier), | ||
| 0, Some("b2")) | ||
| assert(fieldB1.semanticEquals(fieldB2)) | ||
|
||
|
|
||
| val fieldA1 = GetStructField( | ||
| GetStructField( | ||
| AttributeReference("data1", structType, false)(expId, qualifier), | ||
| 0, Some("a1")), | ||
| 0, Some("b1")) | ||
| val fieldA2 = GetStructField( | ||
| GetStructField( | ||
| AttributeReference("data2", structType, false)(expId, qualifier), | ||
| 0, Some("a2")), | ||
| 0, Some("b2")) | ||
| assert(fieldA1.semanticEquals(fieldA2)) | ||
| } | ||
| } | ||
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.
It looks not precisely matched the comments of
ignoreNamesTypes. It's better to change it accordingly.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.
/** Remove names and nullability from types. */I can change it to
and / or.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.
The comment of
Canonicalizesays:It's also needed to be update.
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.
Actually after this change it is not only for types.
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.
Thanks. I re-wrote it a bit. Should look okay now.