@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof CastExpression)) { return false; } CastExpression other = (CastExpression) obj; return this.input.equals(other.input) && (this.getMajorType().hasMinorType() == other.getMajorType().hasMinorType()); }
@Override public Void visitCastExpression(CastExpression e, StringBuilder sb) throws RuntimeException { MajorType mt = e.getMajorType();
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof CastExpression)) { return false; } CastExpression other = (CastExpression) obj; return this.input.equals(other.input) && (this.getMajorType().hasMinorType() == other.getMajorType().hasMinorType()); }
boolean castIsCompatible(CastExpression castExpr, Collection<LogicalExpression> indexFields) { for (LogicalExpression indexExpr : indexFields) { if (indexExpr.getClass() != castExpr.getClass()) { continue; } CastExpression indexCastExpr = (CastExpression)indexExpr; // we compare input using equals because we know we are comparing SchemaPath, // if we extend to support other expression, make sure the equals of that expression // is implemented properly, otherwise it will fall to identity comparison if (!castExpr.getInput().equals(indexCastExpr.getInput()) ) { continue; } if (castExpr.getMajorType().getMinorType() != indexCastExpr.getMajorType().getMinorType()) { continue; } return true; } return false; }
@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 Void visitCastExpression(CastExpression e, StringBuilder sb) throws RuntimeException { MajorType mt = e.getMajorType();
final CastExpression indexedCast = (CastExpression) indexed; if (expr.getInput().equals(indexedCast.getInput()) && expr.getMajorType().getMinorType().equals(indexedCast.getMajorType().getMinorType()) && expr.getMajorType().getPrecision() < indexedCast.getMajorType().getPrecision()) { toRewriteEqualCastMap.put(entry.getKey(), entry.getValue());
if (castExprInFilter.getMajorType().getMinorType() == TypeProtos.MinorType.VARCHAR && (castExprInFilter.getMajorType().getPrecision() > relatedPaths.get(idxFound).getMajorType().getPrecision())) { continue;
@Override public RexNode visitCastExpression(CastExpression e, Void value) throws RuntimeException { RexNode convertedInput = e.getInput().accept(this, null); String typeStr = e.getMajorType().getMinorType().toString(); if (SqlTypeName.get(typeStr) == null) { logger.debug("SqlTypeName could not find {}", typeStr); } SqlTypeName typeName = TypeInferenceUtils.getCalciteTypeFromDrillType(e.getMajorType().getMinorType()); RelDataType targetType = TypeInferenceUtils.createCalciteTypeWithNullability( inputRel.getCluster().getTypeFactory(), typeName, true); return builder.makeCast(targetType, convertedInput); }
MajorType newMajor = e.getMajorType(); // Output type return new CastExpression(input, e.getMajorType(), e.getPosition()); } else if (newMinor == MinorType.NULL) { return new TypedNullConstant(e.getMajorType().toBuilder().setMode(DataMode.OPTIONAL).build()); } else { MajorType type = e.getMajorType();