wenlong88 commented on a change in pull request #18127:
URL: https://github.com/apache/flink/pull/18127#discussion_r770301442



##########
File path: 
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/utils/FlinkRexUtil.scala
##########
@@ -473,22 +489,54 @@ object FlinkRexUtil {
         inFields(i.getIndex)
 
       case l: RexLiteral =>
-        l.toString
+        expressionDetail match {
+          case ExpressionDetail.Digest =>
+            // the digest for the literal
+            l.toString
+          case ExpressionDetail.Explain =>
+            val value = l.getValue
+            if (value == null) {
+              // return null with type
+              "null:" + l.getType
+            } else {
+              l.getTypeName match {
+                case SqlTypeName.DOUBLE => 
Util.toScientificNotation(value.asInstanceOf[BigDecimal])
+                case SqlTypeName.BIGINT => 
s"${value.asInstanceOf[BigDecimal].longValue()}L"
+                case SqlTypeName.BINARY => 
s"X'${value.asInstanceOf[ByteString].toString(16)}'"
+                case SqlTypeName.VARCHAR | SqlTypeName.CHAR =>
+                  s"'${value.asInstanceOf[NlsString].getValue}'"
+                case SqlTypeName.TIME | SqlTypeName.TIME_WITH_LOCAL_TIME_ZONE 
=>
+                  l.getValueAs(classOf[TimeString]).toString
+                case SqlTypeName.DATE =>
+                  l.getValueAs(classOf[DateString]).toString
+                case SqlTypeName.TIMESTAMP | 
SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE =>
+                  l.getValueAs(classOf[TimestampString]).toString
+                case typ if SqlTypeName.INTERVAL_TYPES.contains(typ) => 
l.toString

Review comment:
       interval type value is numeric without type, so we need to use .toString 




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