Search in sources :

Example 11 with NumericException

use of com.questdb.common.NumericException in project questdb by bluestreak01.

the class QueryFilterAnalyser method analyzeInInterval.

private boolean analyzeInInterval(IntrinsicModel model, ExprNode col, ExprNode in) throws ParserException {
    if (!isTimestamp(col)) {
        return false;
    }
    if (in.paramCount > 3) {
        throw QueryError.$(in.args.getQuick(0).position, "Too many args");
    }
    if (in.paramCount < 3) {
        throw QueryError.$(in.position, "Too few args");
    }
    ExprNode lo = in.args.getQuick(1);
    ExprNode hi = in.args.getQuick(0);
    if (lo.type == ExprNode.CONSTANT && hi.type == ExprNode.CONSTANT) {
        long loMillis;
        long hiMillis;
        try {
            loMillis = DateFormatUtils.tryParse(quoteEraser.ofQuoted(lo.token));
        } catch (NumericException ignore) {
            throw QueryError.$(lo.position, "Unknown date format");
        }
        try {
            hiMillis = DateFormatUtils.tryParse(quoteEraser.ofQuoted(hi.token));
        } catch (NumericException ignore) {
            throw QueryError.$(hi.position, "Unknown date format");
        }
        model.intersectIntervals(loMillis, hiMillis);
        in.intrinsicValue = IntrinsicValue.TRUE;
        return true;
    }
    return false;
}
Also used : ExprNode(com.questdb.parser.sql.model.ExprNode) NumericException(com.questdb.common.NumericException)

Example 12 with NumericException

use of com.questdb.common.NumericException in project questdb by bluestreak01.

the class QueryFilterAnalyser method analyzeNotInInterval.

private boolean analyzeNotInInterval(IntrinsicModel model, ExprNode col, ExprNode in) throws ParserException {
    if (!isTimestamp(col)) {
        return false;
    }
    if (in.paramCount > 3) {
        throw ParserException.$(in.args.getQuick(0).position, "Too many args");
    }
    if (in.paramCount < 3) {
        throw ParserException.$(in.position, "Too few args");
    }
    ExprNode lo = in.args.getQuick(1);
    ExprNode hi = in.args.getQuick(0);
    if (lo.type == ExprNode.CONSTANT && hi.type == ExprNode.CONSTANT) {
        long loMillis;
        long hiMillis;
        try {
            loMillis = DateFormatUtils.tryParse(lo.token, 1, lo.token.length() - 1);
        } catch (NumericException ignore) {
            throw ParserException.invalidDate(lo.position);
        }
        try {
            hiMillis = DateFormatUtils.tryParse(hi.token, 1, hi.token.length() - 1);
        } catch (NumericException ignore) {
            throw ParserException.invalidDate(hi.position);
        }
        model.subtractIntervals(loMillis, hiMillis);
        in.intrinsicValue = IntrinsicValue.TRUE;
        return true;
    }
    return false;
}
Also used : ExprNode(com.questdb.griffin.common.ExprNode) NumericException(com.questdb.common.NumericException)

Aggregations

NumericException (com.questdb.common.NumericException)12 Path (com.questdb.std.str.Path)3 ExprNode (com.questdb.griffin.common.ExprNode)2 ExprNode (com.questdb.parser.sql.model.ExprNode)2 TestMicroClock (com.questdb.test.tools.TestMicroClock)2 Test (org.junit.Test)2 NetworkError (com.questdb.std.ex.NetworkError)1 DirectByteCharSequence (com.questdb.std.str.DirectByteCharSequence)1 FileNameExtractorCharSequence (com.questdb.std.str.FileNameExtractorCharSequence)1 LPSZ (com.questdb.std.str.LPSZ)1 Interval (com.questdb.std.time.Interval)1 JournalStructure (com.questdb.store.factory.configuration.JournalStructure)1 File (java.io.File)1