Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove ThrifserverShimUtils's toJavaSQLType
  • Loading branch information
AngersZhuuuu committed Sep 5, 2019
commit 2ec85656d955adc7c07d615e5aa2f758819b30fd
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import scala.collection.JavaConverters.seqAsJavaListConverter

import org.apache.hadoop.hive.ql.security.authorization.plugin.{HiveOperationType, HivePrivilegeObject}
import org.apache.hadoop.hive.ql.security.authorization.plugin.HivePrivilegeObject.HivePrivilegeObjectType
import org.apache.hive.service.cli._
import org.apache.hive.service.cli.{CLIServiceUtils, HiveSQLException, OperationState}
import org.apache.hive.service.cli.operation.GetColumnsOperation
import org.apache.hive.service.cli.session.HiveSession

import org.apache.spark.internal.Logging
import org.apache.spark.sql.SQLContext
import org.apache.spark.sql.catalyst.TableIdentifier
import org.apache.spark.sql.catalyst.catalog.SessionCatalog
import org.apache.spark.sql.hive.thriftserver.ThriftserverShimUtils.toJavaSQLType
import org.apache.spark.sql.hive.thriftserver.cli.Type
import org.apache.spark.sql.types.StructType
import org.apache.spark.util.{Utils => SparkUtils}

Expand Down Expand Up @@ -151,7 +151,7 @@ private[hive] class SparkGetColumnsOperation(
dbName, // TABLE_SCHEM
tableName, // TABLE_NAME
column.name, // COLUMN_NAME
toJavaSQLType(column.dataType.sql).asInstanceOf[AnyRef], // DATA_TYPE
Type.getType(column.dataType.sql).asInstanceOf[AnyRef], // DATA_TYPE
column.dataType.sql, // TYPE_NAME
null, // COLUMN_SIZE
null, // BUFFER_LENGTH, unused
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ object Type {
def types: Seq[Type] =
Seq(NULL,
STRING,
INT,
INTEGER,
BOOLEAN,
DOUBLE,
FLOAT,
Expand All @@ -177,6 +177,19 @@ object Type {
TIMESTAMP,
BINARY)

def getType(name: String): Type = {
val typeForName: Option[Type] = types.find(_.getName == name)
if (typeForName.isDefined) {
typeForName.get
} else {
if (Array("ARRAY", "STRUCT", "MAP", "USERDEFINED").contains(name)) {
STRING
} else {
throw new IllegalArgumentException("Unrecognized type name: " + name)
}
}
}

case object NULL extends Type() {
override def getName: String = "NULL"

Expand Down Expand Up @@ -207,7 +220,7 @@ object Type {
override def isCaseSensitive: Boolean = true
}

case object INT extends Type {
case object INTEGER extends Type {
override def getName: String = "INT"

override def isComplex: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ private[thriftserver] object ThriftserverShimUtils {
RowSetFactory.create(getResultSetSchema, getProtocolVersion)
}

private[thriftserver] def toJavaSQLType(s: String): Int = Type.getType(s).toJavaSQLType

private[thriftserver] def addToClassPath(
loader: ClassLoader,
auxJars: Array[String]): ClassLoader = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ private[thriftserver] object ThriftserverShimUtils {
RowSetFactory.create(getResultSetSchema, getProtocolVersion, false)
}

private[thriftserver] def toJavaSQLType(s: String): Int = Type.getType(s).toJavaSQLType

private[thriftserver] def addToClassPath(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: empty line between functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add it .

loader: ClassLoader,
auxJars: Array[String]): ClassLoader = {
Expand Down