dtenedor commented on code in PR #36960:
URL: https://github.com/apache/spark/pull/36960#discussion_r911534854


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/ResolveDefaultColumnsUtil.scala:
##########
@@ -120,6 +120,54 @@ object ResolveDefaultColumns {
     }
   }
 
+  /**
+   * Computes the string representation of an expression suitable for use when 
storing the
+   * constant-folded result of DEFAULT column values.
+   */
+  private def expressionToString(expression: Expression): String = {
+    expression match {
+      case Cast(child, dataType, _, _) =>
+        s"CAST(${expressionToString(child)} AS ${dataType.catalogString})"
+      case Literal(value, dataType: DataType) =>
+        valueToString(value, dataType)
+      case _ =>
+        expression.sql
+    }
+  }
+
+  /**
+   * Computes the string representation of a value suitable for use when 
storing the
+   * constant-folded result of DEFAULT column values.
+   */
+  private def valueToString(value: Any, dataType: DataType): String = {
+    (value, dataType) match {
+      case (data: GenericArrayData, arrayType: ArrayType) =>

Review Comment:
   Sure, this sounds good. Done. Thanks for the suggestion!



-- 
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: reviews-unsubscr...@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to