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
Make RowSet protected
  • Loading branch information
wangyum committed Jan 3, 2019
commit ecc4e0d0d4d7b16157d7dad27e4e59f9a081b477
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class GetSchemasOperation extends MetadataOperation {
.addStringColumn("TABLE_SCHEM", "Schema name.")
.addStringColumn("TABLE_CATALOG", "Catalog name.");

private RowSet rowSet;
protected RowSet rowSet;
Copy link
Member

@HyukjinKwon HyukjinKwon Jan 3, 2019

Choose a reason for hiding this comment

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

Hm ........ but I noticed here is o.a.hive side code, @gatorsmile. Wouldn't it be better to avoid some changes here to prepare to get rid of Hive stuff later completely?

Copy link
Member

@gatorsmile gatorsmile Jan 7, 2019

Choose a reason for hiding this comment

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

We do not have a plan to remove the thrift-server and use the Hive jar. Instead, I think we need to enhance the current thrift-server implementation.

Copy link
Member

@HyukjinKwon HyukjinKwon Jan 8, 2019

Choose a reason for hiding this comment

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

I actually meant getting rid of Hive fork stuff by upgrading Hive to another version later. Those changes would be some conflicts when upgrading from 1.2.1 to upper Hive versions basically.

Considering it's one line change, okie. I already see some changes are made there. Ok to me.

Copy link
Member

Choose a reason for hiding this comment

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

7feeb82 shows we want to further cleanup and improve the thrift-server. Even if https://issues.apache.org/jira/browse/HIVE-16391 is resolved, we will still keep the Hive thrift-server.


protected GetSchemasOperation(HiveSession parentSession,
String catalogName, String schemaName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ package org.apache.spark.sql.hive.thriftserver
import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType
import org.apache.hive.service.cli._
import org.apache.hive.service.cli.operation.GetSchemasOperation
import org.apache.hive.service.cli.operation.MetadataOperation.DEFAULT_HIVE_CATALOG
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.catalog.SessionCatalog

/**
* Spark's own GetSchemasOperation
Expand All @@ -39,15 +38,7 @@ private[hive] class SparkGetSchemasOperation(
parentSession: HiveSession,
catalogName: String,
schemaName: String)
extends GetSchemasOperation(parentSession, catalogName, schemaName) with Logging {

val catalog: SessionCatalog = sqlContext.sessionState.catalog

private final val RESULT_SET_SCHEMA = new TableSchema()
.addStringColumn("TABLE_SCHEM", "Schema name.")
.addStringColumn("TABLE_CATALOG", "Catalog name.")

private val rowSet = RowSetFactory.create(RESULT_SET_SCHEMA, getProtocolVersion)
extends GetSchemasOperation(parentSession, catalogName, schemaName) {

override def runInternal(): Unit = {
setState(OperationState.RUNNING)
Expand All @@ -61,8 +52,9 @@ private[hive] class SparkGetSchemasOperation(
}

try {
catalog.listDatabases(convertSchemaPattern(schemaName)).foreach { dbName =>
rowSet.addRow(Array[AnyRef](dbName, ""))
val schemaPattern = convertSchemaPattern(schemaName)
sqlContext.sessionState.catalog.listDatabases(schemaPattern).foreach { dbName =>
rowSet.addRow(Array[AnyRef](dbName, DEFAULT_HIVE_CATALOG))
}
setState(OperationState.FINISHED)
} catch {
Expand All @@ -71,14 +63,4 @@ private[hive] class SparkGetSchemasOperation(
throw e
}
}

override def getNextRowSet(orientation: FetchOrientation, maxRows: Long): RowSet = {
assertState(OperationState.FINISHED)
validateDefaultFetchOrientation(orientation)
setHasResultSet(true)
if (orientation.equals(FetchOrientation.FETCH_FIRST)) {
rowSet.setStartOffset(0)
}
rowSet.extractSubset(maxRows.toInt)
}
}