rangareddy commented on code in PR #38875:
URL: https://github.com/apache/spark/pull/38875#discussion_r1066754204
##########
sql/core/src/test/scala/org/apache/spark/sql/sources/InsertSuite.scala:
##########
@@ -2313,6 +2313,33 @@ class InsertSuite extends DataSourceTest with
SharedSparkSession {
}
}
}
+
+ test("SPARK-40988: Test case for insert partition should verify value") {
+ val tableName = "partition_table"
+ withTable(tableName) {
+ sql(s"DROP TABLE IF EXISTS $tableName")
+ sql(s"CREATE TABLE $tableName (id INT, name STRING) USING PARQUET
PARTITIONED BY (age INT)")
+
+ sql(s"INSERT INTO TABLE $tableName PARTITION(age=1) VALUES (1, 'ABC')")
+ checkAnswer(spark.table(s"$tableName"), Row(1, "ABC", 1))
+
+ checkError(
+ exception = intercept[SparkNumberFormatException] {
+ sql(s"INSERT INTO TABLE $tableName PARTITION(age='aaa') VALUES (1,
'ABC')")
Review Comment:
@ulysses-you
Yes, you are right. I am adding a test case for the insert into the hive
table with partitioned data.
The following implementation is correct as per your suggestion?
```scala
withSQLConf("spark.sql.hive.convertInsertingPartitionedTable" ->
"false") {
checkError(
exception = intercept[SparkNumberFormatException] {
sql(s"INSERT INTO TABLE $tableName PARTITION(age='aaa') VALUES
(1, 'ABC')")
},
errorClass = "CAST_INVALID_INPUT",
parameters = Map(
"ansiConfig" -> "\"spark.sql.ansi.enabled\"",
"expression" -> "'aaa'",
"sourceType" -> "\"STRING\"",
"targetType" -> "\"INT\""),
context = ExpectedContext(
fragment = s"INSERT INTO TABLE $tableName PARTITION(age='aaa')",
start = 0,
stop = 38 + tableName.length)
)
}```
--
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]