[ 
https://issues.apache.org/jira/browse/SPARK-44627?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Min Zhao updated SPARK-44627:
-----------------------------
    Description: 
When the resultSet exists a timestmp column and it's value is null, but column 
define is not null. In the row it generates, this column will use the value of 
the same column in the previous row.  

 

In mysql, if a datetime column is defined, meanwhile it is not null. When a 
value is '0000-00-00 00:00:00', mysql provided a property of 
zeroDateTimeBehavior, it will return null.  

table define:
CREATE TABLE `test_timestamp` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
`unbind_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' ,
PRIMARY KEY (`id`)
)
example:

the value of resultSet

1, 2023-01-01 12:00:00

2, null

 

the value of row

1, 2023-01-01 12:00:00

2, 2023-01-01 12:00:00

 

  was:
When the resultSet exists a timestmp column and it's value is null, In the row 
it generates, this column will use the value of the same column in the previous 
row.  

 

In mysql, if a datetime column is defined, meanwhile it is not null. When a 
value is '0000-00-00 00:00:00', mysql provided a property of 
zeroDateTimeBehavior, it will return null.  

table define:
CREATE TABLE `test_timestamp` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
`unbind_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' ,
PRIMARY KEY (`id`)
)
example:

the value of resultSet

1, 2023-01-01 12:00:00

2, null

 

the value of row

1, 2023-01-01 12:00:00

2, 2023-01-01 12:00:00

 


> org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils#resultSetToRows 
> produces wrong data
> ---------------------------------------------------------------------------------------------
>
>                 Key: SPARK-44627
>                 URL: https://issues.apache.org/jira/browse/SPARK-44627
>             Project: Spark
>          Issue Type: Bug
>          Components: Spark Core
>    Affects Versions: 2.3.2, 3.3.1
>            Reporter: Min Zhao
>            Priority: Minor
>         Attachments: image-2023-08-02-14-01-54-447.png
>
>
> When the resultSet exists a timestmp column and it's value is null, but 
> column define is not null. In the row it generates, this column will use the 
> value of the same column in the previous row.  
>  
> In mysql, if a datetime column is defined, meanwhile it is not null. When a 
> value is '0000-00-00 00:00:00', mysql provided a property of 
> zeroDateTimeBehavior, it will return null.  
> table define:
> CREATE TABLE `test_timestamp` (
> `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
> `unbind_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' ,
> PRIMARY KEY (`id`)
> )
> example:
> the value of resultSet
> 1, 2023-01-01 12:00:00
> 2, null
>  
> the value of row
> 1, 2023-01-01 12:00:00
> 2, 2023-01-01 12:00:00
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to