Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
685fd07
use UTF8String instead of String for StringType
Mar 31, 2015
21f67c6
cleanup
Mar 31, 2015
4699c3a
use Array[Byte] in UTF8String
Mar 31, 2015
d32abd1
fix utf8 for python api
Mar 31, 2015
a85fb27
refactor
Mar 31, 2015
6b499ac
fix style
Apr 1, 2015
5f9e120
fix sql tests
Apr 1, 2015
38c303e
fix python sql tests
Apr 1, 2015
c7dd4d2
fix some catalyst tests
Apr 1, 2015
bb52e44
fix scala style
Apr 1, 2015
8b45864
fix codegen with UTF8String
Apr 1, 2015
23a766c
refactor
Apr 1, 2015
9dc32d1
fix some hive tests
Apr 2, 2015
73e4363
Merge branch 'master' of github.com:apache/spark into string
Apr 2, 2015
956b0a4
fix hive tests
Apr 2, 2015
9f4c194
convert data type for data source
Apr 2, 2015
537631c
some comment about Date
Apr 2, 2015
28d6f32
refactor
Apr 2, 2015
28f3d81
Merge branch 'master' of github.com:apache/spark into string
Apr 3, 2015
e5fa5b8
remove clone in UTF8String
Apr 3, 2015
8d17f21
fix hive compatibility tests
Apr 3, 2015
fd11364
optimize UTF8String
Apr 3, 2015
ac18ae6
address comment
Apr 3, 2015
2089d24
add hashcode check back
Apr 3, 2015
13d9d42
Merge branch 'master' of github.com:apache/spark into string
Apr 3, 2015
867bf50
fix String filter push down
Apr 4, 2015
1314a37
address comments from Yin
Apr 8, 2015
5116b43
rollback unrelated changes
Apr 8, 2015
08d897b
Merge branch 'master' of github.com:apache/spark into string
Apr 9, 2015
b04a19c
add comment for getString/setString
Apr 10, 2015
744788f
Merge branch 'master' of github.com:apache/spark into string
Apr 13, 2015
341ec2c
turn off scala style check in UTF8StringSuite
Apr 13, 2015
59025c8
address comments from @marmbrus
Apr 15, 2015
6d776a9
Merge branch 'master' of github.com:apache/spark into string
Apr 15, 2015
2772f0d
fix new test failure
Apr 15, 2015
3b7bfa8
fix schema of AddJar
Apr 15, 2015
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
Next Next commit
fix hive tests
  • Loading branch information
Davies Liu committed Apr 2, 2015
commit 956b0a48bfccc6550f66319c4475220eb6101b23
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object Literal {
case f: Float => Literal(f, FloatType)
case b: Byte => Literal(b, ByteType)
case s: Short => Literal(s, ShortType)
case s: String => Literal(s, StringType)
case s: String => Literal(UTF8String(s), StringType)
case b: Boolean => Literal(b, BooleanType)
case d: BigDecimal => Literal(Decimal(d), DecimalType.Unlimited)
case d: java.math.BigDecimal => Literal(Decimal(d), DecimalType.Unlimited)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ object LikeSimplification extends Rule[LogicalPlan] {
case equalTo(pattern) =>
EqualTo(l, Literal(pattern))
case _ =>
Like(l, Literal(utf, StringType))
Like(l, Literal.create(utf, StringType))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ class ExpressionEvaluationSuite extends ExpressionEvaluationBaseSuite {
checkEvaluation(Sqrt(d), expected, row)
}

checkEvaluation(Sqrt(Literal.create(null, DoubleType)), null, new create_row(Array[Any](null)))
checkEvaluation(Sqrt(Literal.create(null, DoubleType)), null, create_row(Array[Any](null)))
checkEvaluation(Sqrt(-1), null, EmptyRow)
checkEvaluation(Sqrt(-1.5), null, EmptyRow)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import scala.collection.mutable.ArrayBuffer

import org.apache.hadoop.fs.Path

import org.apache.spark.sql.catalyst.expressions.Literal
import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.parquet.ParquetRelation2._
import org.apache.spark.sql.test.TestSQLContext
import org.apache.spark.sql.types._
Expand All @@ -40,6 +40,10 @@ class ParquetPartitionDiscoverySuite extends QueryTest with ParquetTest {

val defaultPartitionName = "__NULL__"

def create_row(values: Any*): Row = {
new GenericRow(values.map(Literal.convertToUTF8String).toArray)
}

test("column type inference") {
def check(raw: String, literal: Literal): Unit = {
assert(inferPartitionColumnValue(raw, defaultPartitionName) === literal)
Expand Down Expand Up @@ -107,7 +111,7 @@ class ParquetPartitionDiscoverySuite extends QueryTest with ParquetTest {
StructType(Seq(
StructField("a", IntegerType),
StructField("b", StringType))),
Seq(Partition(Row(10, "hello"), "hdfs://host:9000/path/a=10/b=hello"))))
Seq(Partition(create_row(10, "hello"), "hdfs://host:9000/path/a=10/b=hello"))))

check(Seq(
"hdfs://host:9000/path/a=10/b=20",
Expand All @@ -117,8 +121,8 @@ class ParquetPartitionDiscoverySuite extends QueryTest with ParquetTest {
StructField("a", FloatType),
StructField("b", StringType))),
Seq(
Partition(Row(10, "20"), "hdfs://host:9000/path/a=10/b=20"),
Partition(Row(10.5, "hello"), "hdfs://host:9000/path/a=10.5/b=hello"))))
Partition(create_row(10, "20"), "hdfs://host:9000/path/a=10/b=20"),
Partition(create_row(10.5, "hello"), "hdfs://host:9000/path/a=10.5/b=hello"))))

