You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2021/01/26 21:06:53 UTC

[GitHub] [iceberg] aokolnychyi commented on a change in pull request #2153: Add truncate transform support for MERGE INTO

aokolnychyi commented on a change in pull request #2153:
URL: https://github.com/apache/iceberg/pull/2153#discussion_r564832877



##########
File path: spark3-extensions/src/main/scala/org/apache/spark/sql/catalyst/expressions/TransformExpressions.scala
##########
@@ -119,3 +118,38 @@ case class IcebergBucketTransform(numBuckets: Int, child: Expression) extends Ic
 
   override def dataType: DataType = IntegerType
 }
+
+case class IcebergTruncateTransform(child: Expression, width: Int) extends IcebergTransformExpression {
+
+  override def children: Seq[Expression] = child :: Nil
+
+  @transient lazy val truncateFunc: Any => Any = child.dataType match {
+    case _: DecimalType =>
+      val t = Transforms.truncate[Any](icebergInputType, width)
+      d: Any =>  Decimal.apply(t(d.asInstanceOf[Decimal].toJavaBigDecimal).asInstanceOf[java.math.BigDecimal])

Review comment:
       nit: extra space




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org