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/09/10 10:38:12 UTC

[GitHub] [spark] cfmcgrady opened a new pull request #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should correctly infer filter for udf

cfmcgrady opened a new pull request #33956:
URL: https://github.com/apache/spark/pull/33956


   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
     2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
     4. Be sure to keep the PR description updated to reflect all changes.
     5. Please write your PR title to summarize what this PR proposes.
     6. If possible, provide a concise example to reproduce the issue for a faster review.
     7. If you want to add a new configuration, please read the guideline first for naming configurations in
        'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
     8. If you want to add or modify an error type or message, please read the guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   Fix InferFiltersFromGenerate bug, before this pr, the following case will throw an exception.
   
   ```scala
   spark.udf.register("vec", (i: Int) => (0 until i).toArray)
   sql("select explode(vec(8)) as c1").show
   ```
   
   ```
   Once strategy's idempotence is broken for batch Infer Filters
    GlobalLimit 21                                                        GlobalLimit 21
    +- LocalLimit 21                                                      +- LocalLimit 21
       +- Project [cast(c1#3 as string) AS c1#12]                            +- Project [cast(c1#3 as string) AS c1#12]
          +- Generate explode(vec(8)), false, [c1#3]                            +- Generate explode(vec(8)), false, [c1#3]
             +- Filter ((size(vec(8), true) > 0) AND isnotnull(vec(8)))            +- Filter ((size(vec(8), true) > 0) AND isnotnull(vec(8)))
   !            +- OneRowRelation                                                     +- Filter ((size(vec(8), true) > 0) AND isnotnull(vec(8)))
   !                                                                                     +- OneRowRelation
          
   java.lang.RuntimeException: 
   Once strategy's idempotence is broken for batch Infer Filters
    GlobalLimit 21                                                        GlobalLimit 21
    +- LocalLimit 21                                                      +- LocalLimit 21
       +- Project [cast(c1#3 as string) AS c1#12]                            +- Project [cast(c1#3 as string) AS c1#12]
          +- Generate explode(vec(8)), false, [c1#3]                            +- Generate explode(vec(8)), false, [c1#3]
             +- Filter ((size(vec(8), true) > 0) AND isnotnull(vec(8)))            +- Filter ((size(vec(8), true) > 0) AND isnotnull(vec(8)))
   !            +- OneRowRelation                                                     +- Filter ((size(vec(8), true) > 0) AND isnotnull(vec(8)))
   !                                                                                     +- OneRowRelation
          
   	at org.apache.spark.sql.errors.QueryExecutionErrors$.onceStrategyIdempotenceIsBrokenForBatchError(QueryExecutionErrors.scala:1200)
   	at org.apache.spark.sql.catalyst.rules.RuleExecutor.checkBatchIdempotence(RuleExecutor.scala:168)
   	at org.apache.spark.sql.catalyst.rules.RuleExecutor.$anonfun$execute$1(RuleExecutor.scala:254)
   	at org.apache.spark.sql.catalyst.rules.RuleExecutor.$anonfun$execute$1$adapted(RuleExecutor.scala:200)
   	at scala.collection.immutable.List.foreach(List.scala:431)
   	at org.apache.spark.sql.catalyst.rules.RuleExecutor.execute(RuleExecutor.scala:200)
   	at org.apache.spark.sql.catalyst.rules.RuleExecutor.$anonfun$executeAndTrack$1(RuleExecutor.scala:179)
   	at org.apache.spark.sql.catalyst.QueryPlanningTracker$.withTracker(QueryPlanningTracker.scala:88)
   	at org.apache.spark.sql.catalyst.rules.RuleExecutor.executeAndTrack(RuleExecutor.scala:179)
   	at org.apache.spark.sql.execution.QueryExecution.$anonfun$optimizedPlan$1(QueryExecution.scala:138)
   	at org.apache.spark.sql.catalyst.QueryPlanningTracker.measurePhase(QueryPlanningTracker.scala:111)
   	at org.apache.spark.sql.execution.QueryExecution.$anonfun$executePhase$1(QueryExecution.scala:196)
   	at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:775)
   	at org.apache.spark.sql.execution.QueryExecution.executePhase(QueryExecution.scala:196)
   	at org.apache.spark.sql.execution.QueryExecution.optimizedPlan$lzycompute(QueryExecution.scala:134)
   	at org.apache.spark.sql.execution.QueryExecution.optimizedPlan(QueryExecution.scala:130)
   	at org.apache.spark.sql.execution.QueryExecution.assertOptimized(QueryExecution.scala:148)
   	at org.apache.spark.sql.execution.QueryExecution.$anonfun$executedPlan$1(QueryExecution.scala:166)
   	at org.apache.spark.sql.execution.QueryExecution.withCteMap(QueryExecution.scala:73)
   	at org.apache.spark.sql.execution.QueryExecution.executedPlan$lzycompute(QueryExecution.scala:163)
   	at org.apache.spark.sql.execution.QueryExecution.executedPlan(QueryExecution.scala:163)
   	at org.apache.spark.sql.execution.QueryExecution.simpleString(QueryExecution.scala:214)
   	at org.apache.spark.sql.execution.QueryExecution.org$apache$spark$sql$execution$QueryExecution$$explainString(QueryExecution.scala:259)
   	at org.apache.spark.sql.execution.QueryExecution.explainString(QueryExecution.scala:228)
   	at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$5(SQLExecution.scala:98)
   	at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:163)
   	at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$1(SQLExecution.scala:90)
   	at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:775)
   	at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:64)
   	at org.apache.spark.sql.Dataset.withAction(Dataset.scala:3731)
   	at org.apache.spark.sql.Dataset.head(Dataset.scala:2755)
   	at org.apache.spark.sql.Dataset.take(Dataset.scala:2962)
   	at org.apache.spark.sql.Dataset.getRows(Dataset.scala:288)
   	at org.apache.spark.sql.Dataset.showString(Dataset.scala:327)
   	at org.apache.spark.sql.Dataset.show(Dataset.scala:807)
   ```
   The reason is that the constraints of expression `Filter (isnotnull(UDF(8)) AND (size(UDF(8), true) > 0))` should be `[ isnotnull(UDF(8)), (size(UDF(8), true) > 0)]` instead of empty.
   
   
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   No, only bug fix.
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   
   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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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 #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should not infer filter for udf

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


   Merged to master, branch-3.2 and branch-3.1.


