private MultiTableColumnResolver(PhoenixConnection connection, int tsAddition) { super(connection, tsAddition, null); tableMap = ArrayListMultimap.<String, TableRef> create(); tables = Lists.newArrayList(); try { connectionSchemaName = connection.getSchema(); } catch (SQLException e) { // ignore } }
public SchemaResolver(PhoenixConnection conn, String schemaName, boolean updateCacheImmediately) throws SQLException { super(conn, 0, null); schemaName = connection.getSchema() != null && schemaName == null ? connection.getSchema() : schemaName; schemas = ImmutableList.of(createSchemaRef(schemaName, updateCacheImmediately)); }
public MutationState dropTable(DropTableStatement statement) throws SQLException { String schemaName = connection.getSchema() != null && statement.getTableName().getSchemaName() == null ? connection.getSchema() : statement.getTableName().getSchemaName(); String tableName = statement.getTableName().getTableName(); return dropTable(schemaName, tableName, null, statement.getTableType(), statement.ifExists(), statement.cascade(), statement.getSkipAddingParentColumns()); }
public QueryLogger createQueryLogger(CompilableStatement stmt, String sql) throws SQLException { boolean isSystemTable=false; if(stmt instanceof ExecutableSelectStatement){ TableNode from = ((ExecutableSelectStatement)stmt).getFrom(); if(from instanceof NamedTableNode){ String schemaName = ((NamedTableNode)from).getName().getSchemaName(); if(schemaName==null){ schemaName=connection.getSchema(); } if(PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA.equals(schemaName)){ isSystemTable=true; } } } QueryLogger queryLogger = QueryLogger.getInstance(connection,isSystemTable); QueryLoggerUtil.logInitialDetails(queryLogger, connection.getTenantId(), connection.getQueryServices(), sql, getParameters()); return queryLogger; }
public MutationState dropSequence(DropSequenceStatement statement) throws SQLException { Long scn = connection.getSCN(); long timestamp = scn == null ? HConstants.LATEST_TIMESTAMP : scn; String schemaName = connection.getSchema() != null && statement.getSequenceName().getSchemaName() == null ? connection.getSchema() : statement.getSequenceName().getSchemaName(); String sequenceName = statement.getSequenceName().getTableName(); String tenantId = connection.getTenantId() == null ? null : connection.getTenantId().getString(); try { connection.getQueryServices().dropSequence(tenantId, schemaName, sequenceName, timestamp); } catch (SequenceNotFoundException e) { if (statement.ifExists()) { return new MutationState(0, 0, connection); } throw e; } return new MutationState(1, 1000, connection); }
public MutationState createSequence(CreateSequenceStatement statement, long startWith, long incrementBy, long cacheSize, long minValue, long maxValue) throws SQLException { Long scn = connection.getSCN(); long timestamp = scn == null ? HConstants.LATEST_TIMESTAMP : scn; String tenantId = connection.getTenantId() == null ? null : connection.getTenantId().getString(); String schemaName=statement.getSequenceName().getSchemaName(); if (SchemaUtil.isNamespaceMappingEnabled(null, connection.getQueryServices().getProps())) { if (schemaName == null || schemaName.equals(StringUtil.EMPTY_STRING)) { schemaName = connection.getSchema(); } if (schemaName != null) { FromCompiler.getResolverForSchema(schemaName, connection); } } return createSequence(tenantId, schemaName, statement .getSequenceName().getTableName(), statement.ifNotExists(), startWith, incrementBy, cacheSize, statement.getCycle(), minValue, maxValue, timestamp); }
private MultiTableColumnResolver(PhoenixConnection connection, int tsAddition) { super(connection, tsAddition, null); tableMap = ArrayListMultimap.<String, TableRef> create(); tables = Lists.newArrayList(); try { connectionSchemaName = connection.getSchema(); } catch (SQLException e) { // ignore } }
public static void upgradeTable(PhoenixConnection conn, String srcTable) throws SQLException, SnapshotCreationException, IllegalArgumentException, IOException, InterruptedException { ReadOnlyProps readOnlyProps = conn.getQueryServices().getProps(); if (conn.getSchema() != null) { throw new IllegalArgumentException( "Schema should not be set for connection!!"); } if (!SchemaUtil.isNamespaceMappingEnabled(PTableType.TABLE,
private MultiTableColumnResolver(PhoenixConnection connection, int tsAddition) { super(connection, tsAddition, null); tableMap = ArrayListMultimap.<String, TableRef> create(); tables = Lists.newArrayList(); try { connectionSchemaName = connection.getSchema(); } catch (SQLException e) { // ignore } }
protected PSchema createSchemaRef(String schemaName, boolean updateCacheImmediately) throws SQLException { long timeStamp = QueryConstants.UNSET_TIMESTAMP; PSchema theSchema = null; MetaDataClient client = new MetaDataClient(connection); if (updateCacheImmediately) { MetaDataMutationResult result = client.updateCache(schemaName, true); timeStamp = TransactionUtil.getResolvedTimestamp(connection, result); theSchema = result.getSchema(); if (theSchema == null) { throw new SchemaNotFoundException(schemaName, timeStamp); } } else { try { theSchema = connection.getSchema(new PTableKey(null, schemaName)); } catch (SchemaNotFoundException e1) {} // We always attempt to update the cache in the event of a // SchemaNotFoundException if (theSchema == null) { MetaDataMutationResult result = client.updateCache(schemaName, true); if (result.wasUpdated()) { timeStamp = TransactionUtil.getResolvedTimestamp(connection, result); theSchema = result.getSchema(); } } if (theSchema == null) { throw new SchemaNotFoundException(schemaName, timeStamp); } } return theSchema; }
String tableName = tableNode.getName().getTableName(); String schemaName = tableNode.getName().getSchemaName(); schemaName = connection.getSchema() != null && schemaName == null ? connection.getSchema() : schemaName; long timeStamp = QueryConstants.UNSET_TIMESTAMP; String fullTableName = SchemaUtil.getTableName(schemaName, tableName);
public SchemaResolver(PhoenixConnection conn, String schemaName, boolean updateCacheImmediately) throws SQLException { super(conn, 0, null); schemaName = connection.getSchema() != null && schemaName == null ? connection.getSchema() : schemaName; schemas = ImmutableList.of(createSchemaRef(schemaName, updateCacheImmediately)); }
public SchemaResolver(PhoenixConnection conn, String schemaName, boolean updateCacheImmediately) throws SQLException { super(conn, 0, null); schemaName = connection.getSchema() != null && schemaName == null ? connection.getSchema() : schemaName; schemas = ImmutableList.of(createSchemaRef(schemaName, updateCacheImmediately)); }
public MutationState dropTable(DropTableStatement statement) throws SQLException { String schemaName = connection.getSchema() != null && statement.getTableName().getSchemaName() == null ? connection.getSchema() : statement.getTableName().getSchemaName(); String tableName = statement.getTableName().getTableName(); return dropTable(schemaName, tableName, null, statement.getTableType(), statement.ifExists(), statement.cascade()); }
public MutationState dropTable(DropTableStatement statement) throws SQLException { String schemaName = connection.getSchema() != null && statement.getTableName().getSchemaName() == null ? connection.getSchema() : statement.getTableName().getSchemaName(); String tableName = statement.getTableName().getTableName(); return dropTable(schemaName, tableName, null, statement.getTableType(), statement.ifExists(), statement.cascade(), statement.getSkipAddingParentColumns()); }
public MutationState dropSequence(DropSequenceStatement statement) throws SQLException { Long scn = connection.getSCN(); long timestamp = scn == null ? HConstants.LATEST_TIMESTAMP : scn; String schemaName = connection.getSchema() != null && statement.getSequenceName().getSchemaName() == null ? connection.getSchema() : statement.getSequenceName().getSchemaName(); String sequenceName = statement.getSequenceName().getTableName(); String tenantId = connection.getTenantId() == null ? null : connection.getTenantId().getString(); try { connection.getQueryServices().dropSequence(tenantId, schemaName, sequenceName, timestamp); } catch (SequenceNotFoundException e) { if (statement.ifExists()) { return new MutationState(0, 0, connection); } throw e; } return new MutationState(1, 1000, connection); }