Repository: spark Updated Branches: refs/heads/master 586d19822 -> bf42c2db5
[SPARK-16297][SQL] Fix mapping Microsoft SQLServer dialect The problem is if it is run with no fix throws an exception and causes the following error: "Cannot specify a column width on data type bit." The problem stems from the fact that the "java.sql.types.BIT" type is mapped as BIT[n] that really must be mapped as BIT. This concerns the type Boolean. As for the type String with maximum length of characters it must be mapped as VARCHAR (MAX) instead of TEXT which is a type deprecated in SQLServer. Here is the list of mappings for SQL Server: https://msdn.microsoft.com/en-us/library/ms378878(v=sql.110).aspx Closes #13944 from meknio/master. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/bf42c2db Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/bf42c2db Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/bf42c2db Branch: refs/heads/master Commit: bf42c2db57b9a2ca642ad3d499c30be8d9ff221a Parents: 586d198 Author: meknio <[email protected]> Authored: Mon Dec 12 12:54:33 2016 -0800 Committer: Marcelo Vanzin <[email protected]> Committed: Mon Dec 12 12:54:39 2016 -0800 ---------------------------------------------------------------------- .../main/scala/org/apache/spark/sql/jdbc/MsSqlServerDialect.scala | 2 ++ 1 file changed, 2 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/bf42c2db/sql/core/src/main/scala/org/apache/spark/sql/jdbc/MsSqlServerDialect.scala ---------------------------------------------------------------------- diff --git a/sql/core/src/main/scala/org/apache/spark/sql/jdbc/MsSqlServerDialect.scala b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/MsSqlServerDialect.scala index 70122f2..da787b4 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/jdbc/MsSqlServerDialect.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/jdbc/MsSqlServerDialect.scala @@ -36,6 +36,8 @@ private object MsSqlServerDialect extends JdbcDialect { override def getJDBCType(dt: DataType): Option[JdbcType] = dt match { case TimestampType => Some(JdbcType("DATETIME", java.sql.Types.TIMESTAMP)) + case StringType => Some(JdbcType("NVARCHAR(MAX)", java.sql.Types.NVARCHAR)) + case BooleanType => Some(JdbcType("BIT", java.sql.Types.BIT)) case _ => None } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
