Skip to content

Commit 66adceb

Browse files
committed
Merge pull request #6 from marmbrus/joinWork
Minor changes to get more tests passing.
2 parents 61b266f + a43d41c commit 66adceb

File tree

6 files changed

+19
-5
lines changed

6 files changed

+19
-5
lines changed

src/main/scala/catalyst/execution/MetastoreCatalog.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,15 @@ class HiveMetastoreCatalog(hiveConf: HiveConf) extends Catalog {
7777
}
7878

7979
object HiveMetatoreTypes {
80+
val VARCHAR = "(?i)VARCHAR\\((\\d+)\\)".r
8081
def toDataType(metastoreType: String): DataType =
8182
metastoreType match {
8283
case "string" => StringType
8384
case "int" => IntegerType
8485
case "double" => DoubleType
8586
case "bigint" => LongType
87+
case "binary" => BinaryType
88+
case VARCHAR(_) => StringType
8689
}
8790
}
8891

src/main/scala/catalyst/execution/hiveOperators.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ case class HiveTableScan(attributes: Seq[Attribute], relation: MetastoreRelation
6868
buildRow(values.map {
6969
case "NULL" => null
7070
case "null" => null
71+
case varchar: org.apache.hadoop.hive.common.`type`.HiveVarchar => varchar.getValue
7172
case other => other
7273
})
7374
}

src/main/scala/catalyst/frontend/Hive.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ object HiveQl {
615615
/* Casts */
616616
case Token("TOK_FUNCTION", Token("TOK_STRING", Nil) :: arg :: Nil) => Cast(nodeToExpr(arg), StringType)
617617
case Token("TOK_FUNCTION", Token("TOK_INT", Nil) :: arg :: Nil) => Cast(nodeToExpr(arg), IntegerType)
618+
case Token("TOK_FUNCTION", Token("TOK_BIGINT", Nil) :: arg :: Nil) => Cast(nodeToExpr(arg), LongType)
618619
case Token("TOK_FUNCTION", Token("TOK_FLOAT", Nil) :: arg :: Nil) => Cast(nodeToExpr(arg), FloatType)
619620
case Token("TOK_FUNCTION", Token("TOK_DOUBLE", Nil) :: arg :: Nil) => Cast(nodeToExpr(arg), DoubleType)
620621
case Token("TOK_FUNCTION", Token("TOK_SMALLINT", Nil) :: arg :: Nil) => Cast(nodeToExpr(arg), ShortType)
@@ -628,6 +629,7 @@ object HiveQl {
628629
case Token("*", left :: right:: Nil) => Multiply(nodeToExpr(left), nodeToExpr(right))
629630
case Token("/", left :: right:: Nil) => Divide(nodeToExpr(left), nodeToExpr(right))
630631
case Token("DIV", left :: right:: Nil) => Divide(nodeToExpr(left), nodeToExpr(right))
632+
case Token("%", left :: right:: Nil) => Remainder(nodeToExpr(left), nodeToExpr(right))
631633

632634
/* Comparisons */
633635
case Token("=", left :: right:: Nil) => Equals(nodeToExpr(left), nodeToExpr(right))

src/test/scala/catalyst/execution/HiveComparisionTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ abstract class HiveComaparisionTest extends FunSuite with BeforeAndAfterAll with
5858
str.replaceAll("file:\\/.*\\/", "<PATH>")
5959
}
6060

61-
val installHooksCommand = "SET.*hooks".r
61+
val installHooksCommand = "(?i)SET.*hooks".r
6262
def createQueryTest(testCaseName: String, sql: String) = {
6363
test(testCaseName) {
6464
logger.error(

src/test/scala/catalyst/execution/HiveCompatability.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,12 @@ class HiveCompatability extends HiveQueryFileTest {
188188
"literal_string",
189189
"load_file_with_space_in_the_name",
190190
"mapjoin_subquery2",
191+
"mapreduce3",
191192
"mergejoins",
192193
"mergejoins_mixed",
193194
"misc_json",
194195
"multi_join_union",
195196
"multigroupby_singlemr",
196-
"no_hooks",
197197
"noalias_subq1",
198198
"nomore_ambiguous_table_col",
199199
"notable_alias1",
@@ -301,6 +301,7 @@ class HiveCompatability extends HiveQueryFileTest {
301301
"udf_minute",
302302
"udf_modulo",
303303
"udf_month",
304+
"udf_negative",
304305
"udf_not",
305306
"udf_notequal",
306307
"udf_nvl",
@@ -374,6 +375,9 @@ class HiveCompatability extends HiveQueryFileTest {
374375
"union7",
375376
"union8",
376377
"union9",
377-
"union_script"
378+
"union_script",
379+
"varchar_2",
380+
"varchar_join1",
381+
"varchar_union1"
378382
)
379383
}

src/test/scala/catalyst/execution/HiveQueryFileTest.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ abstract class HiveQueryFileTest extends HiveComaparisionTest {
2525

2626
val runAll = !(System.getProperty("shark.hive.alltests") == null)
2727

28+
val whiteListProperty = "shark.hive.whitelist"
2829
// Allow the whiteList to be overridden by a system property
29-
val realWhiteList = Option(System.getProperty("shark.hive.whitelist")).map(_.split(",").toSeq).getOrElse(whiteList)
30+
val realWhiteList = Option(System.getProperty(whiteListProperty)).map(_.split(",").toSeq).getOrElse(whiteList)
3031

3132
// Go through all the test cases and add them to scala test.
3233
testCases.foreach {
@@ -38,7 +39,10 @@ abstract class HiveQueryFileTest extends HiveComaparisionTest {
3839
val queriesString = fileToString(testCaseFile)
3940
createQueryTest(testCaseName, queriesString)
4041
} else {
41-
ignore(testCaseName) {}
42+
// Only output warnings for the built in whitelist as this clutters the output when the user
43+
// trying to execute a single test from the commandline.
44+
if(System.getProperty(whiteListProperty) == null)
45+
ignore(testCaseName) {}
4246
}
4347
}
4448
}

0 commit comments

Comments
 (0)