You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/01/02 09:51:18 UTC

[GitHub] [spark] wangyum opened a new pull request #30991: [SPARK-33959][SQL] Improve the statistics estimation of the Tail

wangyum opened a new pull request #30991:
URL: https://github.com/apache/spark/pull/30991


   ### What changes were proposed in this pull request?
   
   This pr improve the statistics estimation of the `Tail`:
   
   ```scala
   spark.sql("set spark.sql.cbo.enabled=true")
   spark.range(100).selectExpr("id as a", "id as b", "id as c", "id as e").write.saveAsTable("t1")
   println(Tail(Literal(5), spark.sql("SELECT * FROM t1").queryExecution.logical).queryExecution.stringWithStats)
   ```
   
   Before this pr:
   ```
   == Optimized Logical Plan ==
   Tail 5, Statistics(sizeInBytes=3.8 KiB)
   +- Relation[a#24L,b#25L,c#26L,e#27L] parquet, Statistics(sizeInBytes=3.8 KiB)
   ```
   
   After this pr:
   ```
   == Optimized Logical Plan ==
   Tail 5, Statistics(sizeInBytes=200.0 B, rowCount=5)
   +- Relation[a#24L,b#25L,c#26L,e#27L] parquet, Statistics(sizeInBytes=3.8 KiB)
   ```
   
   ### Why are the changes needed?
   
   Import statistics estimation.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Unit test.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30991: [SPARK-33959][SQL] Improve the statistics estimation of the Tail

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30991:
URL: https://github.com/apache/spark/pull/30991#issuecomment-753462053


   Kubernetes integration test starting
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38180/
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #30991: [SPARK-33959][SQL] Improve the statistics estimation of the Tail

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30991:
URL: https://github.com/apache/spark/pull/30991#issuecomment-753467888


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/38180/
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #30991: [SPARK-33959][SQL] Improve the statistics estimation of the Tail

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30991:
URL: https://github.com/apache/spark/pull/30991#issuecomment-753486815


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/133591/
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #30991: [SPARK-33959][SQL] Improve the statistics estimation of the Tail

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #30991:
URL: https://github.com/apache/spark/pull/30991#issuecomment-753467888


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/38180/
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30991: [SPARK-33959][SQL] Improve the statistics estimation of the Tail

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30991:
URL: https://github.com/apache/spark/pull/30991#issuecomment-753484418


   **[Test build #133591 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/133591/testReport)** for PR 30991 at commit [`1f476d2`](https://github.com/apache/spark/commit/1f476d244d26854b1f8f4edd5528e2c1814735a6).
    * This patch **fails SparkR unit tests**.
    * This patch merges cleanly.
    * This patch adds no public classes.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30991: [SPARK-33959][SQL] Improve the statistics estimation of the Tail

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30991:
URL: https://github.com/apache/spark/pull/30991#issuecomment-753457606


   **[Test build #133591 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/133591/testReport)** for PR 30991 at commit [`1f476d2`](https://github.com/apache/spark/commit/1f476d244d26854b1f8f4edd5528e2c1814735a6).


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA commented on pull request #30991: [SPARK-33959][SQL] Improve the statistics estimation of the Tail

Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #30991:
URL: https://github.com/apache/spark/pull/30991#issuecomment-753465244


   Kubernetes integration test status failure
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/38180/
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon closed pull request #30991: [SPARK-33959][SQL] Improve the statistics estimation of the Tail

Posted by GitBox <gi...@apache.org>.
HyukjinKwon closed pull request #30991:
URL: https://github.com/apache/spark/pull/30991


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins removed a comment on pull request #30991: [SPARK-33959][SQL] Improve the statistics estimation of the Tail

Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #30991:
URL: https://github.com/apache/spark/pull/30991#issuecomment-753486815


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/133591/
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] wangyum commented on a change in pull request #30991: [SPARK-33959][SQL] Improve the statistics estimation of the Tail

Posted by GitBox <gi...@apache.org>.
wangyum commented on a change in pull request #30991:
URL: https://github.com/apache/spark/pull/30991#discussion_r550941264



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/SizeInBytesOnlyStatsPlanVisitor.scala
##########
@@ -149,4 +149,13 @@ object SizeInBytesOnlyStatsPlanVisitor extends LogicalPlanVisitor[Statistics] {
   }
 
   override def visitWindow(p: Window): Statistics = visitUnaryNode(p)
+
+  override def visitTail(p: Tail): Statistics = {
+    val limit = p.limitExpr.eval().asInstanceOf[Int]
+    val childStats = p.child.stats
+    val rowCount: BigInt = childStats.rowCount.map(_.min(limit)).getOrElse(limit)
+    Statistics(
+      sizeInBytes = EstimationUtils.getOutputSize(p.output, rowCount, childStats.attributeStats),
+      rowCount = Some(rowCount))
+  }

Review comment:
       Same logic as `visitGlobalLimit`:
   https://github.com/apache/spark/blob/1f476d244d26854b1f8f4edd5528e2c1814735a6/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/SizeInBytesOnlyStatsPlanVisitor.scala#L82-L90




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on pull request #30991: [SPARK-33959][SQL] Improve the statistics estimation of the Tail

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #30991:
URL: https://github.com/apache/spark/pull/30991#issuecomment-753555770


   Merged to master.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] SparkQA removed a comment on pull request #30991: [SPARK-33959][SQL] Improve the statistics estimation of the Tail

Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #30991:
URL: https://github.com/apache/spark/pull/30991#issuecomment-753457606


   **[Test build #133591 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/133591/testReport)** for PR 30991 at commit [`1f476d2`](https://github.com/apache/spark/commit/1f476d244d26854b1f8f4edd5528e2c1814735a6).


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on pull request #30991: [SPARK-33959][SQL] Improve the statistics estimation of the Tail

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #30991:
URL: https://github.com/apache/spark/pull/30991#issuecomment-753555253


   cc @wzhfy FYI


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org