Java Code Examples for org.apache.phoenix.schema.PColumn#getExpressionStr()
The following examples show how to use
org.apache.phoenix.schema.PColumn#getExpressionStr() .
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: FromCompiler.java From phoenix with Apache License 2.0 | 6 votes |
public static ColumnResolver getResolverForCompiledDerivedTable(PhoenixConnection connection, TableRef tableRef, RowProjector projector) throws SQLException { List<PColumn> projectedColumns = new ArrayList<PColumn>(); List<Expression> sourceExpressions = new ArrayList<Expression>(); PTable table = tableRef.getTable(); for (PColumn column : table.getColumns()) { Expression sourceExpression = projector.getColumnProjector(column.getPosition()).getExpression(); PColumnImpl projectedColumn = new PColumnImpl(column.getName(), column.getFamilyName(), sourceExpression.getDataType(), sourceExpression.getMaxLength(), sourceExpression.getScale(), sourceExpression.isNullable(), column.getPosition(), sourceExpression.getSortOrder(), column.getArraySize(), column.getViewConstant(), column.isViewReferenced(), column.getExpressionStr()); projectedColumns.add(projectedColumn); sourceExpressions.add(sourceExpression); } PTable t = PTableImpl.makePTable(table, projectedColumns); return new SingleTableColumnResolver(connection, new TableRef(tableRef.getTableAlias(), t, tableRef.getLowerBoundTimeStamp(), tableRef.hasDynamicCols())); }
Example 2
Source File: JoinCompiler.java From phoenix with Apache License 2.0 | 6 votes |
public ProjectedPTableWrapper createProjectedTable(RowProjector rowProjector) throws SQLException { assert(isSubselect()); List<PColumn> projectedColumns = new ArrayList<PColumn>(); List<Expression> sourceExpressions = new ArrayList<Expression>(); ListMultimap<String, String> columnNameMap = ArrayListMultimap.<String, String>create(); PTable table = tableRef.getTable(); for (PColumn column : table.getColumns()) { String colName = getProjectedColumnName(null, tableRef.getTableAlias(), column.getName().getString()); Expression sourceExpression = rowProjector.getColumnProjector(column.getPosition()).getExpression(); PColumnImpl projectedColumn = new PColumnImpl(PNameFactory.newName(colName), PNameFactory.newName(TupleProjector.VALUE_COLUMN_FAMILY), sourceExpression.getDataType(), sourceExpression.getMaxLength(), sourceExpression.getScale(), sourceExpression.isNullable(), column.getPosition(), sourceExpression.getSortOrder(), column.getArraySize(), column.getViewConstant(), column.isViewReferenced(), column.getExpressionStr()); projectedColumns.add(projectedColumn); sourceExpressions.add(sourceExpression); } PTable t = PTableImpl.makePTable(table.getTenantId(), PNameFactory.newName(PROJECTED_TABLE_SCHEMA), table.getName(), PTableType.JOIN, table.getIndexState(), table.getTimeStamp(), table.getSequenceNumber(), table.getPKName(), null, projectedColumns, table.getParentSchemaName(), table.getParentTableName(), table.getIndexes(), table.isImmutableRows(), Collections.<PName>emptyList(), null, null, table.isWALDisabled(), table.isMultiTenant(), table.getStoreNulls(), table.getViewType(), table.getViewIndexId(), table.getIndexType()); return new ProjectedPTableWrapper(t, columnNameMap, sourceExpressions); }
Example 3
Source File: FromCompiler.java From phoenix with Apache License 2.0 | 6 votes |
public static ColumnResolver getResolverForCompiledDerivedTable(PhoenixConnection connection, TableRef tableRef, RowProjector projector) throws SQLException { List<PColumn> projectedColumns = new ArrayList<PColumn>(); PTable table = tableRef.getTable(); for (PColumn column : table.getColumns()) { Expression sourceExpression = projector.getColumnProjector(column.getPosition()).getExpression(); PColumnImpl projectedColumn = new PColumnImpl(column.getName(), column.getFamilyName(), sourceExpression.getDataType(), sourceExpression.getMaxLength(), sourceExpression.getScale(), sourceExpression.isNullable(), column.getPosition(), sourceExpression.getSortOrder(), column.getArraySize(), column.getViewConstant(), column.isViewReferenced(), column.getExpressionStr(), column.isRowTimestamp(), column.isDynamic(), column.getColumnQualifierBytes(), column.getTimestamp()); projectedColumns.add(projectedColumn); } PTable t = PTableImpl.builderWithColumns(table, projectedColumns) .build(); return new SingleTableColumnResolver(connection, new TableRef(tableRef.getTableAlias(), t, tableRef.getLowerBoundTimeStamp(), tableRef.hasDynamicCols())); }
Example 4
Source File: JoinCompiler.java From phoenix with Apache License 2.0 | 5 votes |
private void addProjectedColumn(List<PColumn> projectedColumns, List<Expression> sourceExpressions, ListMultimap<String, String> columnNameMap, PColumn sourceColumn, PName familyName, boolean hasSaltingColumn, boolean isLocalIndexColumnRef, StatementContext context) throws SQLException { if (sourceColumn == SALTING_COLUMN) return; int position = projectedColumns.size() + (hasSaltingColumn ? 1 : 0); PTable table = tableRef.getTable(); String schemaName = table.getSchemaName().getString(); String tableName = table.getTableName().getString(); String colName = isLocalIndexColumnRef ? IndexUtil.getIndexColumnName(sourceColumn) : sourceColumn.getName().getString(); String fullName = getProjectedColumnName(schemaName, tableName, colName); String aliasedName = tableRef.getTableAlias() == null ? fullName : getProjectedColumnName(null, tableRef.getTableAlias(), colName); columnNameMap.put(colName, aliasedName); if (!fullName.equals(aliasedName)) { columnNameMap.put(fullName, aliasedName); } PName name = PNameFactory.newName(aliasedName); PColumnImpl column = new PColumnImpl(name, familyName, sourceColumn.getDataType(), sourceColumn.getMaxLength(), sourceColumn.getScale(), sourceColumn.isNullable(), position, sourceColumn.getSortOrder(), sourceColumn.getArraySize(), sourceColumn.getViewConstant(), sourceColumn.isViewReferenced(), sourceColumn.getExpressionStr()); Expression sourceExpression = isLocalIndexColumnRef ? NODE_FACTORY.column(TableName.create(schemaName, tableName), "\"" + colName + "\"", null).accept(new ExpressionCompiler(context)) : new ColumnRef(tableRef, sourceColumn.getPosition()).newColumnExpression(); projectedColumns.add(column); sourceExpressions.add(sourceExpression); }
Example 5
Source File: IndexUtil.java From phoenix with Apache License 2.0 | 5 votes |
public static PColumn getIndexPKColumn(int position, PColumn dataColumn) { assert (SchemaUtil.isPKColumn(dataColumn)); PName indexColumnName = PNameFactory.newName(getIndexColumnName(null, dataColumn.getName().getString())); PColumn column = new PColumnImpl(indexColumnName, null, dataColumn.getDataType(), dataColumn.getMaxLength(), dataColumn.getScale(), dataColumn.isNullable(), position, dataColumn.getSortOrder(), dataColumn.getArraySize(), null, false, dataColumn.getExpressionStr(), dataColumn.isRowTimestamp(), false, // TODO set the columnQualifierBytes correctly /*columnQualifierBytes*/null, HConstants.LATEST_TIMESTAMP); return column; }
Example 6
Source File: IndexUtil.java From phoenix with Apache License 2.0 | 4 votes |
public static String getIndexColumnExpressionStr(PColumn col) { return col.getExpressionStr() == null ? IndexUtil.getCaseSensitiveDataColumnFullName(col.getName().getString()) : col.getExpressionStr(); }
Example 7
Source File: IndexUtil.java From phoenix with Apache License 2.0 | 4 votes |
public static String getIndexColumnExpressionStr(PColumn col) { return col.getExpressionStr() == null ? IndexUtil.getCaseSensitiveDataColumnFullName(col.getName().getString()) : col.getExpressionStr(); }