/** * Returns the column info for the given column for the given table. * * @param table * @param columnName User-specified column name. May be family-qualified or bare. * @return columnInfo associated with the column in the table * @throws SQLException if parameters are null or if column is not found or if column is ambiguous. */ public static ColumnInfo getColumnInfo(PTable table, String columnName) throws SQLException { if (table==null) { throw new SQLException("Table must not be null."); } if (columnName==null) { throw new SQLException("columnName must not be null."); } PColumn pColumn = null; if (columnName.contains(QueryConstants.NAME_SEPARATOR)) { String[] tokens = columnName.split(QueryConstants.NAME_SEPARATOR_REGEX); if (tokens.length!=2) { throw new SQLException(String.format("Unable to process column %s, expected family-qualified name.",columnName)); } String familyName = tokens[0]; String familyColumn = tokens[1]; PColumnFamily family = table.getColumnFamily(familyName); pColumn = family.getPColumnForColumnName(familyColumn); } else { pColumn = table.getColumnForColumnName(columnName); } return getColumnInfo(pColumn); }
public static PColumn getDataColumnOrNull(PTable dataTable, String indexColumnName) { int pos = indexColumnName.indexOf(INDEX_COLUMN_NAME_SEP); if (pos < 0) { return null; } if (pos == 0) { try { return dataTable.getPKColumn(indexColumnName.substring(1)); } catch (ColumnNotFoundException e) { return null; } } PColumnFamily family; try { family = dataTable.getColumnFamily(getDataColumnFamilyName(indexColumnName)); } catch (ColumnFamilyNotFoundException e) { return null; } try { return family.getPColumnForColumnName(indexColumnName.substring(pos+1)); } catch (ColumnNotFoundException e) { return null; } }
@Deprecated private static PColumn getPColumn(PTable table, @Nullable String familyName, String columnName) throws SQLException { if (table==null) { throw new SQLException("Table must not be null."); } if (columnName==null) { throw new SQLException("columnName must not be null."); } // normalize and remove quotes from family and column names before looking up. familyName = SchemaUtil.normalizeIdentifier(familyName); columnName = SchemaUtil.normalizeIdentifier(columnName); PColumn pColumn = null; if (familyName != null) { PColumnFamily family = table.getColumnFamily(familyName); pColumn = family.getPColumnForColumnName(columnName); } else { pColumn = table.getColumnForColumnName(columnName); } return pColumn; }
public ColumnRef(TableRef tableRef, String familyName, String columnName) throws MetaDataEntityNotFoundException { this(tableRef, tableRef.getTable().getColumnFamily(familyName).getPColumnForColumnName(columnName).getPosition()); }
private static PColumn getColumn(PTable table, @Nullable String familyName, String columnName) throws SQLException { if (table==null) { throw new SQLException("Table must not be null."); } if (columnName==null) { throw new SQLException("columnName must not be null."); } // normalize and remove quotes from family and column names before looking up. familyName = SchemaUtil.normalizeIdentifier(familyName); columnName = SchemaUtil.normalizeIdentifier(columnName); // Column names are always for the data table, so we must translate them if // we're dealing with an index table. if (table.getType() == PTableType.INDEX) { columnName = IndexUtil.getIndexColumnName(familyName, columnName); } PColumn pColumn = null; if (familyName != null) { PColumnFamily family = table.getColumnFamily(familyName); pColumn = family.getPColumnForColumnName(columnName); } else { pColumn = table.getColumnForColumnName(columnName); } return pColumn; }
@Override public ColumnRef resolveColumn(String schemaName, String tableName, String colName) throws SQLException { TableRef tableRef = tableRefs.get(0); boolean resolveCF = false; 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) )) { if (!(resolveCF = schemaName.equals(alias))) { throw new ColumnNotFoundException(schemaName, tableName, null, colName); } } } else { // schemaName == null && tableName != null if (tableName != null && !tableName.equals(alias) && (!tableName.equals(resolvedTableName) || !resolvedSchemaName.equals(""))) { resolveCF = true; } } } PColumn column = resolveCF ? tableRef.getTable().getColumnFamily(tableName).getPColumnForColumnName(colName) : tableRef.getTable().getColumnForColumnName(colName); return new ColumnRef(tableRef, column.getPosition()); }
@Override public ColumnRef resolveColumn(String schemaName, String tableName, String colName) throws SQLException { PColumn column = tableName != null ? tableRef.getTable().getColumnFamily(tableName).getPColumnForColumnName(colName) : tableRef.getTable().getColumnForColumnName(colName); return new ColumnRef(tableRef, column.getPosition()); }
theColumn = theColumnFamily.getPColumnForColumnName(colName); } catch (MetaDataEntityNotFoundException e2) { try { PColumnFamily columnFamily = tableRef.getTable().getColumnFamily(tableName); PColumn column = columnFamily.getPColumnForColumnName(colName); if (theColumn != null) { throw new AmbiguousColumnException(colName);
column = table.getPKColumn(columnToRemove.getName().getString()); } else { column = table.getColumnFamily(familyName).getPColumnForColumnName(columnToRemove.getName().getString());
String columnName = columnInfo.getSecond(); boolean hasNoColumnFamilies = table.getColumnFamilies().isEmpty(); PColumn column = hasNoColumnFamilies ? table.getColumnForColumnName(columnName) : table.getColumnFamily(familyName).getPColumnForColumnName(columnName); if(!projectedColumns.contains(column)) { projectedColumns.add(column);
columnFamily == null ? view.getColumnForColumnName(columnName) : view.getColumnFamily(columnFamily) .getPColumnForColumnName(columnName); } catch (ColumnFamilyNotFoundException e) {
public static String findExistingColumn(PTable table, List<PColumn> columns) { for (PColumn column : columns) { PName familyName = column.getFamilyName(); if (familyName == null) { try { return table.getPKColumn(column.getName().getString()).getName().getString(); } catch (ColumnNotFoundException e) { continue; } } else { try { return table.getColumnFamily(familyName.getString()).getPColumnForColumnName(column.getName().getString()).getName().getString(); } catch (ColumnFamilyNotFoundException e) { continue; // Shouldn't happen } catch (ColumnNotFoundException e) { continue; } } } return null; }
String dataColumnName = IndexUtil.getDataColumnName(indexColumnName); try { PColumn dataColumn = dataFamilyName.equals("") ? dataTable.getColumnForColumnName(dataColumnName) : dataTable.getColumnFamily(dataFamilyName).getPColumnForColumnName(dataColumnName); if (SchemaUtil.isPKColumn(dataColumn)) continue;
resolvedTable.getColumnFamily(column.getFamilyName().getString()).getPColumnForColumnName( column.getName().getString());
view.getColumnForColumnName(colName); } else { view.getColumnFamily(colFamily).getPColumnForColumnName(colName); String colName = col.getName().getString(); if (cf != null) { indexCol = parentTable.getColumnFamily(cf).getPColumnForColumnName(colName);
existingViewColumn = columnFamily == null ? view.getColumnForColumnName(columnName) : view .getColumnFamily(columnFamily).getPColumnForColumnName(columnName); } catch (ColumnFamilyNotFoundException e) {
try { PColumnFamily columnFamily = table.getColumnFamily(familyName); columnFamily.getPColumnForColumnName(columnName); if (!ifNotExists) { throw new ColumnAlreadyExistsException(schemaName, tableName, columnName);
public ColumnRef(TableRef tableRef, String familyName, String columnName) throws MetaDataEntityNotFoundException { this(tableRef, tableRef.getTable().getColumnFamily(familyName).getPColumnForColumnName(columnName).getPosition()); }
public ColumnRef(TableRef tableRef, String familyName, String columnName) throws MetaDataEntityNotFoundException { this(tableRef, tableRef.getTable().getColumnFamily(familyName).getPColumnForColumnName(columnName).getPosition()); }
@Override public ColumnRef resolveColumn(String schemaName, String tableName, String colName) throws SQLException { PColumn column = tableName != null ? tableRef.getTable().getColumnFamily(tableName).getPColumnForColumnName(colName) : tableRef.getTable().getColumnForColumnName(colName); return new ColumnRef(tableRef, column.getPosition()); }