Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,12 @@ class MsSqlServerIntegrationSuite extends DockerJDBCIntegrationSuite {
.load()
assert(df.collect().toSet === expectedResult)
}

test("SPARK-47938: Fix 'Cannot find data type BYTE' in SQL Server") {
spark.sql("select cast(1 as byte) as c0")
.write
.jdbc(jdbcUrl, "test_byte", new Properties)
val df = spark.read.jdbc(jdbcUrl, "test_byte", new Properties)
checkAnswer(df, Row(1.toShort))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ private case class MsSqlServerDialect() extends JdbcDialect {
case BinaryType => Some(JdbcType("VARBINARY(MAX)", java.sql.Types.VARBINARY))
case ShortType if !SQLConf.get.legacyMsSqlServerNumericMappingEnabled =>
Some(JdbcType("SMALLINT", java.sql.Types.SMALLINT))
case ByteType => Some(JdbcType("SMALLINT", java.sql.Types.TINYINT))
case _ => None
}

Expand Down