aokolnychyi commented on code in PR #50593: URL: https://github.com/apache/spark/pull/50593#discussion_r2044980720
########## sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2DataFrameSuite.scala: ########## @@ -338,4 +341,154 @@ class DataSourceV2DataFrameSuite Row(2, "unknown"))) } } + + test("create/replace table with complex foldable default values") { + val tableName = "testcat.ns1.ns2.tbl" + withTable(tableName) { + val createExec = executeAndKeepPhysicalPlan[CreateTableExec] { + sql( + s""" + |CREATE TABLE $tableName ( + | id INT, + | salary INT DEFAULT (100 + 23), + | dep STRING DEFAULT ('h' || 'r'), + | active BOOLEAN DEFAULT CAST(1 AS BOOLEAN) + |) USING foo + |""".stripMargin) + } + + checkDefaultValues( + createExec.columns, + Array( + null, + new ColumnDefaultValue( + "(100 + 23)", + LiteralValue(123, IntegerType), Review Comment: We don't have to covert the original Catalyst expression to V2 in this case as the expression is foldable and doesn't contain expressions like `current_date()` or `current_catalog()`. It is safe to convert the simplified version of the Catalyst expression. -- 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-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org