You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "cloud-fan (via GitHub)" <gi...@apache.org> on 2023/12/20 05:08:06 UTC

Re: [PR] [SPARK-46443][SQL] Decimal precision and scale should decided by H2 dialect. [spark]

cloud-fan commented on code in PR #44398:
URL: https://github.com/apache/spark/pull/44398#discussion_r1432253449


##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/H2Dialect.scala:
##########
@@ -57,6 +57,22 @@ private[sql] object H2Dialect extends JdbcDialect {
   override def isSupportedFunction(funcName: String): Boolean =
     supportedFunctions.contains(funcName)
 
+  override def getCatalystType(
+      sqlType: Int, typeName: String, size: Int, md: MetadataBuilder): Option[DataType] = {
+    sqlType match {
+      case Types.NUMERIC =>
+        val scale = if (null != md) md.build().getLong("scale") else 0L
+        size match {
+          // SPARK-46443: Decimal precision and scale should decided by H2 dialect.
+          // Handle NUMBER fields that have incorrect precision/scale in special way
+          // because JDBC ResultSetMetaData returns 100000 precision and 50000 scale
+          case 100000 if scale == 50000 => Option(DecimalType(DecimalType.MAX_PRECISION, 19))

Review Comment:
   this is too specific. Can we do it if precision > 38?



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org