sunchao commented on a change in pull request #35657:
URL: https://github.com/apache/spark/pull/35657#discussion_r828417187



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/transformExpressions.scala
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.catalyst.expressions
+
+import org.apache.spark.sql.connector.catalog.functions.BoundFunction
+import org.apache.spark.sql.types.DataType
+
+abstract class TransformExpression extends Expression with Unevaluable {
+  override def nullable: Boolean = true
+
+  /**
+   * Whether this [[TransformExpression]] has the same semantics as `other`.
+   * For instance, `bucket(32, c)` is equal to `bucket(32, d)`, but not to 
`bucket(16, d)` or
+   * `year(c)`.
+   *
+   * This will be used, for instance, by Spark to determine whether 
storage-partitioned join can
+   * be triggered, by comparing partition transforms from both sides of the 
join and checking
+   * whether they are compatible.
+   *
+   * @param other the transform expression to compare to
+   * @return true if this and `other` has the same semantics w.r.t to 
transform, false otherwise.
+   */
+  def equalsTo(other: TransformExpression): Boolean
+}
+
+/**
+ * A transform expression defined by a V2 data source.
+ */
+case class DataSourceTransformExpression(
+    function: BoundFunction,
+    children: Seq[Expression]) extends TransformExpression {
+
+  override def equalsTo(other: TransformExpression): Boolean = other match {
+    case DataSourceTransformExpression(otherFunction, _) =>
+      function.canonicalName() == otherFunction.canonicalName()

Review comment:
       I think we only check whether the two V2 functions are semantically 
equal here? i.e., given the same input, whether they map to the same output. 
The comparison on children is done in `ShuffleSpec.isCompatibleWith`.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to