sadikovi commented on code in PR #36745:
URL: https://github.com/apache/spark/pull/36745#discussion_r887433430
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala:
##########
@@ -427,6 +428,7 @@ class SessionCatalog(
tableDefinition.copy(identifier = tableIdentifier)
}
+
ResolveDefaultColumns.checkDataSourceSupportsDefaultColumns(tableDefinition)
Review Comment:
Do we also need to handle DataFrame API? For example, I create a table using
this:
```
val schema = ...
val df = spark.createDataFrame(schema, ...)
df.write.saveAsTable("...")
```
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/ResolveDefaultColumnsUtil.scala:
##########
@@ -231,4 +232,18 @@ object ResolveDefaultColumns {
}
}
}
+
+ def checkDataSourceSupportsDefaultColumns(table: CatalogTable): Unit = {
+ if (table.schema.fields.map(_.metadata).exists { m =>
+ m.contains(CURRENT_DEFAULT_COLUMN_METADATA_KEY) ||
+ m.contains(EXISTS_DEFAULT_COLUMN_METADATA_KEY)
+ }) {
+ table.provider.getOrElse("").toLowerCase() match {
+ case "csv" | "json" | "parquet" | "orc" =>
Review Comment:
Would you like to make a configuration option? Or does it depend on the data
source implementation. For example, can we have DEFAULT in JDBC?
Do we also need to consider DataSource V2? Will this feature work there?
--
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]