zhongyujiang commented on code in PR #5531:
URL: https://github.com/apache/paimon/pull/5531#discussion_r2065325306
##########
paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/catalog/functions/PaimonFunctions.scala:
##########
@@ -98,6 +102,32 @@ class BucketFunction extends UnboundFunction {
override def name: String = BUCKET
}
+object BucketFunction {
+ private val SPARK_TIMESTAMP_PRECISION = 6
+
+ def supportsTable(table: FileStoreTable): Boolean = {
+ table.bucketMode match {
+ case BucketMode.HASH_FIXED =>
+
table.schema().logicalBucketKeyType().getFieldTypes.asScala.forall(supportsType)
+ case _ => false
+ }
+ }
+
+ private def supportsType(t: PaimonDataType): Boolean = t match {
+ case arrayType: ArrayType =>
+ supportsType(arrayType.getElementType)
+ case mapType: MapType =>
+ supportsType(mapType.getKeyType) && supportsType(mapType.getValueType)
+ case rowType: RowType =>
+ rowType.getFieldTypes.asScala.forall(supportsType)
+ case timestamp: TimestampType =>
Review Comment:
I did some investigation and found that the calculation for the previous V1
write is correct, because when converting a Spark Row to a Paimon InternalRow
for computation, it always uses the correct schema from the real paimon table:
https://github.com/apache/paimon/blob/cf22950c1670b2167994c6d50193b09745a0ddc3/paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/commands/BucketProcessor.scala#L71-L87
However, the handling of timestamps in `FixedBucketExpression` is incorrect,
as it directly uses Spark's `inputType`.
https://github.com/apache/paimon/blob/b44824452e0dc23250bea3fbbeb532698a90bda4/paimon-spark/paimon-spark-common/src/main/scala/org/apache/paimon/spark/commands/BucketExpression.scala#L49-L55
So, I think `FixedBucketExpression` should validate the timestamp type in
the same way as V2 write does, I added a test to validate this
https://github.com/apache/paimon/pull/5531/commits/b531b640f128d0925a71740f4a52b974fee2755d
cc @Aitozi
--
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]