senthh commented on a change in pull request #34272:
URL: https://github.com/apache/spark/pull/34272#discussion_r728588988



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/jdbc/JdbcUtils.scala
##########
@@ -301,7 +301,7 @@ object JdbcUtils extends Logging with SQLConfHelper {
             rsmd.getClass.getName == 
"org.apache.hive.jdbc.HiveResultSetMetaData" => true
         }
       }
-      val nullable = if (alwaysNullable) {
+      val nullable = if (alwaysNullable || 
typeName.toString().equals("TIMESTAMP")) {

Review comment:
       @HyukjinKwon Thanks for reviwing this PR.
   
   Based on issue reported in jira 
https://issues.apache.org/jira/browse/SPARK-19726, Spark inserts '0' values, if 
we try to insert null value to TIMESTAMP column(non-nullable) and hence it 
leads SQL to insert values "1970-01-01 08:00:00". Because SQL treats 0 as 
'1970-01-01 08:00:00' for TIMESTAMP column fields.
   
   So in order to avoid inserting wrong value into TIMESTAMP colums, we should 
set NULLABLE as true by default only for TIMESTAMP column.




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