check(Seq(
s"hdfs://host:9000/path/a=10/b=20",
Expand All @@ -128,8 +132,8 @@ class ParquetPartitionDiscoverySuite extends QueryTest with ParquetTest {
StructField("a", IntegerType),
StructField("b", StringType))),
Seq(
Partition(Row(10, "20"), s"hdfs://host:9000/path/a=10/b=20"),
Partition(Row(null, "hello"), s"hdfs://host:9000/path/a=$defaultPartitionName/b=hello"))))
Partition(create_row(10, "20"), s"hdfs://host:9000/path/a=10/b=20"),
Partition(create_row(null, "hello"), s"hdfs://host:9000/path/a=$defaultPartitionName/b=hello"))))

check(Seq(
s"hdfs://host:9000/path/a=10/b=$defaultPartitionName",
Expand All @@ -139,8 +143,8 @@ class ParquetPartitionDiscoverySuite extends QueryTest with ParquetTest {
StructField("a", FloatType),
StructField("b", StringType))),
Seq(
Partition(Row(10, null), s"hdfs://host:9000/path/a=10/b=$defaultPartitionName"),
Partition(Row(10.5, null), s"hdfs://host:9000/path/a=10.5/b=$defaultPartitionName"))))
Partition(create_row(10, null), s"hdfs://host:9000/path/a=10/b=$defaultPartitionName"),
Partition(create_row(10.5, null), s"hdfs://host:9000/path/a=10.5/b=$defaultPartitionName"))))
}

test("read partitioned table - normal case") {
Expand All @@ -163,29 +167,29 @@ class ParquetPartitionDiscoverySuite extends QueryTest with ParquetTest {
i <- 1 to 10
pi <- Seq(1, 2)
ps <- Seq("foo", "bar")
} yield Row(i, i.toString, pi, ps))
} yield create_row(i, i.toString, pi, ps))

checkAnswer(
sql("SELECT intField, pi FROM t"),
for {
i <- 1 to 10
pi <- Seq(1, 2)
_ <- Seq("foo", "bar")
} yield Row(i, pi))
} yield create_row(i, pi))

checkAnswer(
sql("SELECT * FROM t WHERE pi = 1"),
for {
i <- 1 to 10
ps <- Seq("foo", "bar")
} yield Row(i, i.toString, 1, ps))
} yield create_row(i, i.toString, 1, ps))

