Skip to content
Snippets Groups Projects
Commit 3ae0cda8 authored by wangfei's avatar wangfei Committed by Michael Armbrust
Browse files

[SPARK-4695][SQL] Get result using executeCollect

Using ```executeCollect``` to collect the result, because executeCollect is a custom implementation of collect in spark sql which better than rdd's collect

Author: wangfei <wangfei1@huawei.com>

Closes #3547 from scwf/executeCollect and squashes the following commits:

a5ab68e [wangfei] Revert "adding debug info"
a60d680 [wangfei] fix test failure
0db7ce8 [wangfei] adding debug info
184c594 [wangfei] using executeCollect instead collect
parent 1f5ddf17
No related branches found
No related tags found
No related merge requests found
......@@ -377,7 +377,7 @@ class HiveContext(sc: SparkContext) extends SQLContext(sc) {
command.executeCollect().map(_.head.toString)
case other =>
val result: Seq[Seq[Any]] = toRdd.map(_.copy()).collect().toSeq
val result: Seq[Seq[Any]] = other.executeCollect().toSeq
// We need the types so we can output struct field names
val types = analyzed.output.map(_.dataType)
// Reformat to match hive tab delimited output.
......@@ -416,6 +416,8 @@ object HiveContext {
case (bin: Array[Byte], BinaryType) => new String(bin, "UTF-8")
case (decimal: Decimal, DecimalType()) => // Hive strips trailing zeros so use its toString
HiveShim.createDecimal(decimal.toBigDecimal.underlying()).toString
case (decimal: BigDecimal, DecimalType()) =>
HiveShim.createDecimal(decimal.underlying()).toString
case (other, tpe) if primitiveTypes contains tpe => other.toString
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment