Search in sources :

Example 66 with IntrinsicModel

use of com.questdb.parser.sql.model.IntrinsicModel in project questdb by bluestreak01.

the class QueryFilterAnalyserTest method testEqualsOverlapWithIn2.

@Test
public void testEqualsOverlapWithIn2() throws Exception {
    IntrinsicModel m = modelOf("sym = 'y' and sym in ('x','y')");
    Assert.assertNull(m.filter);
    Assert.assertEquals("[y]", m.keyValues.toString());
}
Also used : IntrinsicModel(com.questdb.parser.sql.model.IntrinsicModel) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 67 with IntrinsicModel

use of com.questdb.parser.sql.model.IntrinsicModel in project questdb by bluestreak01.

the class QueryFilterAnalyserTest method testNestedFunctionTest.

@Test
public void testNestedFunctionTest() throws Exception {
    IntrinsicModel m = modelOf("substr(parse(x, 1, 3), 2, 4)");
    Assert.assertNull(m.intervals);
    assertFilter(m, "4231xparsesubstr");
}
Also used : IntrinsicModel(com.questdb.parser.sql.model.IntrinsicModel) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 68 with IntrinsicModel

use of com.questdb.parser.sql.model.IntrinsicModel in project questdb by bluestreak01.

the class QueryFilterAnalyserTest method testListOfValuesPositiveOverlap.

@Test
public void testListOfValuesPositiveOverlap() throws Exception {
    IntrinsicModel m = modelOf("timestamp in ('2014-01-01T12:30:00.000Z', '2014-01-02T12:30:00.000Z') and sym in ('a', 'z') and sym in ('z')");
    Assert.assertNull(m.filter);
    Assert.assertEquals(IntrinsicValue.UNDEFINED, m.intrinsicValue);
    Assert.assertEquals("[z]", m.keyValues.toString());
}
Also used : IntrinsicModel(com.questdb.parser.sql.model.IntrinsicModel) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 69 with IntrinsicModel

use of com.questdb.parser.sql.model.IntrinsicModel in project questdb by bluestreak01.

the class QueryFilterAnalyserTest method testSimpleLambda.

@Test
public void testSimpleLambda() throws Exception {
    IntrinsicModel m = modelOf("sym in (`xyz`)");
    Assert.assertEquals("xyz", m.keyValues.get(0));
    Assert.assertTrue(m.keyValuesIsLambda);
}
Also used : IntrinsicModel(com.questdb.parser.sql.model.IntrinsicModel) AbstractTest(com.questdb.test.tools.AbstractTest) Test(org.junit.Test)

Example 70 with IntrinsicModel

use of com.questdb.parser.sql.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 {
    this.stack.clear();
    this.keyNodes.clear();
    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) {
            switch(node.token) {
                case "and":
                    if (!removeAndIntrinsics(translator, model, node.rhs, m)) {
                        stack.push(node.rhs);
                    }
                    node = removeAndIntrinsics(translator, model, node.lhs, m) ? null : node.lhs;
                    break;
                default:
                    node = stack.poll();
                    break;
            }
        } else {
            node = stack.poll();
        }
    }
    applyKeyExclusions(translator, model);
    model.filter = collapseIntrinsicNodes(root);
    return model;
}
Also used : ExprNode(com.questdb.parser.sql.model.ExprNode) IntrinsicModel(com.questdb.parser.sql.model.IntrinsicModel)

Aggregations

IntrinsicModel (com.questdb.parser.sql.model.IntrinsicModel)70 AbstractTest (com.questdb.test.tools.AbstractTest)69 Test (org.junit.Test)69 ExprNode (com.questdb.parser.sql.model.ExprNode)1