gatorsmile commented on a change in pull request #23559: [SPARK-26630][SQL] Fix
ClassCastException in TableReader while creating HadoopRDD
URL: https://github.com/apache/spark/pull/23559#discussion_r251190008
##########
File path:
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala
##########
@@ -260,6 +260,94 @@ class HiveCatalogedDDLSuite extends DDLSuite with
TestHiveSingleton with BeforeA
assert(err.contains("Cannot recognize hive type string:"))
}
}
+
+ test("SPARK-26630: table with old input format and without partitioned will
use HadoopRDD") {
+ withTable("table_old", "table_ctas_old") {
+ spark.sql(
+ s"""
+ |CREATE TABLE table_old (col1 LONG, col2 STRING, col3 DOUBLE, col4
BOOLEAN)
+ |STORED AS
+ |INPUTFORMAT 'org.apache.hadoop.mapred.TextInputFormat'
+ |OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
+ |""".stripMargin)
+ spark.sql("INSERT INTO table_old " +
+ "VALUES (2147483648, 'AAA', 3.14, false), (2147483649, 'BBB', 3.142,
true)")
+ assert(spark.sql("SELECT col1, col2, col3, col4 FROM
table_old").collect() ===
+ Array(Row(2147483648L, "AAA", 3.14, false), Row(2147483649L, "BBB",
3.142, true)))
Review comment:
```
sql(
"""
|CREATE TABLE table_pt_old (col1 LONG, col2 STRING, col3 DOUBLE,
col4 BOOLEAN)
|PARTITIONED BY (pt INT)
|STORED AS
|INPUTFORMAT 'org.apache.hadoop.mapred.TextInputFormat'
|OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
""".stripMargin)
sql(
"""
|INSERT INTO table_pt_old PARTITION (pt = 1)
|VALUES (2147483648, 'AAA', 3.14, false), (2147483649, 'BBB',
3.142, true)
""".stripMargin)
checkAnswer(
sql("SELECT col1, col2, col3, col4 FROM table_pt_old WHERE pt = 1"),
Row(2147483648L, "AAA", 3.14, false) :: Row(2147483649L, "BBB",
3.142, true) :: Nil)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]