Search in sources :

Example 1 with Decimal38Expression

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

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 = KeyValueBuilder.initFrom(((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;
    }
    if (valueArg instanceof TimeStampExpression) {
    // disable pushdown of TimeStampExpression type until bug 22824 is fixed.
    // 
    // this.value = KeyValueBuilder.initFrom(new OTimestamp(((TimeStampExpression)valueArg).getTimeStamp()));
    // this.path = path;
    // return true;
    }
    return false;
}
Also used : 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)

Example 2 with Decimal38Expression

use of org.apache.drill.common.expression.ValueExpressions.Decimal38Expression 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)2 DateExpression (org.apache.drill.common.expression.ValueExpressions.DateExpression)2 Decimal28Expression (org.apache.drill.common.expression.ValueExpressions.Decimal28Expression)2 Decimal38Expression (org.apache.drill.common.expression.ValueExpressions.Decimal38Expression)2 DoubleExpression (org.apache.drill.common.expression.ValueExpressions.DoubleExpression)2 FloatExpression (org.apache.drill.common.expression.ValueExpressions.FloatExpression)2 IntExpression (org.apache.drill.common.expression.ValueExpressions.IntExpression)2 LongExpression (org.apache.drill.common.expression.ValueExpressions.LongExpression)2 QuotedString (org.apache.drill.common.expression.ValueExpressions.QuotedString)2 TimeExpression (org.apache.drill.common.expression.ValueExpressions.TimeExpression)2 TimeStampExpression (org.apache.drill.common.expression.ValueExpressions.TimeStampExpression)2 LocalTime (org.joda.time.LocalTime)2 OTime (org.ojai.types.OTime)2 VarDecimalExpression (org.apache.drill.common.expression.ValueExpressions.VarDecimalExpression)1