Copilot commented on code in PR #12476:
URL: https://github.com/apache/gluten/pull/12476#discussion_r3542718520
##########
gluten-ut/spark40/src/test/scala/org/apache/spark/sql/sources/GlutenInsertSuite.scala:
##########
@@ -406,195 +406,189 @@ class GlutenInsertSuite
// TODO: fix in Spark-4.0
ignoreGluten("SPARK-39557 INSERT INTO statements with tables with array
defaults") {
- withSQLConf("spark.gluten.sql.complexType.scan.fallback.enabled" ->
"false") {
- import testImplicits._
- // Positive tests: array types are supported as default values.
- case class Config(dataSource: String, useDataFrames: Boolean = false)
- Seq(
- Config("parquet"),
- Config("parquet", useDataFrames = true),
- Config("orc"),
- Config("orc", useDataFrames = true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- sql("alter table t add column s array<int> default array(1, 2)")
- checkAnswer(spark.table("t"), Row(false, null))
- sql("insert into t(i) values (true)")
- checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true,
Seq(1, 2))))
+ import testImplicits._
+ // Positive tests: array types are supported as default values.
+ case class Config(dataSource: String, useDataFrames: Boolean = false)
+ Seq(
+ Config("parquet"),
+ Config("parquet", useDataFrames = true),
+ Config("orc"),
+ Config("orc", useDataFrames = true)).foreach {
+ config =>
+ withTable("t") {
+ sql(s"create table t(i boolean) using ${config.dataSource}")
+ if (config.useDataFrames) {
+ Seq(false).toDF.write.insertInto("t")
+ } else {
+ sql("insert into t select false")
}
- }
- // Negative tests: provided array element types must match their
corresponding DEFAULT
- // declarations, if applicable.
- val incompatibleDefault =
- "Failed to execute ALTER TABLE ADD COLUMNS command because the
destination " +
- "table column `s` has a DEFAULT value"
- Seq(Config("parquet"), Config("parquet", useDataFrames = true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- assert(intercept[AnalysisException] {
- sql("alter table t add column s array<int> default array('abc',
'def')")
- }.getMessage.contains(incompatibleDefault))
+ sql("alter table t add column s array<int> default array(1, 2)")
+ checkAnswer(spark.table("t"), Row(false, null))
+ sql("insert into t(i) values (true)")
+ checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true, Seq(1,
2))))
+ }
+ }
+ // Negative tests: provided array element types must match their
corresponding DEFAULT
+ // declarations, if applicable.
+ val incompatibleDefault =
+ "Failed to execute ALTER TABLE ADD COLUMNS command because the
destination " +
+ "table column `s` has a DEFAULT value"
+ Seq(Config("parquet"), Config("parquet", useDataFrames = true)).foreach {
+ config =>
+ withTable("t") {
+ sql(s"create table t(i boolean) using ${config.dataSource}")
+ if (config.useDataFrames) {
+ Seq(false).toDF.write.insertInto("t")
+ } else {
+ sql("insert into t select false")
}
- }
+ assert(intercept[AnalysisException] {
+ sql("alter table t add column s array<int> default array('abc',
'def')")
+ }.getMessage.contains(incompatibleDefault))
+ }
}
}
// TODO: fix in Spark-4.0
ignoreGluten("SPARK-39557 INSERT INTO statements with tables with struct
defaults") {
- withSQLConf("spark.gluten.sql.complexType.scan.fallback.enabled" ->
"false") {
-
- import testImplicits._
- // Positive tests: struct types are supported as default values.
- case class Config(dataSource: String, useDataFrames: Boolean = false)
- Seq(
- Config("parquet"),
- Config("parquet", useDataFrames = true),
- Config("orc"),
- Config("orc", useDataFrames = true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- sql(
- "alter table t add column s struct<x boolean, y string> default
struct(true, 'abc')")
- checkAnswer(spark.table("t"), Row(false, null))
- sql("insert into t(i) values (true)")
- checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true,
Row(true, "abc"))))
+
+ import testImplicits._
+ // Positive tests: struct types are supported as default values.
+ case class Config(dataSource: String, useDataFrames: Boolean = false)
+ Seq(
+ Config("parquet"),
+ Config("parquet", useDataFrames = true),
+ Config("orc"),
+ Config("orc", useDataFrames = true)).foreach {
+ config =>
+ withTable("t") {
+ sql(s"create table t(i boolean) using ${config.dataSource}")
+ if (config.useDataFrames) {
+ Seq(false).toDF.write.insertInto("t")
+ } else {
+ sql("insert into t select false")
}
- }
+ sql(
+ "alter table t add column s struct<x boolean, y string> default
struct(true, 'abc')")
+ checkAnswer(spark.table("t"), Row(false, null))
+ sql("insert into t(i) values (true)")
+ checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true,
Row(true, "abc"))))
+ }
+ }
- // Negative tests: provided map element types must match their
corresponding DEFAULT
- // declarations, if applicable.
- val incompatibleDefault =
- "Failed to execute ALTER TABLE ADD COLUMNS command because the
destination " +
- "table column `s` has a DEFAULT value"
- Seq(Config("parquet"), Config("parquet", useDataFrames = true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- assert(intercept[AnalysisException] {
- sql("alter table t add column s struct<x boolean, y string>
default struct(42, 56)")
- }.getMessage.contains(incompatibleDefault))
+ // Negative tests: provided map element types must match their
corresponding DEFAULT
+ // declarations, if applicable.
Review Comment:
The negative-test comment says "map element types" but this block is
validating a STRUCT default (see the `struct<x ...>` column and `default
struct(42, 56)` below). This is misleading for future readers.
##########
gluten-ut/spark41/src/test/scala/org/apache/spark/sql/sources/GlutenInsertSuite.scala:
##########
@@ -406,195 +406,189 @@ class GlutenInsertSuite
// TODO: fix in Spark-4.0
ignoreGluten("SPARK-39557 INSERT INTO statements with tables with array
defaults") {
- withSQLConf("spark.gluten.sql.complexType.scan.fallback.enabled" ->
"false") {
- import testImplicits._
- // Positive tests: array types are supported as default values.
- case class Config(dataSource: String, useDataFrames: Boolean = false)
- Seq(
- Config("parquet"),
- Config("parquet", useDataFrames = true),
- Config("orc"),
- Config("orc", useDataFrames = true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- sql("alter table t add column s array<int> default array(1, 2)")
- checkAnswer(spark.table("t"), Row(false, null))
- sql("insert into t(i) values (true)")
- checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true,
Seq(1, 2))))
+ import testImplicits._
+ // Positive tests: array types are supported as default values.
+ case class Config(dataSource: String, useDataFrames: Boolean = false)
+ Seq(
+ Config("parquet"),
+ Config("parquet", useDataFrames = true),
+ Config("orc"),
+ Config("orc", useDataFrames = true)).foreach {
+ config =>
+ withTable("t") {
+ sql(s"create table t(i boolean) using ${config.dataSource}")
+ if (config.useDataFrames) {
+ Seq(false).toDF.write.insertInto("t")
+ } else {
+ sql("insert into t select false")
}
- }
- // Negative tests: provided array element types must match their
corresponding DEFAULT
- // declarations, if applicable.
- val incompatibleDefault =
- "Failed to execute ALTER TABLE ADD COLUMNS command because the
destination " +
- "table column `s` has a DEFAULT value"
- Seq(Config("parquet"), Config("parquet", useDataFrames = true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- assert(intercept[AnalysisException] {
- sql("alter table t add column s array<int> default array('abc',
'def')")
- }.getMessage.contains(incompatibleDefault))
+ sql("alter table t add column s array<int> default array(1, 2)")
+ checkAnswer(spark.table("t"), Row(false, null))
+ sql("insert into t(i) values (true)")
+ checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true, Seq(1,
2))))
+ }
+ }
+ // Negative tests: provided array element types must match their
corresponding DEFAULT
+ // declarations, if applicable.
+ val incompatibleDefault =
+ "Failed to execute ALTER TABLE ADD COLUMNS command because the
destination " +
+ "table column `s` has a DEFAULT value"
+ Seq(Config("parquet"), Config("parquet", useDataFrames = true)).foreach {
+ config =>
+ withTable("t") {
+ sql(s"create table t(i boolean) using ${config.dataSource}")
+ if (config.useDataFrames) {
+ Seq(false).toDF.write.insertInto("t")
+ } else {
+ sql("insert into t select false")
}
- }
+ assert(intercept[AnalysisException] {
+ sql("alter table t add column s array<int> default array('abc',
'def')")
+ }.getMessage.contains(incompatibleDefault))
+ }
}
}
// TODO: fix in Spark-4.0
ignoreGluten("SPARK-39557 INSERT INTO statements with tables with struct
defaults") {
- withSQLConf("spark.gluten.sql.complexType.scan.fallback.enabled" ->
"false") {
-
- import testImplicits._
- // Positive tests: struct types are supported as default values.
- case class Config(dataSource: String, useDataFrames: Boolean = false)
- Seq(
- Config("parquet"),
- Config("parquet", useDataFrames = true),
- Config("orc"),
- Config("orc", useDataFrames = true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- sql(
- "alter table t add column s struct<x boolean, y string> default
struct(true, 'abc')")
- checkAnswer(spark.table("t"), Row(false, null))
- sql("insert into t(i) values (true)")
- checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true,
Row(true, "abc"))))
+
+ import testImplicits._
+ // Positive tests: struct types are supported as default values.
+ case class Config(dataSource: String, useDataFrames: Boolean = false)
+ Seq(
+ Config("parquet"),
+ Config("parquet", useDataFrames = true),
+ Config("orc"),
+ Config("orc", useDataFrames = true)).foreach {
+ config =>
+ withTable("t") {
+ sql(s"create table t(i boolean) using ${config.dataSource}")
+ if (config.useDataFrames) {
+ Seq(false).toDF.write.insertInto("t")
+ } else {
+ sql("insert into t select false")
}
- }
+ sql(
+ "alter table t add column s struct<x boolean, y string> default
struct(true, 'abc')")
+ checkAnswer(spark.table("t"), Row(false, null))
+ sql("insert into t(i) values (true)")
+ checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true,
Row(true, "abc"))))
+ }
+ }
- // Negative tests: provided map element types must match their
corresponding DEFAULT
- // declarations, if applicable.
- val incompatibleDefault =
- "Failed to execute ALTER TABLE ADD COLUMNS command because the
destination " +
- "table column `s` has a DEFAULT value"
- Seq(Config("parquet"), Config("parquet", useDataFrames = true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- assert(intercept[AnalysisException] {
- sql("alter table t add column s struct<x boolean, y string>
default struct(42, 56)")
- }.getMessage.contains(incompatibleDefault))
+ // Negative tests: provided map element types must match their
corresponding DEFAULT
+ // declarations, if applicable.
Review Comment:
The negative-test comment says "map element types" but this block is
validating a STRUCT default (see the `struct<x ...>` column and `default
struct(42, 56)` below). This is misleading for future readers.
##########
gluten-ut/spark35/src/test/scala/org/apache/spark/sql/sources/GlutenInsertSuite.scala:
##########
@@ -405,194 +405,188 @@ class GlutenInsertSuite
}
testGluten("SPARK-39557 INSERT INTO statements with tables with array
defaults") {
- withSQLConf("spark.gluten.sql.complexType.scan.fallback.enabled" ->
"false") {
- import testImplicits._
- // Positive tests: array types are supported as default values.
- case class Config(dataSource: String, useDataFrames: Boolean = false)
- Seq(
- Config("parquet"),
- Config("parquet", useDataFrames = true),
- Config("orc"),
- Config("orc", useDataFrames = true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- sql("alter table t add column s array<int> default array(1, 2)")
- checkAnswer(spark.table("t"), Row(false, null))
- sql("insert into t(i) values (true)")
- checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true,
Seq(1, 2))))
+ import testImplicits._
+ // Positive tests: array types are supported as default values.
+ case class Config(dataSource: String, useDataFrames: Boolean = false)
+ Seq(
+ Config("parquet"),
+ Config("parquet", useDataFrames = true),
+ Config("orc"),
+ Config("orc", useDataFrames = true)).foreach {
+ config =>
+ withTable("t") {
+ sql(s"create table t(i boolean) using ${config.dataSource}")
+ if (config.useDataFrames) {
+ Seq(false).toDF.write.insertInto("t")
+ } else {
+ sql("insert into t select false")
}
- }
- // Negative tests: provided array element types must match their
corresponding DEFAULT
- // declarations, if applicable.
- val incompatibleDefault =
- "Failed to execute ALTER TABLE ADD COLUMNS command because the
destination " +
- "table column `s` has a DEFAULT value"
- Seq(Config("parquet"), Config("parquet", useDataFrames = true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- assert(intercept[AnalysisException] {
- sql("alter table t add column s array<int> default array('abc',
'def')")
- }.getMessage.contains(incompatibleDefault))
+ sql("alter table t add column s array<int> default array(1, 2)")
+ checkAnswer(spark.table("t"), Row(false, null))
+ sql("insert into t(i) values (true)")
+ checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true, Seq(1,
2))))
+ }
+ }
+ // Negative tests: provided array element types must match their
corresponding DEFAULT
+ // declarations, if applicable.
+ val incompatibleDefault =
+ "Failed to execute ALTER TABLE ADD COLUMNS command because the
destination " +
+ "table column `s` has a DEFAULT value"
+ Seq(Config("parquet"), Config("parquet", useDataFrames = true)).foreach {
+ config =>
+ withTable("t") {
+ sql(s"create table t(i boolean) using ${config.dataSource}")
+ if (config.useDataFrames) {
+ Seq(false).toDF.write.insertInto("t")
+ } else {
+ sql("insert into t select false")
}
- }
+ assert(intercept[AnalysisException] {
+ sql("alter table t add column s array<int> default array('abc',
'def')")
+ }.getMessage.contains(incompatibleDefault))
+ }
}
}
testGluten("SPARK-39557 INSERT INTO statements with tables with struct
defaults") {
- withSQLConf("spark.gluten.sql.complexType.scan.fallback.enabled" ->
"false") {
-
- import testImplicits._
- // Positive tests: struct types are supported as default values.
- case class Config(dataSource: String, useDataFrames: Boolean = false)
- Seq(
- Config("parquet"),
- Config("parquet", useDataFrames = true),
- Config("orc"),
- Config("orc", useDataFrames = true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- sql(
- "alter table t add column s struct<x boolean, y string> default
struct(true, 'abc')")
- checkAnswer(spark.table("t"), Row(false, null))
- sql("insert into t(i) values (true)")
- checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true,
Row(true, "abc"))))
+
+ import testImplicits._
+ // Positive tests: struct types are supported as default values.
+ case class Config(dataSource: String, useDataFrames: Boolean = false)
+ Seq(
+ Config("parquet"),
+ Config("parquet", useDataFrames = true),
+ Config("orc"),
+ Config("orc", useDataFrames = true)).foreach {
+ config =>
+ withTable("t") {
+ sql(s"create table t(i boolean) using ${config.dataSource}")
+ if (config.useDataFrames) {
+ Seq(false).toDF.write.insertInto("t")
+ } else {
+ sql("insert into t select false")
}
- }
+ sql(
+ "alter table t add column s struct<x boolean, y string> default
struct(true, 'abc')")
+ checkAnswer(spark.table("t"), Row(false, null))
+ sql("insert into t(i) values (true)")
+ checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true,
Row(true, "abc"))))
+ }
+ }
- // Negative tests: provided map element types must match their
corresponding DEFAULT
- // declarations, if applicable.
- val incompatibleDefault =
- "Failed to execute ALTER TABLE ADD COLUMNS command because the
destination " +
- "table column `s` has a DEFAULT value"
- Seq(Config("parquet"), Config("parquet", useDataFrames = true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- assert(intercept[AnalysisException] {
- sql("alter table t add column s struct<x boolean, y string>
default struct(42, 56)")
- }.getMessage.contains(incompatibleDefault))
+ // Negative tests: provided map element types must match their
corresponding DEFAULT
+ // declarations, if applicable.
Review Comment:
The negative-test comment says "map element types" but this block is
validating a STRUCT default (see the `struct<x ...>` column and `default
struct(42, 56)` below). This is misleading for future readers.
##########
gluten-ut/spark34/src/test/scala/org/apache/spark/sql/sources/GlutenInsertSuite.scala:
##########
@@ -433,194 +433,188 @@ class GlutenInsertSuite
}
testGluten("SPARK-39557 INSERT INTO statements with tables with array
defaults") {
- withSQLConf("spark.gluten.sql.complexType.scan.fallback.enabled" ->
"false") {
- import testImplicits._
- // Positive tests: array types are supported as default values.
- case class Config(dataSource: String, useDataFrames: Boolean = false)
- Seq(
- Config("parquet"),
- Config("parquet", useDataFrames = true),
- Config("orc"),
- Config("orc", useDataFrames = true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- sql("alter table t add column s array<int> default array(1, 2)")
- checkAnswer(spark.table("t"), Row(false, null))
- sql("insert into t(i) values (true)")
- checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true,
Seq(1, 2))))
+ import testImplicits._
+ // Positive tests: array types are supported as default values.
+ case class Config(dataSource: String, useDataFrames: Boolean = false)
+ Seq(
+ Config("parquet"),
+ Config("parquet", useDataFrames = true),
+ Config("orc"),
+ Config("orc", useDataFrames = true)).foreach {
+ config =>
+ withTable("t") {
+ sql(s"create table t(i boolean) using ${config.dataSource}")
+ if (config.useDataFrames) {
+ Seq(false).toDF.write.insertInto("t")
+ } else {
+ sql("insert into t select false")
}
- }
- // Negative tests: provided array element types must match their
corresponding DEFAULT
- // declarations, if applicable.
- val incompatibleDefault =
- "Failed to execute ALTER TABLE ADD COLUMNS command because the
destination " +
- "table column s has a DEFAULT value with type"
- Seq(Config("parquet"), Config("parquet", true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- assert(intercept[AnalysisException] {
- sql("alter table t add column s array<int> default array('abc',
'def')")
- }.getMessage.contains(incompatibleDefault))
+ sql("alter table t add column s array<int> default array(1, 2)")
+ checkAnswer(spark.table("t"), Row(false, null))
+ sql("insert into t(i) values (true)")
+ checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true, Seq(1,
2))))
+ }
+ }
+ // Negative tests: provided array element types must match their
corresponding DEFAULT
+ // declarations, if applicable.
+ val incompatibleDefault =
+ "Failed to execute ALTER TABLE ADD COLUMNS command because the
destination " +
+ "table column s has a DEFAULT value with type"
+ Seq(Config("parquet"), Config("parquet", true)).foreach {
+ config =>
+ withTable("t") {
+ sql(s"create table t(i boolean) using ${config.dataSource}")
+ if (config.useDataFrames) {
+ Seq(false).toDF.write.insertInto("t")
+ } else {
+ sql("insert into t select false")
}
- }
+ assert(intercept[AnalysisException] {
+ sql("alter table t add column s array<int> default array('abc',
'def')")
+ }.getMessage.contains(incompatibleDefault))
+ }
}
}
testGluten("SPARK-39557 INSERT INTO statements with tables with struct
defaults") {
- withSQLConf("spark.gluten.sql.complexType.scan.fallback.enabled" ->
"false") {
-
- import testImplicits._
- // Positive tests: struct types are supported as default values.
- case class Config(dataSource: String, useDataFrames: Boolean = false)
- Seq(
- Config("parquet"),
- Config("parquet", useDataFrames = true),
- Config("orc"),
- Config("orc", useDataFrames = true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- sql(
- "alter table t add column s struct<x boolean, y string> default
struct(true, 'abc')")
- checkAnswer(spark.table("t"), Row(false, null))
- sql("insert into t(i) values (true)")
- checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true,
Row(true, "abc"))))
+
+ import testImplicits._
+ // Positive tests: struct types are supported as default values.
+ case class Config(dataSource: String, useDataFrames: Boolean = false)
+ Seq(
+ Config("parquet"),
+ Config("parquet", useDataFrames = true),
+ Config("orc"),
+ Config("orc", useDataFrames = true)).foreach {
+ config =>
+ withTable("t") {
+ sql(s"create table t(i boolean) using ${config.dataSource}")
+ if (config.useDataFrames) {
+ Seq(false).toDF.write.insertInto("t")
+ } else {
+ sql("insert into t select false")
}
- }
+ sql(
+ "alter table t add column s struct<x boolean, y string> default
struct(true, 'abc')")
+ checkAnswer(spark.table("t"), Row(false, null))
+ sql("insert into t(i) values (true)")
+ checkAnswer(spark.table("t"), Seq(Row(false, null), Row(true,
Row(true, "abc"))))
+ }
+ }
- // Negative tests: provided map element types must match their
corresponding DEFAULT
- // declarations, if applicable.
- val incompatibleDefault =
- "Failed to execute ALTER TABLE ADD COLUMNS command because the
destination " +
- "table column s has a DEFAULT value with type"
- Seq(Config("parquet"), Config("parquet", true)).foreach {
- config =>
- withTable("t") {
- sql(s"create table t(i boolean) using ${config.dataSource}")
- if (config.useDataFrames) {
- Seq(false).toDF.write.insertInto("t")
- } else {
- sql("insert into t select false")
- }
- assert(intercept[AnalysisException] {
- sql("alter table t add column s struct<x boolean, y string>
default struct(42, 56)")
- }.getMessage.contains(incompatibleDefault))
+ // Negative tests: provided map element types must match their
corresponding DEFAULT
+ // declarations, if applicable.
Review Comment:
The negative-test comment says "map element types" but this block is
validating a STRUCT default (see the `struct<x ...>` column and `default
struct(42, 56)` below). This is misleading for future readers.
--
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]