@Override public PName getSchemaName() { return delegate.getSchemaName(); }
public SingleTableColumnResolver(TableRef tableRef) throws SQLException { super(null, 0, null); alias = tableRef.getTableAlias(); tableRefs = ImmutableList.of(tableRef); schemas = ImmutableList.of(new PSchema(tableRef.getTable().getSchemaName().toString())); }
public SingleTableColumnResolver(PhoenixConnection connection, TableRef tableRef) { super(connection, 0, null); alias = tableRef.getTableAlias(); tableRefs = ImmutableList.of(tableRef); schemas = ImmutableList.of(new PSchema(tableRef.getTable().getSchemaName().toString())); }
public SingleTableColumnResolver(PhoenixConnection connection, TableRef tableRef, Map<String, UDFParseNode> udfParseNodes, TableName mutatingTableName) throws SQLException { super(connection, 0, false, udfParseNodes, mutatingTableName); alias = tableRef.getTableAlias(); tableRefs = ImmutableList.of(tableRef); schemas = ImmutableList.of(new PSchema(tableRef.getTable().getSchemaName().toString())); }
public static boolean isMetaTable(PTable table) { return PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA.equals(table.getSchemaName().getString()) && PhoenixDatabaseMetaData.SYSTEM_CATALOG_TABLE.equals(table.getTableName().getString()); }
public SingleTableColumnResolver(PhoenixConnection connection, NamedTableNode tableNode, boolean updateCacheImmediately, int tsAddition, Map<String, UDFParseNode> udfParseNodes, boolean alwaysHitServer, TableName mutatingTableName) throws SQLException { super(connection, tsAddition, updateCacheImmediately, udfParseNodes, mutatingTableName); alias = tableNode.getAlias(); TableRef tableRef = createTableRef(tableNode.getName().getSchemaName(), tableNode, updateCacheImmediately, alwaysHitServer); PSchema schema = new PSchema(tableRef.getTable().getSchemaName().toString()); tableRefs = ImmutableList.of(tableRef); schemas = ImmutableList.of(schema); }
private static void syncUpdateCacheFreqForIndexesOfTable(PTable baseTable, PreparedStatement stmt) throws SQLException { for (PTable index : baseTable.getIndexes()) { if (index.getUpdateCacheFrequency() == baseTable.getUpdateCacheFrequency()) { continue; } stmt.setString(2, index.getSchemaName().getString()); stmt.setString(3, index.getTableName().getString()); stmt.setLong(4, baseTable.getUpdateCacheFrequency()); stmt.addBatch(); } }
@Override public TableRef resolveTable(String schemaName, String tableName) throws SQLException { TableRef tableRef = tableRefs.get(0); /* * The only case we can definitely verify is when both a schemaName and a tableName * are provided. Otherwise, the tableName might be a column family. In this case, * this will be validated by resolveColumn. */ if (schemaName != null || tableName != null) { String resolvedTableName = tableRef.getTable().getTableName().getString(); String resolvedSchemaName = tableRef.getTable().getSchemaName().getString(); if (schemaName != null && tableName != null) { if ( ! ( schemaName.equals(resolvedSchemaName) && tableName.equals(resolvedTableName) ) && ! schemaName.equals(alias) ) { throw new TableNotFoundException(schemaName, tableName); } } } return tableRef; }
public String getQualifiedDataTableName() { return SchemaUtil.getQualifiedTableName(pdataTable.getSchemaName().getString(), pdataTable.getTableName().getString()); }
public String getQualifiedIndexTableName() { return SchemaUtil.getQualifiedTableName(pindexTable.getSchemaName().getString(), pindexTable.getTableName().getString()); }
private TableName getReplacedTableName(TableRef tableRef) { String schemaName = tableRef.getTable().getSchemaName().getString(); return TableName.create(schemaName.length() == 0 ? null : schemaName, tableRef.getTable().getTableName().getString()); }
private String getFullTableName(TableRef dataTableRef) { String schemaName = dataTableRef.getTable().getSchemaName().getString(); String tableName = dataTableRef.getTable().getTableName().getString(); String fullName = schemaName == null ? ("\"" + tableName + "\"") : ("\"" + schemaName + "\"" + QueryConstants.NAME_SEPARATOR + "\"" + tableName + "\""); return fullName; }
public static byte[] getTableKey(PTable dataTable) { PName tenantId = dataTable.getTenantId(); PName schemaName = dataTable.getSchemaName(); return getTableKey(tenantId == null ? ByteUtil.EMPTY_BYTE_ARRAY : tenantId.getBytes(), schemaName == null ? ByteUtil.EMPTY_BYTE_ARRAY : schemaName.getBytes(), dataTable.getTableName().getBytes()); }
public SharedTableState(PTable table) { this.tenantId = table.getTenantId(); this.schemaName = table.getSchemaName(); this.tableName = table.getTableName(); this.columns = table.getColumns(); this.physicalNames = table.getPhysicalNames(); this.viewIndexIdType = table.getviewIndexIdType(); this.viewIndexId = table.getViewIndexId(); }
private TableName getReplacedTableName(TableRef origRef) { // if the setTableAlias flag is true and the original table has an alias we use that as the table name if (setTableAlias && origRef.getTableAlias() != null) return TableName.create(null, origRef.getTableAlias()); if (multiTableRewriteMap == null) return null; TableRef tableRef = multiTableRewriteMap.get(origRef); if (tableRef == null) return null; if (origRef.getTableAlias() != null) return TableName.create(null, origRef.getTableAlias()); String schemaName = tableRef.getTable().getSchemaName().getString(); return TableName.create(schemaName.length() == 0 ? null : schemaName, tableRef.getTable().getTableName().getString()); }
private TableName getParentPhysicalTableName(PTable table) { return table .getType() == PTableType.VIEW ? TableName.valueOf(table.getPhysicalName().getBytes()) : table.getType() == PTableType.INDEX ? TableName .valueOf(SchemaUtil .getPhysicalHBaseTableName(table.getParentSchemaName(), table.getParentTableName(), table.isNamespaceMapped()) .getBytes()) : TableName .valueOf( SchemaUtil .getPhysicalHBaseTableName(table.getSchemaName(), table.getTableName(), table.isNamespaceMapped()) .getBytes()); } }
@Override public void commitDDLFence(PTable dataTable) throws SQLException { try { tx = (HBaseTransaction) tm.fence(dataTable.getName().getBytes()); if (logger.isInfoEnabled()) { logger.info("Added write fence at ~" + tx.getReadTimestamp()); } } catch (TransactionException e) { throw new SQLExceptionInfo.Builder( SQLExceptionCode.TX_UNABLE_TO_GET_WRITE_FENCE) .setSchemaName(dataTable.getSchemaName().getString()) .setTableName(dataTable.getTableName().getString()).build() .buildException(); } }
private PTable getTable(PName tenantId, String fullTableName, long timestamp) throws SQLException { PTable table; try { PMetaData metadata = latestMetaData; throwConnectionClosedIfNullMetaData(); table = metadata.getTableRef(new PTableKey(tenantId, fullTableName)).getTable(); if (table.getTimeStamp() >= timestamp) { // Table in cache is newer than client timestamp which shouldn't be // the case throw new TableNotFoundException(table.getSchemaName().getString(), table.getTableName().getString()); } } catch (TableNotFoundException e) { byte[] schemaName = Bytes.toBytes(SchemaUtil.getSchemaNameFromFullName(fullTableName)); byte[] tableName = Bytes.toBytes(SchemaUtil.getTableNameFromFullName(fullTableName)); MetaDataMutationResult result = this.getTable(tenantId, schemaName, tableName, HConstants.LATEST_TIMESTAMP, timestamp, false, false, null); table = result.getTable(); if (table == null) { throw e; } } return table; }
public LocalIndexDataColumnRef(StatementContext context, TableRef tRef, String indexColumnName) throws MetaDataEntityNotFoundException, SQLException { super(FromCompiler.getResolver( FACTORY.namedTable( null, TableName.create(tRef.getTable().getSchemaName().getString(), tRef.getTable() .getParentTableName().getString())), context.getConnection(), false) .resolveTable(context.getCurrentTable().getTable().getSchemaName().getString(), tRef.getTable().getParentTableName().getString()), IndexUtil.getDataColumnFamilyName(indexColumnName), IndexUtil .getDataColumnName(indexColumnName)); position = context.getDataColumnPosition(this.getColumn()); columns = context.getDataColumns(); }
public long getCurrentTime() throws SQLException { long ts = this.getCurrentTable().getCurrentTime(); // if the table is transactional then it is only resolved once per query, so we can't use the table timestamp if (this.getCurrentTable().getTable().getType() != PTableType.PROJECTED && !this .getCurrentTable().getTable().isTransactional() && ts != QueryConstants .UNSET_TIMESTAMP) { return ts; } if (currentTime != QueryConstants.UNSET_TIMESTAMP) { return currentTime; } /* * For an UPSERT VALUES where autocommit off, we won't hit the server until the commit. * However, if the statement has a CURRENT_DATE() call as a value, we need to know the * current time at execution time. In that case, we'll call MetaDataClient.updateCache * purely to bind the current time based on the server time. */ PTable table = this.getCurrentTable().getTable(); PhoenixConnection connection = getConnection(); MetaDataClient client = new MetaDataClient(connection); currentTime = client.getCurrentTime(table.getSchemaName().getString(), table.getTableName().getString()); return currentTime; }