checkAnswer(
sql("SELECT * FROM t WHERE ps = 'foo'"),
for {
i <- 1 to 10
pi <- Seq(1, 2)
} yield Row(i, i.toString, pi, "foo"))
} yield create_row(i, i.toString, pi, "foo"))
}
}
}
Expand All @@ -210,29 +214,29 @@ class ParquetPartitionDiscoverySuite extends QueryTest with ParquetTest {
i <- 1 to 10
pi <- Seq(1, 2)
ps <- Seq("foo", "bar")
} yield Row(i, pi, i.toString, ps))
} yield create_row(i, pi, i.toString, ps))

checkAnswer(
sql("SELECT intField, pi FROM t"),
for {
i <- 1 to 10
pi <- Seq(1, 2)
_ <- Seq("foo", "bar")
} yield Row(i, pi))
} yield create_row(i, pi))

checkAnswer(
sql("SELECT * FROM t WHERE pi = 1"),
for {
i <- 1 to 10
ps <- Seq("foo", "bar")
} yield Row(i, 1, i.toString, ps))
} yield create_row(i, 1, i.toString, ps))

checkAnswer(
sql("SELECT * FROM t WHERE ps = 'foo'"),
for {
i <- 1 to 10
pi <- Seq(1, 2)
} yield Row(i, pi, i.toString, "foo"))
} yield create_row(i, pi, i.toString, "foo"))
}
}
}
Expand Down Expand Up @@ -264,21 +268,21 @@ class ParquetPartitionDiscoverySuite extends QueryTest with ParquetTest {
i <- 1 to 10
pi <- Seq(1, null.asInstanceOf[Integer])
ps <- Seq("foo", null.asInstanceOf[String])
} yield Row(i, i.toString, pi, ps))
} yield create_row(i, i.toString, pi, ps))

checkAnswer(
sql("SELECT * FROM t WHERE pi IS NULL"),
for {
i <- 1 to 10
ps <- Seq("foo", null.asInstanceOf[String])
} yield Row(i, i.toString, null, ps))
} yield create_row(i, i.toString, null, ps))

checkAnswer(
sql("SELECT * FROM t WHERE ps IS NULL"),
for {
i <- 1 to 10
pi <- Seq(1, null.asInstanceOf[Integer])
} yield Row(i, i.toString, pi, null))
} yield create_row(i, i.toString, pi, null))
}
}
}
Expand Down Expand Up @@ -309,14 +313,14 @@ class ParquetPartitionDiscoverySuite extends QueryTest with ParquetTest {
i <- 1 to 10
pi <- Seq(1, 2)
ps <- Seq("foo", null.asInstanceOf[String])
} yield Row(i, pi, i.toString, ps))
} yield create_row(i, pi, i.toString, ps))

checkAnswer(
sql("SELECT * FROM t WHERE ps IS NULL"),
for {
i <- 1 to 10
pi <- Seq(1, 2)
} yield Row(i, pi, i.toString, null))
} yield create_row(i, pi, i.toString, null))
}
}
}
Expand All @@ -336,7 +340,7 @@ class ParquetPartitionDiscoverySuite extends QueryTest with ParquetTest {
withTempTable("t") {
checkAnswer(
sql("SELECT * FROM t"),
(1 to 10).map(i => Row(i, null, 1)) ++ (1 to 10).map(i => Row(i, i.toString, 2)))
(1 to 10).map(i => create_row(i, null, 1)) ++ (1 to 10).map(i => create_row(i, i.toString, 2)))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import org.apache.spark.sql.execution._
import org.apache.spark.sql.hive.execution._
import org.apache.spark.sql.parquet.ParquetRelation
import org.apache.spark.sql.sources.{CreateTableUsingAsSelect, CreateTableUsing}
import org.apache.spark.sql.types.StringType
import org.apache.spark.sql.types.{UTF8String, StringType}


private[hive] trait HiveStrategies {
Expand Down Expand Up @@ -131,7 +131,10 @@ private[hive] trait HiveStrategies {
val partitionValues = part.getValues
var i = 0
while (i < partitionValues.size()) {
inputData(i) = partitionValues(i)
inputData(i) = partitionValues(i) match {
case s: String => UTF8String(s)
case other => other
}
i += 1
}
pruningCondition(inputData)
Expand Down