[GitHub] [spark] TJX2014 opened a new pull request #29043: [SPARK-32205][SQL] Writing timestamp to mysql should be datetime type

2020-07-11 Thread GitBox


TJX2014 opened a new pull request #29043:
URL: https://github.com/apache/spark/pull/29043


   ### What changes were proposed in this pull request?
   1. Change timestamp to mysql to datetime in 
`org.apache.spark.sql.jdbc.MySQLDialect#getJDBCType`
   2. Add UT in `org.apache.spark.sql.test.SQLTestUtils#test` .
   
   ### Why are the changes needed?
   Because write spark timestamp to mysql should has a '1000-01-01 00:00:00' to 
'-12-31 23:59:59' range.
   see https://dev.mysql.com/doc/refman/5.7/en/datetime.html
   While the date type in mysql should be datetime rather than timestamp.
   **Before this patch**, when we use timestamp data type in mysql by auto 
created table:
   `sql("select cast('-01-01 00:00:01' as 
timestamp)").toDF("ts").write.mode("append").jdbc("jdbc:mysql://localhost:3306/test",
 "ts_test3",prop)`
   we will get an exception:
   `com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime 
value: '-01-01 00:00:01' for column 'ts' at row`
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, **after this patch**, people could insert '1000-01-01 00:00:00' to 
'-12-31 23:59:59' range timestamp to mysql by table auto created.
   
   ### How was this patch tested?
   Unit test.
   



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:
us...@infra.apache.org



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



[GitHub] [spark] TJX2014 opened a new pull request #29043: [SPARK-32205][SQL] Writing timestamp to mysql should be datetime type

2020-07-08 Thread GitBox


TJX2014 opened a new pull request #29043:
URL: https://github.com/apache/spark/pull/29043


   ### What changes were proposed in this pull request?
   1. Change timestamp to mysql to datetime in 
`org.apache.spark.sql.jdbc.MySQLDialect#getJDBCType`
   2. Add UT in `org.apache.spark.sql.test.SQLTestUtils#test` .
   
   ### Why are the changes needed?
   Because write spark timestamp to mysql should has a '1000-01-01 00:00:00' to 
'-12-31 23:59:59' range.
   see https://dev.mysql.com/doc/refman/5.7/en/datetime.html
   While the date type in mysql in datetime rather than timestamp.
   When we use timestamp data type in mysql:
   `sql("select cast('-01-01 00:00:01' as 
timestamp)").toDF("ts").write.mode("append").jdbc("jdbc:mysql://localhost:3306/test",
 "ts_test3",prop)`
   we will get an exception:
   `com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime 
value: '-01-01 00:00:01' for column 'ts' at row`
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, after this patch, people could insert '1000-01-01 00:00:00' to 
'-12-31 23:59:59' range timestamp to mysql.
   
   ### How was this patch tested?
   Unit test.
   



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:
us...@infra.apache.org



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