cloud-fan commented on a change in pull request #35768:
URL: https://github.com/apache/spark/pull/35768#discussion_r828040379



##########
File path: sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala
##########
@@ -220,12 +220,22 @@ abstract class JdbcDialect extends Serializable with 
Logging{
   }
 
   class JDBCSQLBuilder extends V2ExpressionSQLBuilder {
-    override def visitFieldReference(fieldRef: FieldReference): String = {
-      if (fieldRef.fieldNames().length != 1) {
+    override def visitLiteral(literal: Literal[_]): String = 
literal.dataType() match {
+      case StringType => s"${compileValue(literal.value().toString)}"
+      case TimestampType =>
+        
s"${compileValue(DateTimeUtils.toJavaTimestamp(literal.value().asInstanceOf[Long]))}"
+      case DateType =>
+        
s"${compileValue(DateTimeUtils.toJavaDate(literal.value().asInstanceOf[Int]))}"

Review comment:
       So the `compileValue` API takes the external value of Spark data type. 
Then there is a simpler way to do it
   ```
   compileValue(CatalystTypeConverters.convertToScala(literal.value(), 
literal.dataType()))
   ```




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to