use of org.apache.drill.common.expression.FieldReference in project drill by apache.
the class UnnestRecordBatch method resetUnnestTransferPair.
private TransferPair resetUnnestTransferPair() {
List<TransferPair> transfers = Lists.newArrayList();
FieldReference fieldReference = new FieldReference(popConfig.getColumn());
TransferPair transferPair = getUnnestFieldTransferPair(fieldReference);
transfers.add(transferPair);
logger.debug("Added transfer for unnest expression.");
unnest.close();
try {
unnest.setup(context, incoming, this, transfers);
} catch (SchemaChangeException e) {
throw schemaChangeException(e, logger);
}
setUnnestVector();
return transferPair;
}
use of org.apache.drill.common.expression.FieldReference in project drill by apache.
the class DrillWindowRel method implement.
@Override
public LogicalOperator implement(DrillImplementor implementor) {
final LogicalOperator inputOp = implementor.visitChild(this, 0, getInput());
org.apache.drill.common.logical.data.Window.Builder builder = new org.apache.drill.common.logical.data.Window.Builder();
final List<String> fields = getRowType().getFieldNames();
final List<String> childFields = getInput().getRowType().getFieldNames();
for (Group window : groups) {
for (RelFieldCollation orderKey : window.orderKeys.getFieldCollations()) {
builder.addOrdering(new Order.Ordering(orderKey.getDirection(), new FieldReference(fields.get(orderKey.getFieldIndex()))));
}
for (int group : BitSets.toIter(window.keys)) {
FieldReference fr = new FieldReference(childFields.get(group), ExpressionPosition.UNKNOWN);
builder.addWithin(fr, fr);
}
int groupCardinality = window.keys.cardinality();
for (Ord<AggregateCall> aggCall : Ord.zip(window.getAggregateCalls(this))) {
FieldReference ref = new FieldReference(fields.get(groupCardinality + aggCall.i));
LogicalExpression expr = toDrill(aggCall.e, childFields);
builder.addAggregation(ref, expr);
}
}
builder.setInput(inputOp);
org.apache.drill.common.logical.data.Window frame = builder.build();
return frame;
}
use of org.apache.drill.common.expression.FieldReference in project drill by apache.
the class HashPrelUtil method getHashExpression.
/**
* Create a distribution hash expression.
*
* @param fields Distribution fields
* @param rowType Row type
* @return distribution hash expression
*/
public static LogicalExpression getHashExpression(List<DistributionField> fields, RelDataType rowType) {
assert fields.size() > 0;
List<String> childFields = rowType.getFieldNames();
// If we already included a field with hash - no need to calculate hash further down
if (childFields.contains(HASH_EXPR_NAME)) {
return new FieldReference(HASH_EXPR_NAME);
}
List<LogicalExpression> expressions = new ArrayList<>();
for (DistributionField field : fields) {
if (field instanceof NamedDistributionField) {
NamedDistributionField namedDistributionField = (NamedDistributionField) field;
expressions.add(new FieldReference(namedDistributionField.getFieldName(), ExpressionPosition.UNKNOWN));
} else {
expressions.add(new FieldReference(childFields.get(field.getFieldId()), ExpressionPosition.UNKNOWN));
}
}
LogicalExpression distSeed = ValueExpressions.getInt(DIST_SEED);
return createHashBasedPartitionExpression(expressions, distSeed, HASH_HELPER_LOGICAL_EXPRESSION);
}
use of org.apache.drill.common.expression.FieldReference in project drill by apache.
the class InfoSchemaFilterBuilder method visitCastExpression.
@Override
public ExprNode visitCastExpression(CastExpression e, Void value) throws RuntimeException {
if (e.getInput() instanceof FieldReference) {
FieldReference fieldRef = (FieldReference) e.getInput();
String field = fieldRef.getRootSegmentPath().toUpperCase();
if (field.equals(CATS_COL_CATALOG_NAME) || field.equals(SCHS_COL_SCHEMA_NAME) || field.equals(SHRD_COL_TABLE_NAME) || field.equals(SHRD_COL_TABLE_SCHEMA) || field.equals(COLS_COL_COLUMN_NAME) || field.equals(FILES_COL_ROOT_SCHEMA_NAME) || field.equals(FILES_COL_WORKSPACE_NAME)) {
return new FieldExprNode(field);
}
}
return visitUnknown(e, value);
}
Aggregations