You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by va...@apache.org on 2016/12/12 20:55:56 UTC

spark git commit: [SPARK-16297][SQL] Fix mapping Microsoft SQLServer dialect

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 <te...@yoox.com>
Authored: Mon Dec 12 12:54:33 2016 -0800
Committer: Marcelo Vanzin <va...@cloudera.com>
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: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org