uros-b commented on code in PR #56688:
URL: https://github.com/apache/spark/pull/56688#discussion_r3462690380


##########
sql/connect/client/jdbc/src/main/scala/org/apache/spark/sql/connect/client/jdbc/SparkConnectDatabaseMetaData.scala:
##########
@@ -816,4 +882,77 @@ object SparkConnectDatabaseMetaData {
   )
 
   private[jdbc] val TABLE_TYPES = Seq("TABLE", "VIEW")
+
+  // One row of the java.sql.DatabaseMetaData.getTypeInfo result.
+  private type TypeInfoRow =
+    (
+        String,  // TYPE_NAME
+        Int,     // DATA_TYPE
+        Int,     // PRECISION
+        String,  // LITERAL_PREFIX
+        String,  // LITERAL_SUFFIX
+        String,  // CREATE_PARAMS
+        Short,   // NULLABLE
+        Boolean, // CASE_SENSITIVE
+        Short,   // SEARCHABLE
+        Boolean, // UNSIGNED_ATTRIBUTE
+        Boolean, // FIXED_PREC_SCALE
+        Boolean, // AUTO_INCREMENT
+        String,  // LOCAL_TYPE_NAME
+        Short,   // MINIMUM_SCALE
+        Short,   // MAXIMUM_SCALE
+        Int,     // SQL_DATA_TYPE
+        Int,     // SQL_DATETIME_SUB
+        Int      // NUM_PREC_RADIX
+    )
+
+  // Fills the columns that are constant across all Spark atomic types: every 
type is
+  // nullable and searchable, and none are unsigned, fixed-prec-scale, or 
auto-increment.
+  // `literalQuote` is used as both the literal prefix and suffix.
+  private def typeRow(
+      typeName: String,
+      dataType: Int,
+      precision: Int,
+      literalQuote: String,
+      createParams: String,
+      caseSensitive: Boolean,
+      minScale: Short,
+      maxScale: Short,
+      numPrecRadix: Int): TypeInfoRow =
+    (
+      typeName,
+      dataType,
+      precision,
+      literalQuote,
+      literalQuote,
+      createParams,
+      typeNullable.toShort,
+      caseSensitive,
+      typeSearchable.toShort,
+      false,
+      false,
+      false,
+      null,
+      minScale,
+      maxScale,
+      0,
+      0,
+      numPrecRadix)
+
+  // Static JDBC type metadata for the Spark SQL atomic types, mirroring the
+  // JdbcTypeUtils type-code/precision mapping. Only STRING is case-sensitive.
+  // TIME and TIMESTAMP_NTZ are omitted (new and duplicate JDBC type codes).
+  private[jdbc] val TYPE_INFO: Seq[TypeInfoRow] = Seq(

Review Comment:
   Please check: it seems that we're using `NUM_PREC_RADIX = 0` for non-numeric 
types, whereas JdbcTypeUtils uses `null`? If this is the case, and we want to 
mirror JdbcTypeUtils, then let's update accordingly.



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