pan3793 commented on code in PR #36995:
URL: https://github.com/apache/spark/pull/36995#discussion_r941724559


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DistributionAndOrderingUtils.scala:
##########
@@ -17,22 +17,33 @@
 
 package org.apache.spark.sql.execution.datasources.v2
 
-import org.apache.spark.sql.catalyst.expressions.Expression
+import org.apache.spark.sql.catalyst.analysis.{AnsiTypeCoercion, TypeCoercion}
+import org.apache.spark.sql.catalyst.expressions.{Expression, Literal, 
SortOrder, TransformExpression, V2ExpressionUtils}
 import org.apache.spark.sql.catalyst.expressions.V2ExpressionUtils._
 import org.apache.spark.sql.catalyst.plans.logical.{LogicalPlan, 
RebalancePartitions, RepartitionByExpression, Sort}
+import org.apache.spark.sql.catalyst.rules.Rule
+import org.apache.spark.sql.connector.catalog.FunctionCatalog
+import org.apache.spark.sql.connector.catalog.functions.ScalarFunction
 import org.apache.spark.sql.connector.distributions._
 import org.apache.spark.sql.connector.write.{RequiresDistributionAndOrdering, 
Write}
 import org.apache.spark.sql.errors.QueryCompilationErrors
 
 object DistributionAndOrderingUtils {
 
-  def prepareQuery(write: Write, query: LogicalPlan): LogicalPlan = write 
match {
+  def prepareQuery(

Review Comment:
   Given that different storage system usually defines their own hash functions 
and sharding(bucketing) rules, I don't think we can make bucket tables of all 
data sources fully compatible w/ each other, e.g. Spark, Hive, Iceberg using 
the total different hash algorithm for bucketing.
   
   We can make that DS V1 file bucket table compatible w/ V2 file bucket table, 
and Hive bucket table compatible w/ V2 Hive bucket table, but DS file bucket 
table can not be compatible w/ Hive(neither V1 nor V2) since they use the 
different hash algorithm.
   
   In detail, as `V2SessionCatalog` extends `FunctionCatalog`, to make V2 file 
bucket tables compatible w/ V1, we can introduce and register a `SparkBucket` 
V2 function using the same hash algorithm V1 in `V2SessionCatalog`. For Hive 
tables, just register a similar `HiveBucket` V2 function using the Hive hash 
algorithm in `HiveCatalog`.



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