[
https://issues.apache.org/jira/browse/SPARK-45876?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17787261#comment-17787261
]
Alexander Petrossian (PAF) commented on SPARK-45876:
----------------------------------------------------
Original plans:
{code:java}
== Parsed Logical Plan ==
'Project ['request]
+- 'Filter ('c.value = 79640000000)
+- 'Generate 'explode('request.characteristic), false, ctable, ['c]
+- 'UnresolvedRelation [test], [], false
== Analyzed Logical Plan ==
request: struct<characteristic:array<struct<id:string,value:string>>>
Project [request#3]
+- Filter (c#5.value = 79640000000)
+- Generate explode(request#3.characteristic), false, ctable, [c#5]
+- SubqueryAlias spark_catalog.default.test
+- Relation spark_catalog.default.test[system#2,request#3] orc
== Optimized Logical Plan ==
Project [request#3]
+- Filter (isnotnull(c#5.value) AND (c#5.value = 79640000000))
+- Generate explode(request#3.characteristic), false, ctable, [c#5]
+- Project [request#3]
+- Relation spark_catalog.default.test[system#2,request#3] orc
== Physical Plan ==
*(1) Project [request#3]
+- *(1) Filter (isnotnull(c#5.value) AND (c#5.value = 79640000000))
+- *(1) Generate explode(request#3.characteristic), [request#3], false, [c#5]
+- *(1) ColumnarToRow
+- FileScan orc spark_catalog.default.test[request#3] Batched: true,
DataFilters: [], Format: ORC, Location: InMemoryFileIndex(1
paths)[file:/Users/paf/Documents/Hermes/EDR/spark-tests/spark-warehouse/testf...,
PartitionFilters: [], PushedFilters: [], ReadSchema:
struct<request:struct<characteristic:array<struct<id:string,value:string>>>>
{code}
Details on original physical:
{code:java}
== Physical Plan ==
* Project (5)
+- * Filter (4)
+- * Generate (3)
+- * ColumnarToRow (2)
+- Scan orc spark_catalog.default.test (1)
(1) Scan orc spark_catalog.default.test
Output [1]: [request#3]
Batched: true
Location: InMemoryFileIndex
[file:/Users/paf/Documents/Hermes/EDR/spark-tests/spark-warehouse/testfolder]
ReadSchema:
struct<request:struct<characteristic:array<struct<id:string,value:string>>>>
(2) ColumnarToRow [codegen id : 1]
Input [1]: [request#3]
(3) Generate [codegen id : 1]
Input [1]: [request#3]
Arguments: explode(request#3.characteristic), [request#3], false, [c#5]
(4) Filter [codegen id : 1]
Input [2]: [request#3, c#5]
Condition : (isnotnull(c#5.value) AND (c#5.value = 79640000000))
(5) Project [codegen id : 1]
Output [1]: [request#3]
Input [2]: [request#3, c#5] {code}
> Filters are not pushed down across lateral view
> -----------------------------------------------
>
> Key: SPARK-45876
> URL: https://issues.apache.org/jira/browse/SPARK-45876
> Project: Spark
> Issue Type: Bug
> Components: Spark Core
> Affects Versions: 3.5.0
> Reporter: Alexander Petrossian (PAF)
> Priority: Major
> Attachments: Снимок экрана 2023-11-14 в 16.33.48.png, Снимок экрана
> 2023-11-14 в 16.35.56.png, Снимок экрана 2023-11-14 в 16.55.11.png, Снимок
> экрана 2023-11-14 в 16.55.31.png, Снимок экрана 2023-11-14 в 16.58.56.png
>
>
> {code:python}
> from pyspark.sql import SparkSession
> spark = SparkSession.builder.config("spark.sql.catalogImplementation",
> "hive").appName("Write ORC File").getOrCreate()
> spark.sql('drop TABLE if exists test').show()
> spark.sql('CREATE EXTERNAL TABLE test (request
> struct<characteristic:array<struct<id:string,value:string>>>)'
> 'ROW FORMAT SERDE "org.apache.hadoop.hive.ql.io.orc.OrcSerde" '
> 'STORED AS INPUTFORMAT "org.apache.hadoop.hive.ql.io.orc.OrcInputFormat" '
> 'OUTPUTFORMAT "org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat" '
> 'LOCATION "testfolder"').show()
> spark.sql("select request from test lateral view
> explode(request.characteristic) cTable as c where
> c.value='79640000000'").explain()
> {code}
> shows
> {code}
> == Physical Plan ==
> *(1) Project [request#2]
> +- *(1) Filter (isnotnull(c#4.value) AND (c#4.value = 79640000000))
> +- *(1) Generate explode(request#2.characteristic), [request#2], false,
> [c#4]
> +- *(1) ColumnarToRow
> +- FileScan orc spark_catalog.default.test[request#2] Batched: true,
> DataFilters: [], Format: ORC, Location: InMemoryFileIndex(1
> paths)[file:/Users/paf/Downloads/spark-warehouse/testfolder],
> PartitionFilters: [], PushedFilters: [], ReadSchema:
> struct<request:struct<characteristic:array<struct<id:string,value:string>>>>
> {code}
> Which is extremely slow.
> Suppose I search for a column value, which is totally out of min/max
> statistics range.
> Search could have been much faster, but no.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]