uros-b commented on code in PR #56688:
URL: https://github.com/apache/spark/pull/56688#discussion_r3462664951
##########
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).
Review Comment:
TYPE_INFO omits TIME with the comment // TIME and TIMESTAMP_NTZ are omitted
(new and duplicate JDBC type codes). The rationale is imprecise: Types.TIME
(92) is a distinct code (not a duplicate), and JdbcTypeUtils handles it. Either
include TIME in the catalog, or fix the comment to state the actual reason
(parameterized type / CREATE_PARAMS not yet modeled).
##########
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).
Review Comment:
TYPE_INFO omits TIME with the comment // TIME and TIMESTAMP_NTZ are omitted
(new and duplicate JDBC type codes). The rationale is imprecise: Types.TIME
(92) is a distinct code (not a duplicate), and JdbcTypeUtils handles it. Either
include TIME in the catalog, or fix the comment to state the actual reason.
--
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]