morvenhuang commented on code in PR #36212:
URL: https://github.com/apache/spark/pull/36212#discussion_r852556099
##########
sql/core/src/test/scala/org/apache/spark/sql/sources/InsertSuite.scala:
##########
@@ -1178,34 +1205,34 @@ class InsertSuite extends DataSourceTest with
SharedSparkSession {
val addOneColButExpectedTwo = "target table has 2 column(s) but the
inserted data has 1 col"
val addTwoColButExpectedThree = "target table has 3 column(s) but the
inserted data has 2 col"
// The missing columns in these INSERT INTO commands do not have explicit
default values.
- withTable("t") {
- sql("create table t(i boolean, s bigint) using parquet")
- assert(intercept[AnalysisException] {
- sql("insert into t (i) values (true)")
- }.getMessage.contains(addOneColButExpectedTwo))
- }
- withTable("t") {
- sql("create table t(i boolean default true, s bigint) using parquet")
- assert(intercept[AnalysisException] {
- sql("insert into t (i) values (default)")
- }.getMessage.contains(addOneColButExpectedTwo))
- }
- withTable("t") {
- sql("create table t(i boolean, s bigint default 42) using parquet")
- assert(intercept[AnalysisException] {
- sql("insert into t (s) values (default)")
- }.getMessage.contains(addOneColButExpectedTwo))
- }
- withTable("t") {
- sql("create table t(i boolean, s bigint, q int default 43) using
parquet")
- assert(intercept[AnalysisException] {
- sql("insert into t (i, q) select true from (select 1)")
- }.getMessage.contains(addTwoColButExpectedThree))
- }
- // When the USE_NULLS_FOR_MISSING_DEFAULT_COLUMN_VALUES configuration is
disabled, and no
- // explicit DEFAULT value is available when the INSERT INTO statement
provides fewer
- // values than expected, the INSERT INTO command fails to execute.
withSQLConf(SQLConf.USE_NULLS_FOR_MISSING_DEFAULT_COLUMN_VALUES.key ->
"false") {
Review Comment:
There is an existing test("INSERT INTO with user specified columns and
defaults: positive tests") for this.
--
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]