0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 package org.apache.hive.service.cli.operation;
0020
0021 import org.apache.hadoop.hive.ql.security.authorization.plugin.HiveOperationType;
0022 import org.apache.hive.service.cli.FetchOrientation;
0023 import org.apache.hive.service.cli.HiveSQLException;
0024 import org.apache.hive.service.cli.OperationState;
0025 import org.apache.hive.service.cli.OperationType;
0026 import org.apache.hive.service.cli.RowSet;
0027 import org.apache.hive.service.cli.RowSetFactory;
0028 import org.apache.hive.service.cli.TableSchema;
0029 import org.apache.hive.service.cli.session.HiveSession;
0030
0031
0032
0033
0034
0035 public class GetCatalogsOperation extends MetadataOperation {
0036 private static final TableSchema RESULT_SET_SCHEMA = new TableSchema()
0037 .addStringColumn("TABLE_CAT", "Catalog name. NULL if not applicable.");
0038
0039 protected final RowSet rowSet;
0040
0041 protected GetCatalogsOperation(HiveSession parentSession) {
0042 super(parentSession, OperationType.GET_CATALOGS);
0043 rowSet = RowSetFactory.create(RESULT_SET_SCHEMA, getProtocolVersion(), false);
0044 }
0045
0046 @Override
0047 public void runInternal() throws HiveSQLException {
0048 setState(OperationState.RUNNING);
0049 try {
0050 if (isAuthV2Enabled()) {
0051 authorizeMetaGets(HiveOperationType.GET_CATALOGS, null);
0052 }
0053 setState(OperationState.FINISHED);
0054 } catch (HiveSQLException e) {
0055 setState(OperationState.ERROR);
0056 throw e;
0057 }
0058
0059 }
0060
0061
0062
0063
0064 @Override
0065 public TableSchema getResultSetSchema() throws HiveSQLException {
0066 return RESULT_SET_SCHEMA;
0067 }
0068
0069
0070
0071
0072 @Override
0073 public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException {
0074 assertState(OperationState.FINISHED);
0075 validateDefaultFetchOrientation(orientation);
0076 if (orientation.equals(FetchOrientation.FETCH_FIRST)) {
0077 rowSet.setStartOffset(0);
0078 }
0079 return rowSet.extractSubset((int)maxRows);
0080 }
0081 }