-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-16948][SQL] Use metastore schema instead of inferring schema for ORC in HiveMetastoreCatalog #14537
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-16948][SQL] Use metastore schema instead of inferring schema for ORC in HiveMetastoreCatalog #14537
Changes from 3 commits
5721b88
4ae92d8
75bca1b
97d21f6
4004c0a
9a8838a
eb8a955
70cf84d
c9d677b
7385a06
1746853
5f7e5ad
e8e2d70
0f901aa
0772a96
6ff7e5d
fc14e2d
9ecb2ed
fa71370
e39715e
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 |
|---|---|---|
|
|
@@ -17,9 +17,12 @@ | |
|
|
||
| package org.apache.spark.sql.hive.orc | ||
|
|
||
| import java.io.FileNotFoundException | ||
| import java.net.URI | ||
| import java.util.Properties | ||
|
|
||
| import scala.util.Try | ||
|
|
||
| import org.apache.hadoop.conf.Configuration | ||
| import org.apache.hadoop.fs.{FileStatus, Path} | ||
| import org.apache.hadoop.hive.conf.HiveConf.ConfVars | ||
|
|
@@ -56,10 +59,11 @@ private[sql] class OrcFileFormat | |
| sparkSession: SparkSession, | ||
| options: Map[String, String], | ||
| files: Seq[FileStatus]): Option[StructType] = { | ||
| OrcFileOperator.readSchema( | ||
| files.map(_.getPath.toUri.toString), | ||
| Some(sparkSession.sessionState.newHadoopConf()) | ||
| ) | ||
| val schema = Try(OrcFileOperator.readSchema( | ||
|
||
| files.map(_.getPath.toUri.toString), | ||
| Some(sparkSession.sessionState.newHadoopConf()))) | ||
| .recover { case _: FileNotFoundException => None } | ||
|
||
| schema.get | ||
| } | ||
|
|
||
| override def prepareWrite( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -349,6 +349,29 @@ class OrcQuerySuite extends QueryTest with BeforeAndAfterAll with OrcTest { | |
| } | ||
| } | ||
|
|
||
| test("SPARK-16948. Check empty orc partitioned tables in ORC") { | ||
| withSQLConf((HiveUtils.CONVERT_METASTORE_ORC.key, "true")) { | ||
| withTempPath { dir => | ||
|
||
| withTable("empty_orc_partitioned") { | ||
| spark.sql( | ||
| s"""CREATE TABLE empty_orc_partitioned(key INT, value STRING) | ||
| | PARTITIONED BY (p INT) STORED AS ORC | ||
| """.stripMargin) | ||
|
|
||
| val emptyDF = Seq.empty[(Int, String)].toDF("key", "value").coalesce(1) | ||
| emptyDF.createOrReplaceTempView("empty") | ||
|
||
|
|
||
| // Query empty table | ||
| val df = spark.sql( | ||
| s"""SELECT key, value FROM empty_orc_partitioned | ||
| | WHERE key > 10 | ||
| """.stripMargin) | ||
| checkAnswer(df, emptyDF) | ||
|
||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test("SPARK-10623 Enable ORC PPD") { | ||
| withTempPath { dir => | ||
| withSQLConf(SQLConf.ORC_FILTER_PUSHDOWN_ENABLED.key -> "true") { | ||
|
|
||
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.
can we be more specific here? e.g. doing it only if it is parquet or orc.