-
Notifications
You must be signed in to change notification settings - Fork 28.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-19459][SQL] Add Hive datatype (char/varchar) to StructField metadata #16804
Changes from 2 commits
c6a5bf6
277ed15
64c37e0
7d1b48e
f42348a
e378f62
673168e
e7ca0ea
2fa926d
21be4ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,10 @@ package org.apache.spark.sql | |
* Contains a type system for attributes produced by relations, including complex types like | ||
* structs, arrays and maps. | ||
*/ | ||
package object types | ||
package object types { | ||
/** | ||
* Metadata key used to store the Hive type name. This is relevant for datatypes that do not | ||
* have a direct Spark SQL counterpart, such as CHAR and VARCHAR. | ||
*/ | ||
val HIVE_TYPE_STRING = "HIVE_TYPE_STRING" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shall we remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah we should. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,6 +162,28 @@ abstract class OrcSuite extends QueryTest with TestHiveSingleton with BeforeAndA | |
hiveClient.runSqlHive("DROP TABLE IF EXISTS orc_varchar") | ||
} | ||
} | ||
|
||
test("read varchar column from orc tables created by hive") { | ||
try { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about
then we don't need to create the orc file manually. |
||
// This is an ORC file with a STRING, a CHAR(10) and a VARCHAR(10) column that has been | ||
// created using Hive 1.2.1 | ||
val hiveOrc = new File(Thread.currentThread().getContextClassLoader | ||
.getResource(s"data/files/orc/").getFile).toURI | ||
sql( | ||
s""" | ||
|CREATE EXTERNAL TABLE test_hive_orc( | ||
| a STRING, | ||
| b CHAR(10), | ||
| c VARCHAR(10) | ||
|) | ||
|STORED AS ORC | ||
|LOCATION '$hiveOrc' | ||
""".stripMargin) | ||
checkAnswer(spark.table("test_hive_orc"), Row("a", "b ", "c")) | ||
} finally { | ||
sql("DROP TABLE IF EXISTS test_hive_orc") | ||
} | ||
} | ||
} | ||
|
||
class OrcSourceSuite extends OrcSuite { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: