shivsood opened a new pull request #25238: [WIP][SPARK-28152][SQL] Mapped 
ShortType to SMALLINT and FloatType to REAL for MsSqlServerDialect
URL: https://github.com/apache/spark/pull/25238
 
 
   ## What changes were proposed in this pull request?
   This is a backport of SPARK-28152 to Spark 2.4. Because the fix in 3.0 was 
based on different base files, following relevant fixes have also been 
cherry-picked as part of this fix. 
   - [SPARK-27159][SQL] update mssql server dialect to support binary type 
   - SPARK-27168 [SQL][TEST] Add docker integration test for MsSql server
   
   SPARK-28152  corrects mappings in `MsSqlServerDialect`. Post fix `ShortType` 
is mapped to `SMALLINT` and `FloatType` is mapped to `REAL` per [JBDC mapping]( 
https://docs.microsoft.com/en-us/sql/connect/jdbc/using-basic-data-types?view=sql-server-2017)
 respectively.
   
   ShortType and FloatTypes are not correctly mapped to right JDBC types when 
using JDBC connector. This results in tables and spark data frame being created 
with unintended types. The issue was observed when validating against SQLServer.
   
   Refer [JBDC mapping]( 
https://docs.microsoft.com/en-us/sql/connect/jdbc/using-basic-data-types?view=sql-server-2017
  ) for guidance on mappings between SQLServer, JDBC and Java. Note that java 
"Short" type should be mapped to JDBC "SMALLINT" and java Float should be 
mapped to JDBC "REAL".
   
   Some example issue that can happen because of wrong mappings
       - Write from df with column type results in a SQL table of with column 
type as INTEGER as opposed to SMALLINT.Thus a larger table that expected.
       - Read results in a dataframe with type INTEGER as opposed to ShortType
   
   - ShortType has a problem in both the the write and read path
   - FloatTypes only have an issue with read path. In the write path Spark data 
type 'FloatType' is correctly mapped to JDBC equivalent data type 'Real'. But 
in the read path when JDBC data types need to be converted to Catalyst data 
types ( getCatalystType) 'Real' gets incorrectly gets mapped to 'DoubleType' 
rather than 'FloatType'.
   
   ## How was this patch tested?
   Integration test using : ./build/mvn test -Pdocker-integration-tests -pl 
:spark-docker-integration-tests_2.11 -Dtest=none 
-DwildcardSuites=org.apache.spark.sql.jdbc.MsSqlServerIntegrationSuite
   
   (Please explain how this patch was tested. E.g. unit tests, integration 
tests, manual tests)
   (If this patch involves UI changes, please attach a screenshot; otherwise, 
remove this)
   
   Please review https://spark.apache.org/contributing.html before opening a 
pull request.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to