Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[SPARK-14387][SQL] Enable Hive-1.x ORC compatibility with spark.sql.h…
…ive.convertMetastoreOrc
  • Loading branch information
rbalamohan committed Aug 3, 2016
commit 046e0c433997b71c85635535b5039e0405cabd13
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.spark.sql.hive.orc

import java.io.File
import java.nio.charset.StandardCharsets

import org.scalatest.BeforeAndAfterAll
Expand Down Expand Up @@ -401,6 +402,31 @@ class OrcQuerySuite extends QueryTest with BeforeAndAfterAll with OrcTest {
}
}

def getHiveFile(path: String): File = {
new File(Thread.currentThread().getContextClassLoader.getResource(path).getFile)
}

test("Verify ORC conversion parameter: CONVERT_METASTORE_ORC with Hive-1.x files") {
val singleRowDF = Seq((2415022, "AAAAAAAAOKJNECAA")).toDF("key", "value")
Seq("true", "false").foreach { orcConversion =>
withSQLConf(HiveUtils.CONVERT_METASTORE_ORC.key -> orcConversion) {
withTable("dummy_orc") {
// Hive 1.x can have virtual columns as follows in ORC files
// Type: struct<_col0:int,_col1:string> in hive_1.x_orc
spark.sql(
s"""
|CREATE EXTERNAL TABLE dummy_orc(key INT, value STRING)
|STORED AS ORC
|LOCATION '${getHiveFile("data/files/hive_1.x_orc/")}'
""".stripMargin)

val df = spark.sql("SELECT key, value FROM dummy_orc LIMIT 1")
checkAnswer(df, singleRowDF)
}
}
}
}

test("Verify the ORC conversion parameter: CONVERT_METASTORE_ORC") {
withTempView("single") {
val singleRowDF = Seq((0, "foo")).toDF("key", "value")
Expand Down