public GetSchemasOperation newGetSchemasOperation(HiveSession parentSession, String catalogName, String schemaName) { GetSchemasOperation operation = new GetSchemasOperation(parentSession, catalogName, schemaName); addOperation(operation); return operation; }
@Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); validateDefaultFetchOrientation(orientation); if (orientation.equals(FetchOrientation.FETCH_FIRST)) { rowSet.setStartOffset(0); } return rowSet.extractSubset((int)maxRows); } }
@Override public void runInternal() throws HiveSQLException { setState(OperationState.RUNNING); LOG.info("Fetching schema metadata"); if (isAuthV2Enabled()) { String cmdStr = "catalog : " + catalogName + ", schemaPattern : " + schemaName; authorizeMetaGets(HiveOperationType.GET_SCHEMAS, null, cmdStr); } try { IMetaStoreClient metastoreClient = getParentSession().getMetaStoreClient(); String schemaPattern = convertSchemaPattern(schemaName); for (String dbName : metastoreClient.getDatabases(schemaPattern)) { rowSet.addRow(new Object[] {dbName, DEFAULT_HIVE_CATALOG}); if (LOG.isDebugEnabled()) { String debugMessage = getDebugMessage("schema", RESULT_SET_SCHEMA); LOG.debug(debugMessage, dbName, DEFAULT_HIVE_CATALOG); } } if (LOG.isDebugEnabled() && rowSet.numRows() == 0) { LOG.debug("No schema metadata has been returned."); } setState(OperationState.FINISHED); LOG.info("Fetching schema metadata has been successfully finished"); } catch (Exception e) { setState(OperationState.ERROR); throw new HiveSQLException(e); } }
@Override public OperationHandle getSchemas(String catalogName, String schemaName) throws HiveSQLException { acquire(true, true); OperationManager operationManager = getOperationManager(); GetSchemasOperation operation = operationManager.newGetSchemasOperation(getSession(), catalogName, schemaName); OperationHandle opHandle = operation.getHandle(); try { addOpHandle(opHandle); operation.run(); return opHandle; } catch (HiveSQLException e) { removeOpHandle(opHandle); operationManager.closeOperation(opHandle); throw e; } finally { release(true, true); } }
protected GetSchemasOperation(HiveSession parentSession, String catalogName, String schemaName) { super(parentSession, OperationType.GET_SCHEMAS); this.catalogName = catalogName; this.schemaName = schemaName; this.rowSet = RowSetFactory.create(RESULT_SET_SCHEMA, getProtocolVersion(), false); LOG.info( "Starting GetSchemasOperation with the following parameters: catalogName={}, schemaName={}", catalogName, schemaName); }
@Override public TableSchema getResultSetSchema() throws HiveSQLException { assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); return RESULT_SET_SCHEMA; }
@Override public OperationHandle getSchemas(String catalogName, String schemaName) throws HiveSQLException { acquire(true); OperationManager operationManager = getOperationManager(); GetSchemasOperation operation = operationManager.newGetSchemasOperation(getSession(), catalogName, schemaName); OperationHandle opHandle = operation.getHandle(); try { operation.run(); opHandleSet.add(opHandle); return opHandle; } catch (HiveSQLException e) { operationManager.closeOperation(opHandle); throw e; } finally { release(true); } }
protected GetSchemasOperation(HiveSession parentSession, String catalogName, String schemaName) { super(parentSession, OperationType.GET_SCHEMAS); this.catalogName = catalogName; this.schemaName = schemaName; this.rowSet = RowSetFactory.create(RESULT_SET_SCHEMA, getProtocolVersion()); }
@Override public TableSchema getResultSetSchema() throws HiveSQLException { assertState(OperationState.FINISHED); return RESULT_SET_SCHEMA; }
@Override public void runInternal() throws HiveSQLException { setState(OperationState.RUNNING); if (isAuthV2Enabled()) { String cmdStr = "catalog : " + catalogName + ", schemaPattern : " + schemaName; authorizeMetaGets(HiveOperationType.GET_SCHEMAS, null, cmdStr); } try { IMetaStoreClient metastoreClient = getParentSession().getMetaStoreClient(); String schemaPattern = convertSchemaPattern(schemaName); for (String dbName : metastoreClient.getDatabases(schemaPattern)) { rowSet.addRow(new Object[] {dbName, DEFAULT_HIVE_CATALOG}); } setState(OperationState.FINISHED); } catch (Exception e) { setState(OperationState.ERROR); throw new HiveSQLException(e); } }
@Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { assertState(new ArrayList<OperationState>(Arrays.asList(OperationState.FINISHED))); validateDefaultFetchOrientation(orientation); if (orientation.equals(FetchOrientation.FETCH_FIRST)) { rowSet.setStartOffset(0); } return rowSet.extractSubset((int)maxRows); } }
@Override public OperationHandle getSchemas(String catalogName, String schemaName) throws HiveSQLException { acquire(true); OperationManager operationManager = getOperationManager(); GetSchemasOperation operation = operationManager.newGetSchemasOperation(getSession(), catalogName, schemaName); OperationHandle opHandle = operation.getHandle(); try { operation.run(); opHandleSet.add(opHandle); return opHandle; } catch (HiveSQLException e) { operationManager.closeOperation(opHandle); throw e; } finally { release(true); } }
protected GetSchemasOperation(HiveSession parentSession, String catalogName, String schemaName) { super(parentSession, OperationType.GET_SCHEMAS); this.catalogName = catalogName; this.schemaName = schemaName; this.rowSet = RowSetFactory.create(RESULT_SET_SCHEMA, getProtocolVersion()); }
public GetSchemasOperation newGetSchemasOperation(HiveSession parentSession, String catalogName, String schemaName) { GetSchemasOperation operation = new GetSchemasOperation(parentSession, catalogName, schemaName); addOperation(operation); return operation; }
@Override public TableSchema getResultSetSchema() throws HiveSQLException { assertState(OperationState.FINISHED); return RESULT_SET_SCHEMA; }
@Override public void runInternal() throws HiveSQLException { setState(OperationState.RUNNING); if (isAuthV2Enabled()) { String cmdStr = "catalog : " + catalogName + ", schemaPattern : " + schemaName; authorizeMetaGets(HiveOperationType.GET_SCHEMAS, null, cmdStr); } try { IMetaStoreClient metastoreClient = getParentSession().getMetaStoreClient(); String schemaPattern = convertSchemaPattern(schemaName); for (String dbName : metastoreClient.getDatabases(schemaPattern)) { rowSet.addRow(new Object[] {dbName, DEFAULT_HIVE_CATALOG}); } setState(OperationState.FINISHED); } catch (Exception e) { setState(OperationState.ERROR); throw new HiveSQLException(e); } }
@Override public RowSet getNextRowSet(FetchOrientation orientation, long maxRows) throws HiveSQLException { assertState(OperationState.FINISHED); validateDefaultFetchOrientation(orientation); if (orientation.equals(FetchOrientation.FETCH_FIRST)) { rowSet.setStartOffset(0); } return rowSet.extractSubset((int)maxRows); } }
@Override public OperationHandle getSchemas(String catalogName, String schemaName) throws HiveSQLException { acquire(true); OperationManager operationManager = getOperationManager(); GetSchemasOperation operation = operationManager.newGetSchemasOperation(getSession(), catalogName, schemaName); OperationHandle opHandle = operation.getHandle(); try { operation.run(); opHandleSet.add(opHandle); return opHandle; } catch (HiveSQLException e) { operationManager.closeOperation(opHandle); throw e; } finally { release(true); } }
protected GetSchemasOperation(HiveSession parentSession, String catalogName, String schemaName) { super(parentSession, OperationType.GET_SCHEMAS); this.catalogName = catalogName; this.schemaName = schemaName; this.rowSet = RowSetFactory.create(RESULT_SET_SCHEMA, getProtocolVersion(), false); }
public GetSchemasOperation newGetSchemasOperation(HiveSession parentSession, String catalogName, String schemaName) { GetSchemasOperation operation = new GetSchemasOperation(parentSession, catalogName, schemaName); addOperation(operation); return operation; }