-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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] Make delta.dataSkippingStatsColumns
more lenient for nested columns
#2850
base: master
Are you sure you want to change the base?
Changes from all commits
a9412bc
a864205
975f20b
6411e7a
e68028d
cbb0447
3759afd
329a571
b911d6a
0ea2fc8
81c60aa
6068eb0
60978a8
bb86d96
0c24d44
9bd8159
86c148f
25e6faa
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 |
---|---|---|
|
@@ -599,6 +599,33 @@ trait DataSkippingDeltaTestsBase extends DeltaExcludedBySparkVersionTestMixinShi | |
deltaStatsColNamesOpt = Some("b.c") | ||
) | ||
|
||
testSkipping( | ||
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. Should we consider double struct test? 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. Added a double nested struct as well |
||
"indexed column names - naming a nested column allows nested complex types", | ||
"""{ | ||
"a": { | ||
"b": [1, 2, 3], | ||
"c": [4, 5, 6], | ||
"d": 7, | ||
"e": 8, | ||
"f": { | ||
"g": 9 | ||
} | ||
}, | ||
"i": 10 | ||
}""".replace("\n", ""), | ||
hits = Seq( | ||
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. Could we have hit tests for elements inside struct and the double struct as well? Btw click on re-request review so that I get notified. 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. Added more hit tests 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. My understanding is that when we are inside struct, we gather stats for the valid datatypes inside the struct, but the invalid ones we still don't right? Would we want to test that we still don't skip the invalid datatypes inside the struct? 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. Also, if we can check another skipping valid type beside integer, like timestamp, string, ... that would be great 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. Technically null counts are collected, but they can't be used for skipping. We could add that to the test, but seems kind of out of scope because you can't do min/max things with arrays/maps anyway, so it'd have to be like an element contains or something 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. I think there are other non-skipping eligible datatypes than lists datatypes 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. I'm not sure how to specify a Binary type in the inferred JSON. Is that the only non-complex type? |
||
"i < 0", | ||
"a.d > 6", | ||
"a.f.g < 10" | ||
), | ||
misses = Seq( | ||
"a.d < 0", | ||
"a.e < 0", | ||
"a.f.g < 0" | ||
), | ||
deltaStatsColNamesOpt = Some("a") | ||
) | ||
|
||
testSkipping( | ||
"indexed column names - index only a subset of leaf columns", | ||
"""{ | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -499,14 +499,13 @@ class StatsCollectionSuite | |||
("BINARY", "BinaryType"), | ||||
("BOOLEAN", "BooleanType"), | ||||
("ARRAY<TINYINT>", "ArrayType(ByteType,true)"), | ||||
Kimahriman marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
("MAP<DATE, INT>", "MapType(DateType,IntegerType,true)"), | ||||
("STRUCT<c60:INT, c61:ARRAY<INT>>", "ArrayType(IntegerType,true)") | ||||
("MAP<DATE, INT>", "MapType(DateType,IntegerType,true)") | ||||
Kimahriman marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
).foreach { case (invalidType, typename) => | ||||
val tableName1 = "delta_table_1" | ||||
val tableName2 = "delta_table_2" | ||||
test(s"Delta statistic column: invalid data type $invalidType") { | ||||
withTable(tableName1, tableName2) { | ||||
val columnName = if (typename.equals("ArrayType(IntegerType,true)")) "c2.c61" else "c2" | ||||
val columnName = "c2" | ||||
val exceptOne = intercept[DeltaIllegalArgumentException] { | ||||
sql( | ||||
s"create table $tableName1 (c1 long, c2 $invalidType) using delta " + | ||||
|
@@ -530,7 +529,7 @@ class StatsCollectionSuite | |||
|
||||
test(s"Delta statistic column: invalid data type $invalidType in nested column") { | ||||
withTable(tableName1, tableName2) { | ||||
val columnName = if (typename == "ArrayType(IntegerType,true)") "c2.c21.c61" else "c2.c21" | ||||
val columnName = "c2.c21" | ||||
val exceptOne = intercept[DeltaIllegalArgumentException] { | ||||
sql( | ||||
s"create table $tableName1 (c1 long, c2 STRUCT<c20:INT, c21:$invalidType>) " + | ||||
|
@@ -541,16 +540,6 @@ class StatsCollectionSuite | |||
exceptOne.getErrorClass == "DELTA_COLUMN_DATA_SKIPPING_NOT_SUPPORTED_TYPE" && | ||||
exceptOne.getMessageParametersArray.toSeq == Seq(columnName, typename) | ||||
) | ||||
val exceptTwo = intercept[DeltaIllegalArgumentException] { | ||||
sql( | ||||
s"create table $tableName1 (c1 long, c2 STRUCT<c20:INT, c21:$invalidType>) " + | ||||
s"using delta TBLPROPERTIES('delta.dataSkippingStatsColumns' = 'c2')" | ||||
) | ||||
} | ||||
assert( | ||||
exceptTwo.getErrorClass == "DELTA_COLUMN_DATA_SKIPPING_NOT_SUPPORTED_TYPE" && | ||||
exceptTwo.getMessageParametersArray.toSeq == Seq(columnName, typename) | ||||
) | ||||
sql(s"create table $tableName2 (c1 long, c2 STRUCT<c20:INT, c21:$invalidType>) using delta") | ||||
val exceptThree = interceptWithUnwrapping[DeltaIllegalArgumentException] { | ||||
sql( | ||||
|
@@ -561,13 +550,6 @@ class StatsCollectionSuite | |||
exceptThree.getErrorClass == "DELTA_COLUMN_DATA_SKIPPING_NOT_SUPPORTED_TYPE" && | ||||
exceptThree.getMessageParametersArray.toSeq == Seq(columnName, typename) | ||||
) | ||||
val exceptFour = interceptWithUnwrapping[DeltaIllegalArgumentException] { | ||||
sql(s"ALTER TABLE $tableName2 SET TBLPROPERTIES('delta.dataSkippingStatsColumns'='c2')") | ||||
} | ||||
assert( | ||||
exceptFour.getErrorClass == "DELTA_COLUMN_DATA_SKIPPING_NOT_SUPPORTED_TYPE" && | ||||
exceptFour.getMessageParametersArray.toSeq == Seq(columnName, typename) | ||||
) | ||||
} | ||||
} | ||||
} | ||||
|
@@ -608,7 +590,8 @@ class StatsCollectionSuite | |||
|
||||
Seq( | ||||
"BIGINT", "DATE", "DECIMAL(3, 2)", "DOUBLE", "FLOAT", "INT", "SMALLINT", "STRING", | ||||
"TIMESTAMP", "TIMESTAMP_NTZ", "TINYINT" | ||||
"TIMESTAMP", "TIMESTAMP_NTZ", "TINYINT", "STRUCT<c3: BIGINT>", | ||||
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. Looks like there are relevant tests in DataSkippingDeltaTests as well delta/spark/src/test/scala/org/apache/spark/sql/delta/stats/DataSkippingDeltaTests.scala Line 442 in da5a5d2
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. Those tests are for specifying the number of indexed columns, not columns by name |
||||
"STRUCT<c3: BIGINT, c4: ARRAY<BIGINT>>" | ||||
).foreach { validType => | ||||
val tableName1 = "delta_table_1" | ||||
val tableName2 = "delta_table_2" | ||||
|
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.
should we also make the non-struct field have the same behavior?
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.
Up to you. The idea was if you directly specify an in-eligible type, throw an exception because you did something wrong. If you specify a struct, just work with the sub fields that are supported
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.
Then, I am good about it.
Thank you