panbingkun commented on PR #46655:
URL: https://github.com/apache/spark/pull/46655#issuecomment-2126624184

   Through comparative analysis, it is found that
   1. In version `2.x`, there is `no distinction` between `signed` and 
`unsigned`. For example, a type is defined in MySQL: `med MEDIUMINT UNSIGNED`
     Through the `mariadb jdbc driver`, the final logic is:
     
https://github.com/mariadb-corporation/mariadb-connector-j/blob/maintenance/2.x/src/main/java/org/mariadb/jdbc/MariaDbResultSetMetaData.java#L283
     <img width="490" alt="image" 
src="https://github.com/apache/spark/assets/15246973/2a2987e7-6229-4c8f-b190-4637814c4ab7";>
   
     
https://github.com/mariadb-corporation/mariadb-connector-j/blob/maintenance/2.x/src/main/java/org/mariadb/jdbc/internal/ColumnType.java#L73
     <img width="619" alt="image" 
src="https://github.com/apache/spark/assets/15246973/a89e2f1c-820e-441d-8d66-2262d7711d97";>
     ** `Types.INTEGER` will be returned  to `Spark` **
   
     On the Spark side, we will go to the following logic:
   
https://github.com/apache/spark/blob/14d3f447360b66663c8979a8cdb4c40c480a1e04/sql/core/src/main/scala/org/apache/spark/sql/jdbc/MySQLDialect.scala#L148-L151
   
     ** Therefore, `Interger` will be finally obtained. **
   
   2. In version `3.x`, there is a `distinction` between `signed` and 
`unsigned`. For example, a type is defined in MySQL: `med MEDIUMINT UNSIGNED`
   Through the `mariadb jdbc driver`, the final logic is:
     
https://github.com/mariadb-corporation/mariadb-connector-j/blob/master/src/main/java/org/mariadb/jdbc/client/result/ResultSetMetaData.java#L232-L234
     <img width="578" alt="image" 
src="https://github.com/apache/spark/assets/15246973/c34bae4e-06db-4e41-82a2-325c50abe42c";>
     
     
https://github.com/mariadb-corporation/mariadb-connector-j/blob/master/src/main/java/org/mariadb/jdbc/client/result/ResultSetMetaData.java#L297-L302
     <img width="659" alt="image" 
src="https://github.com/apache/spark/assets/15246973/036a0544-ffa2-4dec-a0fb-c6439c888988";>
     
     **UnsignedMediumIntColumn**
     
https://github.com/mariadb-corporation/mariadb-connector-j/blob/master/src/main/java/org/mariadb/jdbc/client/column/UnsignedMediumIntColumn.java
   
   
   
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to