/** * Create a {@link FieldReference} given an unquoted name. (Note: the * name here is a misnomer: the name may have been quoted in SQL, but * must be unquoted when passed in here.) * * @param safeString the unquoted field reference * @return the field reference expression */ public static FieldReference getWithQuotedRef(CharSequence safeString) { return new FieldReference(safeString, ExpressionPosition.UNKNOWN, false); }
private void checkData() { if (getRootSegment().getChild() != null) { throw new UnsupportedOperationException("Field references must be singular names."); } }
public FieldReference(SchemaPath sp) { super(sp); checkData(); }
final FieldReference ref = new FieldReference(name); final ValueVector vvOut = container.addOrGet(MaterializedField.create(ref.getAsNamePart().getName(), vvIn.getField().getType()), callBack); final TransferPair tp = vvIn.makeTransferPair(vvOut); final String outputName = getRef(namedExpression).getRootSegment().getPath(); //moved to before the if addToResultMaps(outputName, result, true); String outputName = getRef(namedExpression).getRootSegment().getPath(); if (result != null && result.outputNames != null && result.outputNames.size() > 0) { boolean isMatched = false; container.addOrGet(MaterializedField.create(ref.getLastSegment().getNameSegment().getPath(), vectorRead.getMajorType()), callBack); final TransferPair tp = vvIn.makeTransferPair(vvOut);
final IntHashSet transferFieldIds = new IntHashSet(); final NamedExpression flattenExpr = new NamedExpression(popConfig.getColumn(), new FieldReference(popConfig.getColumn())); final ValueVectorReadExpression vectorRead = (ValueVectorReadExpression)ExpressionTreeMaterializer.materialize(flattenExpr.getExpr(), incoming, collector, context.getFunctionRegistry(), true); final FieldReference fieldReference = flattenExpr.getRef(); final MaterializedField outputField = MaterializedField.create(fieldReference.getAsNamePart().getName(), Types.OPTIONAL_INT); final ValueVector vector = TypeHelper.getNewVector(outputField, oContext.getAllocator()); result.clear(); String outputName = getRef(namedExpression).getRootSegment().getPath(); if (result != null && result.outputNames != null && result.outputNames.size() > 0) { for (int j = 0; j < result.outputNames.size(); j++) {
int i = 0; FieldReference ref = new FieldReference("dummy", ExpressionPosition.UNKNOWN, valueFieldIds.get(0).getIntermediateType()); for (TypedFieldId id : valueFieldIds) { materializedValueFields[i++] = MaterializedField.create(ref.getAsNamePart().getName(), id.getIntermediateType());
@Override public void setup(OperatorContext context, OutputMutator output) throws ExecutionSetupException { MaterializedField field = MaterializedField.create(ref.getAsNamePart().getName(), Types.repeated(TypeProtos.MinorType.VARCHAR)); try { vector = output.addField(field, RepeatedVarCharVector.class); } catch (Exception e) { handleAndRaise("Failure in setting up reader", e); } }
@Override public LogicalExpression visitInputRef(RexInputRef inputRef) { final int index = inputRef.getIndex(); final RelDataTypeField field = fieldList.get(index); return FieldReference.getWithQuotedRef(field.getName()); }
final MaterializedField outputField = MaterializedField.create(ne.getRef().getLastSegment().getNameSegment().getPath(), expr.getMajorType()); @SuppressWarnings("resource") MaterializedField field = MaterializedField.create(ne.getRef().getAsNamePart().getName(), UntypedNullHolder.TYPE); container.add(new UntypedNullVector(field, container.getAllocator())); valueExprs[i] = expr; } else { final MaterializedField outputField = MaterializedField.create(ne.getRef().getLastSegment().getNameSegment().getPath(), expr.getMajorType()); @SuppressWarnings("resource")
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof JsonTableRangePartitionFunction) { JsonTableRangePartitionFunction rpf = (JsonTableRangePartitionFunction) obj; List<FieldReference> thisPartRefList = this.getPartitionRefList(); List<FieldReference> otherPartRefList = rpf.getPartitionRefList(); if (thisPartRefList.size() != otherPartRefList.size()) { return false; } for (int refIdx = 0; refIdx < thisPartRefList.size(); refIdx++) { if (!thisPartRefList.get(refIdx).equals(otherPartRefList.get(refIdx))) { return false; } } return true; } return false; }
@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); }
final MaterializedField outputField = MaterializedField.create(ne.getRef().getLastSegment().getNameSegment().getPath(), expr.getMajorType()); @SuppressWarnings("resource")
@Override boolean materialize(final NamedExpression ne, final VectorContainer batch, FunctionLookupContext registry) throws SchemaChangeException { final MaterializedField outputField = MaterializedField.create(ne.getRef().getAsNamePart().getName(), getMajorType()); batch.addOrGet(outputField).allocateNew(); fieldId = batch.getValueVectorId(ne.getRef()); return true; }
public static Map<LogicalExpression, Integer> getExprsFromRowType( RelDataType indexScanRowType) { Map<LogicalExpression, Integer> rowTypeExprs = Maps.newLinkedHashMap(); int idx = 0; for (RelDataTypeField field : indexScanRowType.getFieldList()) { rowTypeExprs.put(FieldReference.getWithQuotedRef(field.getName()), idx++); } return rowTypeExprs; }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj instanceof JsonTableRangePartitionFunction) { JsonTableRangePartitionFunction rpf = (JsonTableRangePartitionFunction) obj; List<FieldReference> thisPartRefList = this.getPartitionRefList(); List<FieldReference> otherPartRefList = rpf.getPartitionRefList(); if (thisPartRefList.size() != otherPartRefList.size()) { return false; } for (int refIdx = 0; refIdx < thisPartRefList.size(); refIdx++) { if (!thisPartRefList.get(refIdx).equals(otherPartRefList.get(refIdx))) { return false; } } return true; } return false; }
@Override public FieldReference deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { String ref = this._parseString(jp, ctxt); ref = ref.replace("`", ""); return new FieldReference(ref, ExpressionPosition.UNKNOWN, true); } }
@Override public void serialize(FieldReference value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { jgen.writeString('`' + value.getRootSegment().getNameSegment().getPath() + '`'); } }
if (unnestField instanceof RepeatedMapVector) { tp = ((RepeatedMapVector) unnestField) .getTransferPairToSingleMap(reference.getAsNamePart().getName(), oContext.getAllocator()); } else if (!(unnestField instanceof RepeatedValueVector)) { if (incoming.getRecordCount() != 0) { .getTransferPair(reference.getAsNamePart().getName(), oContext.getAllocator()); } else { final ValueVector vvIn = RepeatedValueVector.class.cast(unnestField).getDataVector(); tp = vvIn.getTransferPair(reference.getAsNamePart().getName(), oContext.getAllocator());
protected LogicalExpression toDrill(AggregateCall call, List<String> fn) { List<LogicalExpression> args = Lists.newArrayList(); for (Integer i : call.getArgList()) { args.add(FieldReference.getWithQuotedRef(fn.get(i))); } // for count(1). if (args.isEmpty()) { args.add(new ValueExpressions.LongExpression(1L)); } return new FunctionCall(call.getAggregation().getName().toLowerCase(), args, ExpressionPosition.UNKNOWN); }
public FieldReference(CharSequence value, ExpressionPosition pos, boolean check) { super(new NameSegment(value), pos); if (check) { checkData(); } }