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/08/12 11:46:25 UTC

[GitHub] [spark] beliefer opened a new pull request, #37494: [SPARK-40013][SQL] S V2 expressions should have the default toString

beliefer opened a new pull request, #37494:
URL: https://github.com/apache/spark/pull/37494

   ### What changes were proposed in this pull request?
   Currently, V2 expressions missing the default `toString` and lead to unexpected result or duplicate code.
   This PR creates a new abstract class `AbstractExpression` so as we can add default `toString` using ToStringSQLBuilder.
   
   
   ### Why are the changes needed?
   The default `toString` could reuse `ToStringSQLBuilder` so that avoid duplicate code.
   The default `toString` also let developers no need implement `toString`, when creating a new V2 expression.
   
   
   ### Does this PR introduce _any_ user-facing change?
   'No'.
   Just update the inner implementation.
   
   
   ### How was this patch tested?
   N/A
   


-- 
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] beliefer commented on pull request #37494: [SPARK-40013][SQL] DS V2 expressions should have the default `toString`

Posted by GitBox <gi...@apache.org>.
beliefer commented on PR #37494:
URL: https://github.com/apache/spark/pull/37494#issuecomment-1216430046

   @cloud-fan @LuciferYang @huaxingao Thank you !


-- 
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 closed pull request #37494: [SPARK-40013][SQL] DS V2 expressions should have the default `toString`

Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #37494: [SPARK-40013][SQL] DS V2 expressions should have the default `toString`
URL: https://github.com/apache/spark/pull/37494


-- 
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 diff in pull request #37494: [SPARK-40013][SQL] DS V2 expressions should have the default `toString`

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #37494:
URL: https://github.com/apache/spark/pull/37494#discussion_r946291532


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/connector/expressions/expressions.scala:
##########
@@ -389,3 +390,8 @@ private[sql] object SortValue {
       None
   }
 }
+
+private[sql] abstract class AbstractExpression extends Expression with Serializable {

Review Comment:
   For the name, how about `ExpressionWithToString`?



-- 
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] beliefer commented on a diff in pull request #37494: [SPARK-40013][SQL] DS V2 expressions should have the default `toString`

Posted by GitBox <gi...@apache.org>.
beliefer commented on code in PR #37494:
URL: https://github.com/apache/spark/pull/37494#discussion_r946278379


##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/expressions/AbstractExpression.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * 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 org.apache.spark.sql.connector.expressions;
+
+import java.io.Serializable;
+
+import org.apache.spark.sql.internal.connector.ToStringSQLBuilder;
+
+public abstract class AbstractExpression implements Expression, Serializable {

Review Comment:
   OK



-- 
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 diff in pull request #37494: [SPARK-40013][SQL] DS V2 expressions should have the default `toString`

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #37494:
URL: https://github.com/apache/spark/pull/37494#discussion_r945699153


##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/expressions/AbstractExpression.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * 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 org.apache.spark.sql.connector.expressions;
+
+import java.io.Serializable;
+
+import org.apache.spark.sql.internal.connector.ToStringSQLBuilder;
+
+public abstract class AbstractExpression implements Expression, Serializable {

Review Comment:
   I think this can be package private? we don't expect end users to access it.



-- 
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 diff in pull request #37494: [SPARK-40013][SQL] DS V2 expressions should have the default `toString`

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #37494:
URL: https://github.com/apache/spark/pull/37494#discussion_r946291319


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/connector/expressions/expressions.scala:
##########
@@ -389,3 +390,8 @@ private[sql] object SortValue {
       None
   }
 }
+
+private[sql] abstract class AbstractExpression extends Expression with Serializable {

Review Comment:
   I mean java package private... basically just define the class without `public`. We can simply put this class in `Expression.java`



-- 
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] beliefer commented on a diff in pull request #37494: [SPARK-40013][SQL] DS V2 expressions should have the default `toString`

Posted by GitBox <gi...@apache.org>.
beliefer commented on code in PR #37494:
URL: https://github.com/apache/spark/pull/37494#discussion_r946291931


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/connector/expressions/expressions.scala:
##########
@@ -389,3 +390,8 @@ private[sql] object SortValue {
       None
   }
 }
+
+private[sql] abstract class AbstractExpression extends Expression with Serializable {

Review Comment:
   I got it.



-- 
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] LuciferYang commented on a diff in pull request #37494: [SPARK-40013][SQL] DS V2 expressions should have the default `toString`

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on code in PR #37494:
URL: https://github.com/apache/spark/pull/37494#discussion_r945297095


##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/expressions/AbstractExpression.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * 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 org.apache.spark.sql.connector.expressions;
+
+import java.io.Serializable;
+
+import org.apache.spark.sql.internal.connector.ToStringSQLBuilder;
+
+public abstract class AbstractExpression implements Expression, Serializable {
+  @Override
+  public String toString() {
+    ToStringSQLBuilder builder = new ToStringSQLBuilder();

Review Comment:
   Discuss: Is the `build` method thread safe? If yes, do we need to create a new `ToStringSQLBuilder` object every time?



-- 
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] beliefer commented on a diff in pull request #37494: [SPARK-40013][SQL] DS V2 expressions should have the default `toString`

Posted by GitBox <gi...@apache.org>.
beliefer commented on code in PR #37494:
URL: https://github.com/apache/spark/pull/37494#discussion_r945382068


##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/expressions/AbstractExpression.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * 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 org.apache.spark.sql.connector.expressions;
+
+import java.io.Serializable;
+
+import org.apache.spark.sql.internal.connector.ToStringSQLBuilder;
+
+public abstract class AbstractExpression implements Expression, Serializable {
+  @Override
+  public String toString() {
+    ToStringSQLBuilder builder = new ToStringSQLBuilder();

Review Comment:
   Thank you for you reminder. `ToStringSQLBuilder` is stateless.



-- 
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 pull request #37494: [SPARK-40013][SQL] DS V2 expressions should have the default `toString`

Posted by GitBox <gi...@apache.org>.
cloud-fan commented on PR #37494:
URL: https://github.com/apache/spark/pull/37494#issuecomment-1216299437

   thanks, merging 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.

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] beliefer commented on pull request #37494: [SPARK-40013][SQL] DS V2 expressions should have the default `toString`

Posted by GitBox <gi...@apache.org>.
beliefer commented on PR #37494:
URL: https://github.com/apache/spark/pull/37494#issuecomment-1214130934

   The GA failure is unrelated.
   ping @huaxingao cc @cloud-fan cc @chenzhx 


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