-- 
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: reviews-unsubscribe@spark.apache.org

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 #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should not infer filter for udf

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


   **[Test build #143202 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/143202/testReport)** for PR 33956 at commit [`d7aa7c0`](https://github.com/apache/spark/commit/d7aa7c0fd0e544389a8023ffead95a6718b02643).


-- 
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: reviews-unsubscribe@spark.apache.org

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 #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should not infer filter for udf

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


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


-- 
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: reviews-unsubscribe@spark.apache.org

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 a change in pull request #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should correctly infer filter for udf

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



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/QueryPlanConstraints.scala
##########
@@ -33,7 +33,8 @@ trait QueryPlanConstraints extends ConstraintHelper { self: LogicalPlan =>
         .union(inferAdditionalConstraints(validConstraints))
         .union(constructIsNotNullConstraints(validConstraints, output))
         .filter { c =>
-          c.references.nonEmpty && c.references.subsetOf(outputSet) && c.deterministic
+          (c.references.nonEmpty && c.references.subsetOf(outputSet) || c.references.isEmpty) &&

Review comment:
       Hm, it's a bit weird that we consider the constraints are valid even for the constraint that holds the reference not being referred. Shouldn't we handle it in `InferFiltersFromGenerate` rule itself?




-- 
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: reviews-unsubscribe@spark.apache.org

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 a change in pull request #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should correctly infer filter for udf

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



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/QueryPlanConstraints.scala
##########
@@ -33,7 +33,8 @@ trait QueryPlanConstraints extends ConstraintHelper { self: LogicalPlan =>
         .union(inferAdditionalConstraints(validConstraints))
         .union(constructIsNotNullConstraints(validConstraints, output))
         .filter { c =>
-          c.references.nonEmpty && c.references.subsetOf(outputSet) && c.deterministic
+          (c.references.nonEmpty && c.references.subsetOf(outputSet) || c.references.isEmpty) &&

Review comment:
       cc @tanelk and @maropu (from https://github.com/apache/spark/commit/17eebd72097ee65e22cdaddf375e868074251f5a)




-- 
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: reviews-unsubscribe@spark.apache.org

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 #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should not infer filter for udf

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


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


-- 
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: reviews-unsubscribe@spark.apache.org

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 #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should correctly infer filter for udf

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


   Can one of the admins verify this patch?


-- 
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: reviews-unsubscribe@spark.apache.org

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 #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should not infer filter for udf

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


   Kubernetes integration test unable to build dist.
   
   exiting with code: 1
   URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/47704/
   


-- 
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: reviews-unsubscribe@spark.apache.org

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] tanelk commented on a change in pull request #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should correctly infer filter for udf

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



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/QueryPlanConstraints.scala
##########
@@ -33,7 +33,8 @@ trait QueryPlanConstraints extends ConstraintHelper { self: LogicalPlan =>
         .union(inferAdditionalConstraints(validConstraints))
         .union(constructIsNotNullConstraints(validConstraints, output))
         .filter { c =>
-          c.references.nonEmpty && c.references.subsetOf(outputSet) && c.deterministic
+          (c.references.nonEmpty && c.references.subsetOf(outputSet) || c.references.isEmpty) &&

Review comment:
       I agree with @HyukjinKwon . In the `InferFiltersFromGenerate` we ignore expressions, where `e.children.forall(_.foldable)`. Unfortunatelly the `ScalaUDF` is never foldable (perhaps it could be). I would recomend turning this optimizer of, when the child expression is instance of `org.apache.spark.sql.catalyst.expressions.UserDefinedExpression`.




-- 
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: reviews-unsubscribe@spark.apache.org

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] cfmcgrady commented on pull request #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should correctly infer filter for udf

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


   cc @cloud-fan @HyukjinKwon @maropu 


-- 
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: reviews-unsubscribe@spark.apache.org

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 #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should not infer filter for udf

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


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


-- 
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: reviews-unsubscribe@spark.apache.org

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 #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should not infer filter for udf

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






-- 
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: reviews-unsubscribe@spark.apache.org

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 #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should not infer filter for udf

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


   Can one of the admins verify this patch?


-- 
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: reviews-unsubscribe@spark.apache.org

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] cfmcgrady commented on pull request #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should not infer filter for udf

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


   Thanks for the review.


-- 
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: reviews-unsubscribe@spark.apache.org

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 #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should not infer filter for udf

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


   **[Test build #143202 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/143202/testReport)** for PR 33956 at commit [`d7aa7c0`](https://github.com/apache/spark/commit/d7aa7c0fd0e544389a8023ffead95a6718b02643).
    * This patch passes all 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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

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] tanelk commented on pull request #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should not infer filter for udf

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


   lgtm


-- 
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: reviews-unsubscribe@spark.apache.org

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 #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should not infer filter for udf

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


   


-- 
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: reviews-unsubscribe@spark.apache.org

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 #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should not infer filter for udf

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


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


-- 
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: reviews-unsubscribe@spark.apache.org

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] tanelk commented on a change in pull request #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should correctly infer filter for udf

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



##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/QueryPlanConstraints.scala
##########
@@ -33,7 +33,8 @@ trait QueryPlanConstraints extends ConstraintHelper { self: LogicalPlan =>
         .union(inferAdditionalConstraints(validConstraints))
         .union(constructIsNotNullConstraints(validConstraints, output))
         .filter { c =>
-          c.references.nonEmpty && c.references.subsetOf(outputSet) && c.deterministic
+          (c.references.nonEmpty && c.references.subsetOf(outputSet) || c.references.isEmpty) &&

Review comment:
       I agree with @HyukjinKwon . In the `InferFiltersFromGenerate` we ignore expressions `e.children.forall(_.foldable)`. Unfortunatelly the `ScalaUDF` is never foldable (perhaps it could be). I would recomend turning this optimizer of, when the child expression is instance of `org.apache.spark.sql.catalyst.expressions.UserDefinedExpression`.




-- 
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: reviews-unsubscribe@spark.apache.org

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] cfmcgrady commented on pull request #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should not infer filter for udf

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


   Disabled infer filter when children contain a `UserDefinedExpression`, please take another look when you are free, @HyukjinKwon @tanelk  thanks.


-- 
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: reviews-unsubscribe@spark.apache.org

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 #33956: [SPARK-36715][SQL] InferFiltersFromGenerate should not infer filter for udf

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


   **[Test build #143202 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/143202/testReport)** for PR 33956 at commit [`d7aa7c0`](https://github.com/apache/spark/commit/d7aa7c0fd0e544389a8023ffead95a6718b02643).


-- 
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: reviews-unsubscribe@spark.apache.org

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