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 Table,
   reference: 
https://github.com/apache/paimon/commit/d4beafac7c56770f473c0ab13f1550fc9adb0bbd#diff-91b558b15f88e797ba63a1d4966754b30873f1d07872bf28a657aa1998fa4d23R65
   
   However, the handling of timestamps in `FixedBucketExpression` is incorrect, 
as it directly uses Spark's `inputType`.
   
https://github.com/apache/paimon/commit/b44824452e0dc23250bea3fbbeb532698a90bda4#diff-a275abe02ed75c7f27b8699d538611593169632e989df12c13e459282b89eb48L40
   
    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]

Reply via email to