Search in sources :

Example 1 with VarDecimalExpression

use of org.apache.drill.common.expression.ValueExpressions.VarDecimalExpression in project drill by apache.

the class CompareFunctionsProcessor method visitSchemaPath.

@Override
public Boolean visitSchemaPath(SchemaPath path, LogicalExpression valueArg) throws RuntimeException {
    // If valueArg is null, this might be a IS NULL/IS NOT NULL type of query
    if (valueArg == null) {
        this.path = path;
        return true;
    }
    if (valueArg instanceof QuotedString) {
        this.value = SqlHelper.decodeStringAsValue(((QuotedString) valueArg).value);
        this.path = path;
        return true;
    }
    if (valueArg instanceof IntExpression) {
        this.value = KeyValueBuilder.initFrom(((IntExpression) valueArg).getInt());
        this.path = path;
        return true;
    }
    if (valueArg instanceof FloatExpression) {
        this.value = KeyValueBuilder.initFrom(((FloatExpression) valueArg).getFloat());
        this.path = path;
        return true;
    }
    if (valueArg instanceof BooleanExpression) {
        this.value = KeyValueBuilder.initFrom(((BooleanExpression) valueArg).getBoolean());
        this.path = path;
        return true;
    }
    if (valueArg instanceof Decimal28Expression) {
        this.value = KeyValueBuilder.initFrom(((Decimal28Expression) valueArg).getBigDecimal());
        this.path = path;
        return true;
    }
    if (valueArg instanceof Decimal38Expression) {
        this.value = KeyValueBuilder.initFrom(((Decimal38Expression) valueArg).getBigDecimal());
        this.path = path;
        return true;
    }
    if (valueArg instanceof DoubleExpression) {
        this.value = KeyValueBuilder.initFrom(((DoubleExpression) valueArg).getDouble());
        this.path = path;
        return true;
    }
    if (valueArg instanceof LongExpression) {
        this.value = KeyValueBuilder.initFrom(((LongExpression) valueArg).getLong());
        this.path = path;
        return true;
    }
    if (valueArg instanceof DateExpression) {
        long d = ((DateExpression) valueArg).getDate();
        final long MILLISECONDS_IN_A_DAY = (long) 1000 * 60 * 60 * 24;
        int daysSinceEpoch = (int) (d / MILLISECONDS_IN_A_DAY);
        this.value = KeyValueBuilder.initFrom(ODate.fromDaysSinceEpoch(daysSinceEpoch));
        this.path = path;
        return true;
    }
    if (valueArg instanceof TimeExpression) {
        int t = ((TimeExpression) valueArg).getTime();
        LocalTime lT = LocalTime.fromMillisOfDay(t);
        this.value = KeyValueBuilder.initFrom(new OTime(lT.getHourOfDay(), lT.getMinuteOfHour(), lT.getSecondOfMinute(), lT.getMillisOfSecond()));
        this.path = path;
        return true;
    }
    // See com.mapr.db.impl.ConditionImpl.is(FieldPath path, QueryCondition.Op op, BigDecimal value) method
    if (valueArg instanceof VarDecimalExpression) {
        this.value = KeyValueBuilder.initFrom(((VarDecimalExpression) valueArg).getBigDecimal().doubleValue());
        this.path = path;
        return true;
    }
    if (valueArg instanceof TimeStampExpression) {
        return visitTimestampExpr(path, (TimeStampExpression) valueArg);
    }
    return false;
}
Also used : VarDecimalExpression(org.apache.drill.common.expression.ValueExpressions.VarDecimalExpression) LocalTime(org.joda.time.LocalTime) IntExpression(org.apache.drill.common.expression.ValueExpressions.IntExpression) Decimal38Expression(org.apache.drill.common.expression.ValueExpressions.Decimal38Expression) DoubleExpression(org.apache.drill.common.expression.ValueExpressions.DoubleExpression) FloatExpression(org.apache.drill.common.expression.ValueExpressions.FloatExpression) TimeExpression(org.apache.drill.common.expression.ValueExpressions.TimeExpression) TimeStampExpression(org.apache.drill.common.expression.ValueExpressions.TimeStampExpression) QuotedString(org.apache.drill.common.expression.ValueExpressions.QuotedString) BooleanExpression(org.apache.drill.common.expression.ValueExpressions.BooleanExpression) DateExpression(org.apache.drill.common.expression.ValueExpressions.DateExpression) Decimal28Expression(org.apache.drill.common.expression.ValueExpressions.Decimal28Expression) LongExpression(org.apache.drill.common.expression.ValueExpressions.LongExpression) OTime(org.ojai.types.OTime)

Aggregations

BooleanExpression (org.apache.drill.common.expression.ValueExpressions.BooleanExpression)1 DateExpression (org.apache.drill.common.expression.ValueExpressions.DateExpression)1 Decimal28Expression (org.apache.drill.common.expression.ValueExpressions.Decimal28Expression)1 Decimal38Expression (org.apache.drill.common.expression.ValueExpressions.Decimal38Expression)1 DoubleExpression (org.apache.drill.common.expression.ValueExpressions.DoubleExpression)1 FloatExpression (org.apache.drill.common.expression.ValueExpressions.FloatExpression)1 IntExpression (org.apache.drill.common.expression.ValueExpressions.IntExpression)1 LongExpression (org.apache.drill.common.expression.ValueExpressions.LongExpression)1 QuotedString (org.apache.drill.common.expression.ValueExpressions.QuotedString)1 TimeExpression (org.apache.drill.common.expression.ValueExpressions.TimeExpression)1 TimeStampExpression (org.apache.drill.common.expression.ValueExpressions.TimeStampExpression)1 VarDecimalExpression (org.apache.drill.common.expression.ValueExpressions.VarDecimalExpression)1 LocalTime (org.joda.time.LocalTime)1 OTime (org.ojai.types.OTime)1