Search in sources :

Example 86 with IntrinsicModel

use of com.questdb.griffin.lexer.model.IntrinsicModel in project questdb by bluestreak01.

the class QueryFilterAnalyser method extract.

IntrinsicModel extract(AliasTranslator translator, ExprNode node, RecordMetadata m, String preferredKeyColumn, int timestampIndex) throws ParserException {
    reset();
    this.timestamp = timestampIndex < 0 ? null : m.getColumnName(timestampIndex);
    this.preferredKeyColumn = preferredKeyColumn;
    IntrinsicModel model = models.next();
    if (removeAndIntrinsics(translator, model, node, m)) {
        return model;
    }
    ExprNode root = node;
    while (!stack.isEmpty() || node != null) {
        if (node != null) {
            if (Chars.equals("and", node.token)) {
                if (!removeAndIntrinsics(translator, model, node.rhs, m)) {
                    stack.push(node.rhs);
                }
                node = removeAndIntrinsics(translator, model, node.lhs, m) ? null : node.lhs;
            } else {
                node = stack.poll();
            }
        } else {
            node = stack.poll();
        }
    }
    applyKeyExclusions(translator, model);
    model.filter = collapseIntrinsicNodes(root);
    return model;
}
Also used : ExprNode(com.questdb.griffin.common.ExprNode) IntrinsicModel(com.questdb.griffin.lexer.model.IntrinsicModel)

Aggregations

IntrinsicModel (com.questdb.griffin.lexer.model.IntrinsicModel)86 AbstractCairoTest (com.questdb.cairo.AbstractCairoTest)85 GriffinParserTestUtils.intervalToString (com.questdb.griffin.lexer.GriffinParserTestUtils.intervalToString)5 ExprNode (com.questdb.griffin.common.ExprNode)1