Java Code Examples for org.apache.phoenix.util.SchemaUtil#getColumnDisplayName()

The following examples show how to use org.apache.phoenix.util.SchemaUtil#getColumnDisplayName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableRef.java    From phoenix with Apache License 2.0 6 votes vote down vote up
public String getColumnDisplayName(ColumnRef ref, boolean cfCaseSensitive, boolean cqCaseSensitive) {
    String cf = null;
    String cq = null;       
    PColumn column = ref.getColumn();
    String name = column.getName().getString();
    boolean isIndex = table.getType() == PTableType.INDEX;
    if (table.getType() == PTableType.JOIN || table.getType() == PTableType.SUBQUERY) {
        cq = column.getName().getString();
    }
    else if (SchemaUtil.isPKColumn(column)) {
        cq = isIndex ? IndexUtil.getDataColumnName(name) : name;
    }
    else {
        String defaultFamilyName = table.getDefaultFamilyName() == null ? QueryConstants.DEFAULT_COLUMN_FAMILY : table.getDefaultFamilyName().getString();
        // Translate to the data table column name
        String dataFamilyName = isIndex ? IndexUtil.getDataColumnFamilyName(name) : column.getFamilyName().getString() ;
        cf = defaultFamilyName.equals(dataFamilyName) ? null : dataFamilyName;
        cq = isIndex ? IndexUtil.getDataColumnName(name) : name;
    }
    
    cf = (cf!=null && cfCaseSensitive) ? "\"" + cf + "\"" : cf;
    cq = cqCaseSensitive ? "\"" + cq + "\"" : cq;
    return SchemaUtil.getColumnDisplayName(cf, cq);
}
 
Example 2
Source File: TableRef.java    From phoenix with Apache License 2.0 6 votes vote down vote up
public String getColumnDisplayName(ColumnRef ref, boolean cfCaseSensitive, boolean cqCaseSensitive) {
    String cf = null;
    String cq = null;       
    PColumn column = ref.getColumn();
    String name = column.getName().getString();
    boolean isIndex = IndexUtil.isIndexColumn(name);
    if ((table.getType() == PTableType.PROJECTED && TupleProjectionCompiler.PROJECTED_TABLE_SCHEMA.equals(table.getSchemaName()))
            || table.getType() == PTableType.SUBQUERY) {
        cq = name;
    }
    else if (SchemaUtil.isPKColumn(column)) {
        cq = isIndex ? IndexUtil.getDataColumnName(name) : name;
    }
    else {
        String defaultFamilyName = table.getDefaultFamilyName() == null ? QueryConstants.DEFAULT_COLUMN_FAMILY : table.getDefaultFamilyName().getString();
        // Translate to the data table column name
        String dataFamilyName = isIndex ? IndexUtil.getDataColumnFamilyName(name) : column.getFamilyName().getString() ;
        cf = (table.getIndexType()==IndexType.LOCAL? IndexUtil.getActualColumnFamilyName(defaultFamilyName):defaultFamilyName).equals(dataFamilyName) ? null : dataFamilyName;
        cq = isIndex ? IndexUtil.getDataColumnName(name) : name;
    }
    
    cf = (cf!=null && cfCaseSensitive) ? "\"" + cf + "\"" : cf;
    cq = cqCaseSensitive ? "\"" + cq + "\"" : cq;
    return SchemaUtil.getColumnDisplayName(cf, cq);
}
 
Example 3
Source File: KeyValueColumnExpression.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    if (displayName == null) {
        displayName = SchemaUtil.getColumnDisplayName(cf, cq);
    }
    return displayName;
}
 
Example 4
Source File: LocalIndexDataColumnRef.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public ColumnExpression newColumnExpression(boolean schemaNameCaseSensitive, boolean colNameCaseSensitive) {
    PTable table = this.getTable();
    PColumn column = this.getColumn();
    // TODO: util for this or store in member variable
    byte[] defaultFamily = table.getDefaultFamilyName() == null ? QueryConstants.DEFAULT_COLUMN_FAMILY_BYTES : table.getDefaultFamilyName().getBytes();
    String displayName = SchemaUtil.getColumnDisplayName(Bytes.compareTo(defaultFamily, column.getFamilyName().getBytes()) == 0  ? null : column.getFamilyName().getBytes(), column.getName().getBytes());
    return new ProjectedColumnExpression(this.getColumn(), columns, position, displayName);
}
 
Example 5
Source File: KeyValueColumnExpression.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    if (displayName == null) {
        displayName = SchemaUtil.getColumnDisplayName(cf, cq);
    }
    return displayName;
}
 
Example 6
Source File: SingleCellColumnExpression.java    From phoenix with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    if (arrayColDisplayName == null) {
        arrayColDisplayName = SchemaUtil.getColumnDisplayName(getColumnFamily(), getColumnQualifier());
    }
    return arrayColDisplayName;
}