[
https://issues.apache.org/jira/browse/SPARK-23985?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16625432#comment-16625432
]
Yuming Wang edited comment on SPARK-23985 at 9/24/18 7:07 AM:
--------------------------------------------------------------
You should move {{where("a>'1'")}} before {{withColumn}}:
{code}
import org.apache.spark.sql.functions._
spark.range(10).selectExpr(
"cast(id as string) a",
"id as b").write.saveAsTable("t1")
val windowSpec = Window.partitionBy(concat(col("a"), lit("lit"))).orderBy("b")
spark.table("t1").where("a>'1'").withColumn("d", row_number() over
windowSpec).explain{code}
{noformat}
== Physical Plan ==
*(3) Project [a#8, b#9L, d#13]
+- Window [row_number() windowspecdefinition(_w0#19, b#9L ASC NULLS FIRST,
specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS d#13],
[_w0#19], [b#9L ASC NULLS FIRST]
+- *(2) Sort [_w0#19 ASC NULLS FIRST, b#9L ASC NULLS FIRST], false, 0
+- Exchange hashpartitioning(_w0#19, 5)
+- *(1) Project [a#8, b#9L, concat(a#8, lit) AS _w0#19]
+- *(1) Filter (isnotnull(a#8) && (a#8 > 1))
+- *(1) FileScan parquet default.t1[a#8,b#9L] Batched: true,
DataFilters: [isnotnull(a#8), (a#8 > 1)], Format: Parquet, Location:
InMemoryFileIndex[file:/Users/yumwang/opensource/spark/core/spark-warehouse/t1],
PartitionFilters: [], PushedFilters: [IsNotNull(a), GreaterThan(a,1)],
ReadSchema: struct<a:string,b:bigint>
{noformat}
was (Author: q79969786):
This works:
{code:scala}
import org.apache.spark.sql.functions._
spark.range(10).selectExpr(
"cast(id as string) a",
"id as b").write.saveAsTable("t1")
val windowSpec = Window.partitionBy(concat(col("a"), lit("lit"))).orderBy("b")
spark.table("t1").where("a>'1'").withColumn("d", row_number() over
windowSpec).explain{code}
{noformat}
== Physical Plan ==
*(3) Project [a#8, b#9L, d#13]
+- Window [row_number() windowspecdefinition(_w0#19, b#9L ASC NULLS FIRST,
specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS d#13],
[_w0#19], [b#9L ASC NULLS FIRST]
+- *(2) Sort [_w0#19 ASC NULLS FIRST, b#9L ASC NULLS FIRST], false, 0
+- Exchange hashpartitioning(_w0#19, 5)
+- *(1) Project [a#8, b#9L, concat(a#8, lit) AS _w0#19]
+- *(1) Filter (isnotnull(a#8) && (a#8 > 1))
+- *(1) FileScan parquet default.t1[a#8,b#9L] Batched: true,
DataFilters: [isnotnull(a#8), (a#8 > 1)], Format: Parquet, Location:
InMemoryFileIndex[file:/Users/yumwang/opensource/spark/core/spark-warehouse/t1],
PartitionFilters: [], PushedFilters: [IsNotNull(a), GreaterThan(a,1)],
ReadSchema: struct<a:string,b:bigint>
{noformat}
> predicate push down doesn't work with simple compound partition spec
> --------------------------------------------------------------------
>
> Key: SPARK-23985
> URL: https://issues.apache.org/jira/browse/SPARK-23985
> Project: Spark
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 2.4.0
> Reporter: Ohad Raviv
> Priority: Minor
>
> while predicate push down works with this query:
> {code:sql}
> select *, row_number() over (partition by a order by b) from t1 where a>1
> {code}
> it dowsn't work with:
> {code:sql}
> select *, row_number() over (partition by concat(a,'lit') order by b) from t1
> where a>1
> {code}
>
> I added a test to FilterPushdownSuite which I think recreates the problem:
> {code:scala}
> test("Window: predicate push down -- ohad") {
> val winExpr = windowExpr(count('b),
> windowSpec(Concat('a :: Nil) :: Nil, 'b.asc :: Nil, UnspecifiedFrame))
> val originalQuery = testRelation.select('a, 'b, 'c,
> winExpr.as('window)).where('a > 1)
> val correctAnswer = testRelation
> .where('a > 1).select('a, 'b, 'c)
> .window(winExpr.as('window) :: Nil, 'a :: Nil, 'b.asc :: Nil)
> .select('a, 'b, 'c, 'window).analyze
> comparePlans(Optimize.execute(originalQuery.analyze), correctAnswer)
> }
> {code}
> will try to create a PR with a correction
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]