public String getTableName() { return tableName == null ? null : tableName.getTableName(); }
private TableRef resolveTable(String alias, TableName name) throws SQLException { if (alias != null) return resolver.resolveTable(null, alias); return resolver.resolveTable(name.getSchemaName(), name.getTableName()); }
private TableRef resolveTable(String alias, TableName name) throws SQLException { if (alias != null) return origResolver.resolveTable(null, alias); return origResolver.resolveTable(name.getSchemaName(), name.getTableName()); }
private void validateNodeIsStateless(CreateSequenceStatement sequence, ParseNode node, SQLExceptionCode code) throws SQLException { if (!node.isStateless()) { TableName sequenceName = sequence.getSequenceName(); throw SequenceUtil.getException(sequenceName.getSchemaName(), sequenceName.getTableName(), code); } }
if (resolver == null) { if (this.tableName != null) { tableName = this.tableName.getTableName();
public MutationState dropIndex(DropIndexStatement statement) throws SQLException { String schemaName = statement.getTableName().getSchemaName(); String tableName = statement.getIndexName().getName(); String parentTableName = statement.getTableName().getTableName(); return dropTable(schemaName, tableName, parentTableName, PTableType.INDEX, statement.ifExists(), false, false); }
@Override public ParseNode visit(TableWildcardParseNode node) throws SQLException { TableName tName = getReplacedTableName(getResolver().resolveTable(node.getTableName().getSchemaName(), node.getTableName().getTableName())); return tName == null ? node : TableWildcardParseNode.create(tName, true); }
private boolean isWildCardSelectForTable(List<AliasedNode> select, TableRef tableRef, ColumnResolver resolver) throws SQLException { ColumnRefParseNodeVisitor visitor = new ColumnRefParseNodeVisitor(resolver, statement.getConnection()); for (AliasedNode aliasedNode : select) { ParseNode node = aliasedNode.getNode(); if (node instanceof TableWildcardParseNode) { TableName tableName = ((TableWildcardParseNode) node).getTableName(); if (tableRef.equals(resolver.resolveTable(tableName.getSchemaName(), tableName.getTableName()))) { return true; } } } return false; }
@Override public Expression visit(SequenceValueParseNode node) throws SQLException { // NEXT VALUE FOR is only supported in SELECT expressions and UPSERT VALUES throw new SQLExceptionInfo.Builder(SQLExceptionCode.INVALID_USE_OF_NEXT_VALUE_FOR) .setSchemaName(node.getTableName().getSchemaName()) .setTableName(node.getTableName().getTableName()).build().buildException(); }
TableName tableName = node.getTableName(); if (tableName.getSchemaName() == null && statement.getConnection().getSchema() != null) { tableName = TableName.create(statement.getConnection().getSchema(), tableName.getTableName()); SequenceKey key = new SequenceKey(tenantId, tableName.getSchemaName(), tableName.getTableName(), nSaltBuckets); SequenceValueExpression expression = sequenceMap.get(key); if (expression == null) {
private long evalExpression(CreateSequenceStatement sequence, StatementContext context, Expression expression, SQLExceptionCode code) throws SQLException { ImmutableBytesWritable ptr = context.getTempPtr(); expression.evaluate(null, ptr); if (ptr.getLength() == 0 || !expression.getDataType().isCoercibleTo(PLong.INSTANCE)) { TableName sequenceName = sequence.getSequenceName(); throw SequenceUtil.getException(sequenceName.getSchemaName(), sequenceName.getTableName(), code); } return (Long) PLong.INSTANCE.toObject(ptr, expression.getDataType()); }
expression.evaluate(null, ptr); if (ptr.getLength() == 0 || !expression.getDataType().isCoercibleTo(PLong.INSTANCE)) { throw SequenceUtil.getException(sequenceName.getSchemaName(), sequenceName.getTableName(), SQLExceptionCode.NUM_SEQ_TO_ALLOCATE_MUST_BE_CONSTANT); throw SequenceUtil.getException(sequenceName.getSchemaName(), sequenceName.getTableName(), SQLExceptionCode.NUM_SEQ_TO_ALLOCATE_MUST_BE_CONSTANT);
@Override public Expression visit(SequenceValueParseNode node) throws SQLException { if (aggregateFunction != null) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.INVALID_USE_OF_NEXT_VALUE_FOR) .setSchemaName(node.getTableName().getSchemaName()) .setTableName(node.getTableName().getTableName()).build().buildException(); } return context.getSequenceManager().newSequenceReference(node); }
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()); }
String tableName = table.getName().getTableName(); PName name = PNameFactory.newName(SchemaUtil.getTableName(schema, tableName)); PTable theTable = new PTableImpl.Builder()
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); }
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); }
protected TableRef createTableRef(String connectionSchemaName, NamedTableNode tableNode, boolean updateCacheImmediately, boolean alwaysHitServer) throws SQLException { String tableName = tableNode.getName().getTableName(); String schemaName = tableNode.getName().getSchemaName(); schemaName = connection.getSchema() != null && schemaName == null ? connection.getSchema() : schemaName;
.setSchemaName(tableName.getSchemaName()).setTableName(tableName.getTableName()) .build().buildException(); if (statement.immutableRows()!=null && immutableProp!=null) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.IMMUTABLE_TABLE_PROPERTY_INVALID) .setSchemaName(tableName.getSchemaName()).setTableName(tableName.getTableName()) .build().buildException(); MetaDataMutationResult result = updateCache(tableName.getSchemaName(), tableName.getTableName()); if (result.getMutationCode()==MutationCode.TABLE_ALREADY_EXISTS) { table = result.getTable(); if (!statement.ifNotExists()) { throw new NewerTableAlreadyExistsException(tableName.getSchemaName(), tableName.getTableName(), table);
boolean isNamespaceMapped = SchemaUtil.isNamespaceMappingEnabled(statement.getTableType(), connection.getQueryServices().getProps()); byte[] fullTableName = SchemaUtil.getPhysicalHBaseTableName( baseTable.getSchemaName(), baseTable.getTableName(), isNamespaceMapped).getBytes(); Table htable = null; try {