aokolnychyi commented on code in PR #36995:
URL: https://github.com/apache/spark/pull/36995#discussion_r951950341
##########
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:
> Consider we build bucketed table support for DSv2 file source on top on
this mechanism, does it mean for a particular row, it could be hashed to a
different bucket ID than V1? What if someone wants to first write a bucketed
table using V2 and then read back in V1, and perhaps do bucket join with
another V1 bucketed table?
@sunchao, coming back to the use case you mentioned above. I think the
bucket ID will be always the same as long as the task writer respects the table
bucket spec and Spark shuffles all records that are supposed to land in one
bucket to one task. Like @pan3793 said, I suppose V2 file source will request a
distribution using a V2 function that would wrap the internal Spark hash
function. That should guarantee that all records for the same bucket will land
in one task. As long as the task writer uses the correct bucket expression
(based on the table definition), we should be good, right?
You are right the partition/task ID during writes for a particular row may
be different in V1 and V2 because of double hashing. But does it actually
matter, though?
--
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]