Skip to content

Commit

Permalink
support udt->hive types (hive->udt is not supported)
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxr committed Nov 8, 2014
1 parent 5923dd9 commit 57c7519
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ object HiveMetastoreTypes extends RegexParsers {
case d: DecimalType => HiveShim.decimalMetastoreString(d)
case TimestampType => "timestamp"
case NullType => "void"
case udt: UserDefinedType[_] => toMetastoreType(udt.sqlType)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ package org.apache.spark.sql.hive

import org.scalatest.FunSuite

import org.apache.spark.sql.catalyst.types.{DataType, StructType}
import org.apache.spark.sql.catalyst.types.StructType
import org.apache.spark.sql.test.ExamplePointUDT

class HiveMetastoreCatalogSuite extends FunSuite {

Expand All @@ -29,4 +30,10 @@ class HiveMetastoreCatalogSuite extends FunSuite {
val datatype = HiveMetastoreTypes.toDataType(metastr)
assert(datatype.isInstanceOf[StructType])
}

test("udt to metastore type conversion") {
val udt = new ExamplePointUDT
assert(HiveMetastoreTypes.toMetastoreType(udt) ===
HiveMetastoreTypes.toMetastoreType(udt.sqlType))
}
}

0 comments on commit 57c7519

Please sign in to comment.