ohad-definity commented on code in PR #59706:
URL: https://github.com/apache/spark/pull/59706#discussion_r4523880983
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/SchemaPruning.scala:
##########
@@ -40,6 +49,20 @@ object SchemaPruning extends Rule[LogicalPlan] {
override def apply(plan: LogicalPlan): LogicalPlan =
plan transformDown {
+ case op @ GeneratorsOverScan(_, _,
+ l @ LogicalRelationWithTable(hadoopFsRelation: HadoopFsRelation, _))
+ if !hadoopFsRelation.fileFormat.isInstanceOf[OrcFileFormat] =>
Review Comment:
Thanks for measuring it. Taken as suggested in 266974dc: the V1 guard now
accepts only `ParquetFileFormat`, with the reason next to it (other formats but
ORC never prune their data schema; ORC is not pruned through generators yet).
##########
sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/SchemaPruningSuite.scala:
##########
@@ -671,20 +1300,20 @@ abstract class SchemaPruningSuite
val query1 = spark.table("contacts")
.select(explode(col("friends")).as("friend"))
.select("friend.first")
- checkScan(query1, "struct<friends:array<struct<first:string>>>")
+ checkGeneratorScan(query1, "struct<friends:array<struct<first:string>>>")
Review Comment:
Good catch, done in 266974dc: `query1` and `query3` use `checkScan` again in
both the SPARK-34638 and the SPARK-41961 tests, so the single-field and
whole-element scans stay pinned on ORC too. Only `query2` uses
`checkGeneratorScan`.
##########
sql/core/benchmarks/ParquetNestedSchemaPruningBenchmark-results.txt:
##########
@@ -2,52 +2,61 @@
Nested Schema Pruning Benchmark For Parquet
================================================================================================
-OpenJDK 64-Bit Server VM 21.0.12+8-LTS on Linux 6.17.0-1020-azure
-AMD EPYC 9V74 80-Core Processor
+OpenJDK 64-Bit Server VM 21.0.13.0.3+1-LTS on Linux 7.0.0-1017-azure
+AMD EPYC 9V45 96-Core Processor
Selection: Best Time(ms) Avg Time(ms)
Stdev(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------------------------------
-Top-level column 70 85
13 14.3 69.9 1.0X
-Nested column 71 82
8 14.1 70.9 1.0X
-Nested column in array 227 247
14 4.4 227.1 0.3X
+Top-level column 35 43
8 28.6 35.0 1.0X
+Nested column 36 40
4 27.9 35.8 1.0X
+Nested column in array 131 134
3 7.6 131.1 0.3X
-OpenJDK 64-Bit Server VM 21.0.12+8-LTS on Linux 6.17.0-1020-azure
-AMD EPYC 9V74 80-Core Processor
+OpenJDK 64-Bit Server VM 21.0.13.0.3+1-LTS on Linux 7.0.0-1017-azure
+AMD EPYC 9V45 96-Core Processor
Limiting: Best Time(ms) Avg Time(ms)
Stdev(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------------------------------
-Top-level column 277 288
8 3.6 277.4 1.0X
-Nested column 279 289
8 3.6 278.9 1.0X
-Nested column in array 622 653
22 1.6 621.9 0.4X
+Top-level column 164 180
18 6.1 163.8 1.0X
+Nested column 168 178
6 6.0 167.9 1.0X
+Nested column in array 379 392
17 2.6 378.8 0.4X
-OpenJDK 64-Bit Server VM 21.0.12+8-LTS on Linux 6.17.0-1020-azure
-AMD EPYC 9V74 80-Core Processor
+OpenJDK 64-Bit Server VM 21.0.13.0.3+1-LTS on Linux 7.0.0-1017-azure
+AMD EPYC 9V45 96-Core Processor
Repartitioning: Best Time(ms) Avg Time(ms)
Stdev(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------------------------------
-Top-level column 246 252
5 4.1 246.3 1.0X
-Nested column 256 268
12 3.9 256.3 1.0X
-Nested column in array 571 590
9 1.8 570.7 0.4X
+Top-level column 150 160
9 6.7 150.1 1.0X
+Nested column 153 164
8 6.6 152.6 1.0X
+Nested column in array 349 360
18 2.9 349.3 0.4X
-OpenJDK 64-Bit Server VM 21.0.12+8-LTS on Linux 6.17.0-1020-azure
-AMD EPYC 9V74 80-Core Processor
+OpenJDK 64-Bit Server VM 21.0.13.0.3+1-LTS on Linux 7.0.0-1017-azure
+AMD EPYC 9V45 96-Core Processor
Repartitioning by exprs: Best Time(ms) Avg Time(ms)
Stdev(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------------------------------
-Top-level column 244 249
8 4.1 243.7 1.0X
-Nested column 278 292
11 3.6 278.0 0.9X
-Nested column in array 621 625
3 1.6 621.0 0.4X
+Top-level column 149 163
15 6.7 149.2 1.0X
+Nested column 164 174
10 6.1 164.0 0.9X
+Nested column in array 375 381
5 2.7 375.3 0.4X
-OpenJDK 64-Bit Server VM 21.0.12+8-LTS on Linux 6.17.0-1020-azure
-AMD EPYC 9V74 80-Core Processor
+OpenJDK 64-Bit Server VM 21.0.13.0.3+1-LTS on Linux 7.0.0-1017-azure
+AMD EPYC 9V45 96-Core Processor
Sample: Best Time(ms) Avg Time(ms)
Stdev(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------------------------------
-Top-level column 81 95
8 12.3 81.1 1.0X
-Nested column 92 102
12 10.8 92.2 0.9X
-Nested column in array 285 308
13 3.5 284.7 0.3X
+Top-level column 49 57
5 20.2 49.5 1.0X
+Nested column 55 63
8 18.3 54.6 0.9X
+Nested column in array 164 182
8 6.1 164.0 0.3X
-OpenJDK 64-Bit Server VM 21.0.12+8-LTS on Linux 6.17.0-1020-azure
-AMD EPYC 9V74 80-Core Processor
+OpenJDK 64-Bit Server VM 21.0.13.0.3+1-LTS on Linux 7.0.0-1017-azure
+AMD EPYC 9V45 96-Core Processor
Sorting: Best Time(ms) Avg Time(ms)
Stdev(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------------------------------
-Top-level column 335 349
23 3.0 334.7 1.0X
-Nested column 393 407
25 2.5 393.0 0.9X
-Nested column in array 827 853
30 1.2 826.7 0.4X
+Top-level column 204 216
19 4.9 204.1 1.0X
+Nested column 234 245
14 4.3 234.3 0.9X
+Nested column in array 488 502
11 2.0 488.5 0.4X
+
+OpenJDK 64-Bit Server VM 21.0.13.0.3+1-LTS on Linux 7.0.0-1017-azure
+AMD EPYC 9V45 96-Core Processor
+Explode: Best
Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative
+---------------------------------------------------------------------------------------------------------------------------------------------------
+Two nested fields of an exploded array, through generate false
1040 1094 51 4.8 207.9 1.0X
Review Comment:
Thanks, updated: the description now quotes the JDK 21 run in this file:
1040 → 256 ms (4.1×) and 428 → 255 ms (1.7×).
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/NestedColumnAliasing.scala:
##########
@@ -408,11 +408,9 @@ object GeneratorNestedColumnAliasing {
attrToExtractValuesOnGenerator.flatMap(_._2).toSeq, Seq.empty,
collectNestedGetStructFields)
- // Pruning on `Generator`'s output. We only process single field case.
- // For multiple field case, we cannot directly move field extractor into
- // the generator expression. A workaround is to re-construct array of
struct
- // from multiple fields. But it will be more complicated and may not
worth.
- // TODO(SPARK-34956): support multiple fields.
+ // Pruning on `Generator`'s output. We only process single field case: a
single field
+ // extractor can be moved into the generator expression. Multiple fields
of a generator's
+ // output are pruned at the scan by `SchemaPruning` instead
(SPARK-34956).
Review Comment:
Taken as suggested in 266974dc.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]