Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-33743]change TimestampType match to datetime2 instead of datetime for MsSQLServerDialect #32655

Closed
wants to merge 2 commits into from

Conversation

luxu1-ms
Copy link

@luxu1-ms luxu1-ms commented May 24, 2021

SPARK-33743 is to change datetime datatype mapping in JDBC mssqldialect.

What changes were proposed in this pull request?

override def getJDBCType(dt: DataType): Option[JdbcType] = dt match {
case TimestampType => Some(JdbcType("DATETIME2", java.sql.Types.TIMESTAMP))

Why are the changes needed?

Spark datetime type is timestamp type. This supports a microsecond resolution.
Sql supports 2 date time types:

datetime can support only milli seconds resolution (0 to 999).
datetime2 is extension of datetime , is compatible with datetime and supports 0 to 9999999 sub second resolution.
datetime2 (Transact-SQL) - SQL Server | Microsoft Docs
datetime (Transact-SQL) - SQL Server | Microsoft Docs

Currently MsSQLServerDialect maps timestamp type to datetime. Datetime only allows 3 digits of microseconds. This implies results in errors when writing timestamp with more than 3 digits of microseconds to sql server table. We want to map timestamp to datetime2, which is compatible with datetime but allows 7 digits of microseconds.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Unit tests were updated and passed in JDBCSuit.scala.
E2E test done with SQL Server.

@github-actions github-actions bot added the SQL label May 24, 2021
@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@dongjoon-hyun dongjoon-hyun marked this pull request as draft May 25, 2021 07:07
@luxu1-ms luxu1-ms changed the title [WIP][SPARK-33743]change TimestampType match to datetime2 instead of datetime for MsSQLServerDialect [SPARK-33743]change TimestampType match to datetime2 instead of datetime for MsSQLServerDialect Jun 16, 2021
@luxu1-ms luxu1-ms marked this pull request as ready for review June 17, 2021 07:05
@darrenpricedcww
Copy link

Hi Team,

Any ETA on getting this one complete?

Thanks,
Darren

@philipp-t
Copy link

we also have a lot of conflicts with Datetime2 in MSSQL, is their a plan if this fix is released soon??

hmayer1980 pushed a commit to hmayer1980/sql-spark-connector that referenced this pull request Oct 28, 2021
… pull request apache/spark#32655 is incorporated into your spark enviornment.
@JochenMSFT
Copy link

when could we close / merge the PR?

@github-actions
Copy link

We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants