Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ class HiveContext(sc: SparkContext) extends SQLContext(sc) {
private[spark] def convertMetastoreParquet: Boolean =
getConf("spark.sql.hive.convertMetastoreParquet", "true") == "true"

private[spark] def parquetBinaryAsString = setConf("spark.sql.parquet.binaryAsString", "true")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't be mutating configuration when accessing a setting. Also, I think that #3441 is going to solve this problem so perhaps we can close this issue?


// Hive use parquet with older version, which do not differentiate between binary data and strings
// So here set spark.sql.parquet.binaryAsString to true
if (convertMetastoreParquet) {
parquetBinaryAsString
}

override protected[sql] def executePlan(plan: LogicalPlan): this.QueryExecution =
new this.QueryExecution { val logical = plan }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ class HiveParquetSuite extends FunSuite with BeforeAndAfterAll with BeforeAndAft
compareRDDs(rddOrig, rddCopy, "testsource", ParquetTestData.testSchemaFieldNames)
}

test("SPARK-4553: String issue for Parquet Table") {
sql("CREATE TABLE parquet_string(key INT, value STRING)")
sql("INSERT OVERWRITE TABLE parquet_string SELECT * FROM src")
val result = sql("SELECT * FROM parquet_string limit 5").collect
assert(result(0)(1).isInstanceOf[String])
}

private def compareRDDs(rddOne: Array[Row], rddTwo: Array[Row], tableName: String, fieldNames: Seq[String]) {
var counter = 0
(rddOne, rddTwo).zipped.foreach {
Expand Down