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 2022/01/18 21:57:42 UTC
[GitHub] [spark] sunchao opened a new pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
sunchao opened a new pull request #35243:
URL: https://github.com/apache/spark/pull/35243
<!--
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.
-->
Pass `isDeterministic` flag to `ApplyFunctionExpression`, `Invoke` and `StaticInvoke` when processing V2 scalar functions.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
A V2 scalar function can be declared as non-deterministic. However, currently Spark doesn't pass the flag when converting the V2 function to a catalyst expression, which could lead to incorrect results if being applied with certain optimizations.
### 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.
### 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.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
Added a 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 a change in pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #35243:
URL: https://github.com/apache/spark/pull/35243#discussion_r798278536
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -248,7 +250,8 @@ case class StaticInvoke(
arguments: Seq[Expression] = Nil,
inputTypes: Seq[AbstractDataType] = Nil,
propagateNull: Boolean = true,
- returnNullable: Boolean = true) extends InvokeLike {
+ returnNullable: Boolean = true,
+ isDeterministic: Boolean = true) extends InvokeLike {
Review comment:
That's fine. I didn't have a strong preference so I am okay with keeping it either 👍 .
--
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] huaxingao commented on a change in pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
huaxingao commented on a change in pull request #35243:
URL: https://github.com/apache/spark/pull/35243#discussion_r787250381
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -248,7 +250,8 @@ case class StaticInvoke(
arguments: Seq[Expression] = Nil,
inputTypes: Seq[AbstractDataType] = Nil,
propagateNull: Boolean = true,
- returnNullable: Boolean = true) extends InvokeLike {
+ returnNullable: Boolean = true,
+ isDeterministic: Boolean = true) extends InvokeLike {
Review comment:
why this defaults to true?
--
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] sunchao commented on a change in pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
sunchao commented on a change in pull request #35243:
URL: https://github.com/apache/spark/pull/35243#discussion_r798249107
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -248,7 +250,8 @@ case class StaticInvoke(
arguments: Seq[Expression] = Nil,
inputTypes: Seq[AbstractDataType] = Nil,
propagateNull: Boolean = true,
- returnNullable: Boolean = true) extends InvokeLike {
+ returnNullable: Boolean = true,
+ isDeterministic: Boolean = true) extends InvokeLike {
Review comment:
I think this is a bug fix. A V2 catalog can return a function that's non-deterministic, while without the fix Spark can treat it as deterministic and apply related optimization rules (e.g., constant folding), which could cause correctness issues.
Since this is already in Spark 3.2.1, I don't see much benefit of reverting it and re-introduce the correctness issue.
--
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 #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #35243:
URL: https://github.com/apache/spark/pull/35243#discussion_r798182172
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -248,7 +250,8 @@ case class StaticInvoke(
arguments: Seq[Expression] = Nil,
inputTypes: Seq[AbstractDataType] = Nil,
propagateNull: Boolean = true,
- returnNullable: Boolean = true) extends InvokeLike {
+ returnNullable: Boolean = true,
+ isDeterministic: Boolean = true) extends InvokeLike {
Review comment:
I think this might be controversial to backport .. as
1. V2 expressions are unstable yet.
2. It could lead to different results in maintenance version upgrade if a user sets `isDeterministic` to `false`
3. Maybe performance regression if a user sets `isDeterministic` to `false`.
4. We haven't heard an actual complaint from user mailing list.
5. This makes an API (`isDeterministic`) working that has never been working in a way (is this a bug fix?)
While I agree with this being merged in 3.3.0, and I don't feel strongly on this in 3.2.X, maybe we can consider reverting this out of `branch-3.2` because it has a good and bad thing. If we're worried about this change, we could issue a warning instead when `isDeterministic` from V2 Scalar Function returns `false`.
I will leave it to you @sunchao.
--
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] cloud-fan commented on a change in pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #35243:
URL: https://github.com/apache/spark/pull/35243#discussion_r787378977
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -259,6 +262,7 @@ case class StaticInvoke(
override def nullable: Boolean = needNullCheck || returnNullable
override def children: Seq[Expression] = arguments
+ override lazy val deterministic: Boolean = isDeterministic
Review comment:
we should also check if all the arguments are deterministic.
--
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 #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #35243:
URL: https://github.com/apache/spark/pull/35243#discussion_r798182172
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -248,7 +250,8 @@ case class StaticInvoke(
arguments: Seq[Expression] = Nil,
inputTypes: Seq[AbstractDataType] = Nil,
propagateNull: Boolean = true,
- returnNullable: Boolean = true) extends InvokeLike {
+ returnNullable: Boolean = true,
+ isDeterministic: Boolean = true) extends InvokeLike {
Review comment:
I think this might be controversial to backport .. as
1. V2 expressions are unstable yet.
2. It could lead to different results in maintenance version upgrade if a user sets `isDeterministic` to `false`
3. Maybe performance regression if a user sets `isDeterministic` to `false`.
4. We haven't heard an actual complaint from user mailing list.
5. This makes an API (`isDeterministic`) working that has never been working in a way (is this a bug fix?)
While I agree with this being merged in 3.3.0, and I don't feel strongly on this, maybe we can consider reverting this out of `branch-3.2` because it has a good and bad thing. If we're worried about this change, we could issue a warning instead when `isDeterministic` from V2 Scalar Function returns `false`.
I will leave it to you @sunchao.
--
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] dongjoon-hyun commented on pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on pull request #35243:
URL: https://github.com/apache/spark/pull/35243#issuecomment-1016979317
Thank you all!
--
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] sunchao closed pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
sunchao closed pull request #35243:
URL: https://github.com/apache/spark/pull/35243
--
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] sunchao commented on a change in pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
sunchao commented on a change in pull request #35243:
URL: https://github.com/apache/spark/pull/35243#discussion_r787978011
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -259,6 +262,7 @@ case class StaticInvoke(
override def nullable: Boolean = needNullCheck || returnNullable
override def children: Seq[Expression] = arguments
+ override lazy val deterministic: Boolean = isDeterministic
Review comment:
Oops you are right. Let me fix it.
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2FunctionSuite.scala
##########
@@ -428,6 +430,22 @@ class DataSourceV2FunctionSuite extends DatasourceV2SQLBase {
}
}
+ test("SPARK-37957: pass deterministic flag") {
Review comment:
Sure
--
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] huaxingao commented on a change in pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
huaxingao commented on a change in pull request #35243:
URL: https://github.com/apache/spark/pull/35243#discussion_r798277097
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -248,7 +250,8 @@ case class StaticInvoke(
arguments: Seq[Expression] = Nil,
inputTypes: Seq[AbstractDataType] = Nil,
propagateNull: Boolean = true,
- returnNullable: Boolean = true) extends InvokeLike {
+ returnNullable: Boolean = true,
+ isDeterministic: Boolean = true) extends InvokeLike {
Review comment:
+1 on keeping this in 3.2.x. This fixed the correctness issue and we actually intentionally included this fix in 3.2.1 release.
--
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] sunchao commented on a change in pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
sunchao commented on a change in pull request #35243:
URL: https://github.com/apache/spark/pull/35243#discussion_r787256785
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -248,7 +250,8 @@ case class StaticInvoke(
arguments: Seq[Expression] = Nil,
inputTypes: Seq[AbstractDataType] = Nil,
propagateNull: Boolean = true,
- returnNullable: Boolean = true) extends InvokeLike {
+ returnNullable: Boolean = true,
+ isDeterministic: Boolean = true) extends InvokeLike {
Review comment:
I think in majority cases a function is deterministic, so defaulting to true here. This is similar to how we treat `propagateNull` and `returnNullable` here.
--
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] sunchao commented on pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
sunchao commented on pull request #35243:
URL: https://github.com/apache/spark/pull/35243#issuecomment-1016918767
Thanks! merged to master and branch-3.2.
--
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] sunchao commented on a change in pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
sunchao commented on a change in pull request #35243:
URL: https://github.com/apache/spark/pull/35243#discussion_r788040266
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -259,6 +262,7 @@ case class StaticInvoke(
override def nullable: Boolean = needNullCheck || returnNullable
override def children: Seq[Expression] = arguments
+ override lazy val deterministic: Boolean = isDeterministic && arguments.forall(_.deterministic)
Review comment:
I thought about this too, but then we'd have to move `isDeterministic` there too and then override it in `StaticInvoke` and `Invoke`, so doesn't seem we can save much. Plus I think deterministic property is not useful for `NewInstance`.
--
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] huaxingao commented on a change in pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
huaxingao commented on a change in pull request #35243:
URL: https://github.com/apache/spark/pull/35243#discussion_r787251170
##########
File path: sql/core/src/test/java/test/org/apache/spark/sql/connector/catalog/functions/JavaRandomAdd.java
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package test.org.apache.spark.sql.connector.catalog.functions;
+
+import java.util.Random;
+
+import org.apache.spark.sql.catalyst.InternalRow;
+import org.apache.spark.sql.connector.catalog.functions.BoundFunction;
+import org.apache.spark.sql.connector.catalog.functions.ScalarFunction;
+import org.apache.spark.sql.connector.catalog.functions.UnboundFunction;
+import org.apache.spark.sql.types.DataType;
+import org.apache.spark.sql.types.DataTypes;
+import org.apache.spark.sql.types.IntegerType;
+import org.apache.spark.sql.types.StructType;
+
+/**
+ * Test V2 function which add a random number to the input integer.
+ */
+public class JavaRandomAdd implements UnboundFunction {
+ private final BoundFunction fn;
+
+ public JavaRandomAdd(BoundFunction fn) {
+ this.fn = fn;
+ }
+
+ @Override
+ public String name() {
+ return "rand";
+ }
+
+ @Override
+ public BoundFunction bind(StructType inputType) {
+ if (inputType.fields().length != 1) {
+ throw new UnsupportedOperationException("Expect exactly one argument");
+ }
+ if (inputType.fields()[0].dataType() instanceof IntegerType) {
+ return fn;
+ }
+ throw new UnsupportedOperationException("Expect IntegerType");
+ }
+
+ @Override
+ public String description() {
+ return "rand_add: add a random integer to the input\n" +
+ "rand_add(int) -> int";
+ }
+
+ public static abstract class JavaRandomAddBase implements ScalarFunction<Integer> {
+ @Override
+ public DataType[] inputTypes() {
+ return new DataType[] { DataTypes.IntegerType };
+ }
+
+ @Override
+ public DataType resultType() {
+ return DataTypes.IntegerType;
+ }
+
+ @Override
+ public String name() {
+ return "rand_add";
+ }
+
+ @Override
+ public boolean isDeterministic() {
+ return false;
+ }
+ }
+
+ public static class JavaRandomAddDefault extends JavaRandomAddBase {
+ private final Random rand = new Random();
+
+ @Override
+ public Integer produceResult(InternalRow input) {
+ return input.getInt(0) + rand.nextInt();
+ }
+ }
+
+ public static class JavaRandomAddMagic extends JavaRandomAddBase {
+ private final Random rand = new Random();
+
+ public int invoke(int input) {
+ return input + rand.nextInt();
+ }
+ }
+
+ public static class JavaRandomAddStaticMagic extends JavaRandomAddBase {
+ private static final Random rand = new Random();
+
+ public static int invoke(int input) {
+ return input + rand.nextInt();
+ }
+ }
+}
+
+
Review comment:
super nit: extra blank line
--
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] AngersZhuuuu commented on a change in pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on a change in pull request #35243:
URL: https://github.com/apache/spark/pull/35243#discussion_r787298787
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -248,7 +250,8 @@ case class StaticInvoke(
arguments: Seq[Expression] = Nil,
inputTypes: Seq[AbstractDataType] = Nil,
propagateNull: Boolean = true,
- returnNullable: Boolean = true) extends InvokeLike {
+ returnNullable: Boolean = true,
+ isDeterministic: Boolean = true) extends InvokeLike {
Review comment:
+1 for default true.
--
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] AngersZhuuuu commented on a change in pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
AngersZhuuuu commented on a change in pull request #35243:
URL: https://github.com/apache/spark/pull/35243#discussion_r787299349
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2FunctionSuite.scala
##########
@@ -428,6 +430,22 @@ class DataSourceV2FunctionSuite extends DatasourceV2SQLBase {
}
}
+ test("SPARK-37957: pass deterministic flag") {
Review comment:
Can we make the test name more clear? `pass deterministic flat to what`
--
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] cloud-fan commented on a change in pull request #35243: [SPARK-37957][SQL] Correctly pass deterministic flag for V2 scalar functions
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #35243:
URL: https://github.com/apache/spark/pull/35243#discussion_r788007794
##########
File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
##########
@@ -259,6 +262,7 @@ case class StaticInvoke(
override def nullable: Boolean = needNullCheck || returnNullable
override def children: Seq[Expression] = arguments
+ override lazy val deterministic: Boolean = isDeterministic && arguments.forall(_.deterministic)
Review comment:
nit: seems we can move this to `InvokeLike`
--
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