/** * @param input * @param pos */ public AnyValueExpression(LogicalExpression input, ExpressionPosition pos) { super(pos); this.input = input; this.type = input.getMajorType(); }
@Override public MajorType getOutputType(List<LogicalExpression> expressions) { return expressions.get(0).getMajorType(); } }
@Override public MajorType getOutputType(List<LogicalExpression> expressions) { for(LogicalExpression e : expressions){ if(e.getMajorType().getMode() == DataMode.OPTIONAL){ return e.getMajorType(); } } return expressions.get(0).getMajorType(); } }
@Override public MajorType getMajorType() { // If any of argumgnet of a boolean "and"/"or" is nullable, the result is nullable bit. // Otherwise, it's non-nullable bit. for (LogicalExpression e : args) { if (e.getMajorType().getMode() == DataMode.OPTIONAL) { return Types.OPTIONAL_BIT; } } return Types.REQUIRED_BIT; }
@Override public Void visitBooleanOperator(BooleanOperator op, ErrorCollector errors) throws RuntimeException { int i = 0; for (LogicalExpression arg : op.args) { if ( arg.getMajorType().getMinorType() != MinorType.BIT) { errors .addGeneralError( arg.getPosition(), String .format( "Failure composing boolean operator %s. All conditions must return a boolean type. Condition %d was of Type %s.", op.getName(), i, arg.getMajorType().getMinorType())); } i++; } return null; }
@Override public MajorType getOutputType(List<LogicalExpression> expressions) { for(LogicalExpression e : expressions){ if(e.getMajorType().getMode() == DataMode.OPTIONAL){ return Types.optional(outputMinorType); } } return Types.required(outputMinorType); } }
MajorType majorType = cond.condition.getMajorType(); if ( majorType .getMinorType() != MinorType.BIT) { final MajorType mt = ifExpr.elseExpression.getMajorType(); cond = ifExpr.ifCondition; MajorType innerT = cond.expression.getMajorType(); if ((innerT.getMode() == DataMode.REPEATED && mt.getMode() != DataMode.REPEATED) || // ((innerT.getMinorType() != mt.getMinorType()) &&
@Override public MajorType getMajorType() { if (outputType != null) { return outputType; } MajorType elseType = elseExpression.getMajorType(); MajorType ifType = ifCondition.expression.getMajorType(); if (elseType.getMinorType() == MinorType.UNION) { Set<MinorType> subtypes = Sets.newHashSet(); for (MinorType subtype : elseType.getSubTypeList()) { subtypes.add(subtype); } for (MinorType subtype : ifType.getSubTypeList()) { subtypes.add(subtype); } MajorType.Builder builder = MajorType.newBuilder().setMinorType(MinorType.UNION).setMode(DataMode.OPTIONAL); for (MinorType subtype : subtypes) { builder.addSubType(subtype); } return builder.build(); } MajorType.Builder builder = MajorType.newBuilder().setMinorType(ifType.getMinorType()); builder.setMode(elseType.getMode() == DataMode.OPTIONAL || ifType.getMode() == DataMode.OPTIONAL ? DataMode.OPTIONAL : elseType.getMode()); builder = Types.calculateTypePrecisionAndScale(ifType, elseType, builder); return builder.build(); }
for (int i=0; i<call.args.size(); i++) { try { argTypes[i] = call.args.get(i).getMajorType(); argOIs[i] = ObjectInspectorHelper.getDrillObjectInspector(argTypes[i].getMode(), argTypes[i].getMinorType(), varCharToStringReplacement);
private boolean checkType(LogicalExpression e1, LogicalExpression e2) { return e1.getMajorType().equals(e2.getMajorType()); } }
@Override public OutputWidthExpression visitUnknown(LogicalExpression logicalExpression, OutputWidthVisitorState state) { OutputWidthExpression fixedLenExpr = getFixedLenExpr(logicalExpression.getMajorType()); if (fixedLenExpr != null) { return fixedLenExpr; } throw new IllegalStateException("Unknown variable width expression: " + logicalExpression); }
private boolean hasUnionInput(FunctionCall call) { for (LogicalExpression arg : call.args) { if (arg.getMajorType().getMinorType() == MinorType.UNION) { return true; } } return false; }
private int computePrecision(LogicalExpression currentArg) { int precision = currentArg.getMajorType().getPrecision(); return DecimalUtility.getDefaultPrecision(currentArg.getMajorType().getMinorType(), precision); }
@Override public Boolean visitNullConstant(TypedNullConstant e, LogicalExpression value) throws RuntimeException { if (!(value instanceof TypedNullConstant)) { return false; } return value.getMajorType().equals(e.getMajorType()); }
@Override public boolean apply(LogicalExpression input) { return !input.getMajorType().getMinorType().equals(TypeProtos.MinorType.NULL); } }
@Override public Boolean visitNullExpression(NullExpression e, LogicalExpression value) throws RuntimeException { if (!(value instanceof NullExpression)) { return false; } return e.getMajorType().equals(value.getMajorType()); }
@Override public Boolean visitCastExpression(CastExpression e, LogicalExpression value) throws RuntimeException { if (!(value instanceof CastExpression)) { return false; } if (!e.getMajorType().equals(value.getMajorType())) { return false; } return checkChildren(e, value); }
@Override public MajorType getOutputType(List<LogicalExpression> expressions) { for(LogicalExpression e : expressions){ if(e.getMajorType().getMode() == DataMode.OPTIONAL){ return Types.optional(outputMinorType); } } return Types.required(outputMinorType); } }
@Override public Boolean visitVarDecimalConstant(VarDecimalExpression decExpr, LogicalExpression value) throws RuntimeException { if (!(value instanceof VarDecimalExpression)) { return false; } if (!decExpr.getMajorType().equals(value.getMajorType())) { return false; } if (!decExpr.getBigDecimal().equals(((VarDecimalExpression) value).getBigDecimal())) { return false; } return true; }
@Override boolean materialize(final NamedExpression ne, final VectorContainer batch, final FunctionLookupContext registry) throws SchemaChangeException { final FunctionCall call = (FunctionCall) ne.getExpr(); final LogicalExpression argument = call.args.get(0); final MaterializedField outputField = MaterializedField.create(ne.getRef().getAsNamePart().getName(), argument.getMajorType()); batch.addOrGet(outputField).allocateNew(); fieldId = batch.getValueVectorId(ne.getRef()); numTiles = numTilesFromExpression(argument); return true; }