Search in sources :

Example 36 with WhereClause

use of io.crate.analyze.WhereClause in project crate by crate.

the class WhereClauseAnalyzerTest method testOptimizationNonRoundingFunctionGreater.

@Test
public void testOptimizationNonRoundingFunctionGreater() throws Exception {
    WhereClause whereClause = analyzeSelectWhere("select * from double_gen_parted where x > 3");
    assertThat(whereClause.query(), isSQL("(doc.double_gen_parted.x > 3)"));
    assertThat(whereClause.partitions().size(), is(1));
    assertThat(whereClause.partitions().get(0), is(".partitioned.double_gen_parted.0813a0hm"));
}
Also used : WhereClause(io.crate.analyze.WhereClause) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 37 with WhereClause

use of io.crate.analyze.WhereClause in project crate by crate.

the class WhereClauseAnalyzerTest method test4ColPrimaryKeySetLiteral.

@Test
public void test4ColPrimaryKeySetLiteral() throws Exception {
    WhereClause whereClause = analyzeSelectWhere("select * from pk4 where i1=10 and i2=20 and" + " i3 in (30, 31) and i4=40");
    assertThat(whereClause.docKeys().get(), containsInAnyOrder(isDocKey(10, 20, 30, 40), isDocKey(10, 20, 31, 40)));
}
Also used : WhereClause(io.crate.analyze.WhereClause) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 38 with WhereClause

use of io.crate.analyze.WhereClause in project crate by crate.

the class WhereClauseAnalyzerTest method test1ColPrimaryKeySetLiteral.

@Test
public void test1ColPrimaryKeySetLiteral() throws Exception {
    WhereClause whereClause = analyzeSelectWhere("select name from users where id in ('1', '2')");
    assertFalse(whereClause.noMatch());
    assertThat(whereClause.docKeys().get(), containsInAnyOrder(isDocKey("1"), isDocKey("2")));
}
Also used : WhereClause(io.crate.analyze.WhereClause) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 39 with WhereClause

use of io.crate.analyze.WhereClause in project crate by crate.

the class WhereClauseAnalyzerTest method testGtGenColOptimization.

@Test
public void testGtGenColOptimization() throws Exception {
    WhereClause whereClause = analyzeSelectWhere("select * from generated_col where ts > '2015-01-02T12:00:00'");
    assertThat(whereClause.partitions().size(), is(1));
    assertThat(whereClause.partitions().get(0), is(new PartitionName("generated_col", Arrays.asList(new BytesRef("1420156800000"), new BytesRef("-2"))).asIndexName()));
}
Also used : PartitionName(io.crate.metadata.PartitionName) WhereClause(io.crate.analyze.WhereClause) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 40 with WhereClause

use of io.crate.analyze.WhereClause in project crate by crate.

the class WhereClauseAnalyzerTest method testClusteredByValueContainsComma.

@Test
public void testClusteredByValueContainsComma() throws Exception {
    WhereClause whereClause = analyzeSelectWhere("select * from bystring where name = 'a,b,c'");
    assertThat(whereClause.clusteredBy().get(), contains(isLiteral("a,b,c")));
    assertThat(whereClause.docKeys().get().size(), is(1));
    assertThat(whereClause.docKeys().get().getOnlyKey(), isDocKey("a,b,c"));
}
Also used : WhereClause(io.crate.analyze.WhereClause) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

WhereClause (io.crate.analyze.WhereClause)61 Test (org.junit.Test)46 CrateUnitTest (io.crate.test.integration.CrateUnitTest)43 Symbol (io.crate.analyze.symbol.Symbol)10 PartitionName (io.crate.metadata.PartitionName)8 BytesRef (org.apache.lucene.util.BytesRef)8 DataType (io.crate.types.DataType)6 TableInfo (io.crate.metadata.table.TableInfo)5 SqlExpressions (io.crate.testing.SqlExpressions)5 QualifiedName (io.crate.sql.tree.QualifiedName)4 ArrayType (io.crate.types.ArrayType)4 ImmutableList (com.google.common.collect.ImmutableList)3 OrderBy (io.crate.analyze.OrderBy)3 AnalyzedRelation (io.crate.analyze.relations.AnalyzedRelation)3 TableRelation (io.crate.analyze.relations.TableRelation)3 Function (io.crate.analyze.symbol.Function)3 SQLTransportIntegrationTest (io.crate.integrationtests.SQLTransportIntegrationTest)3 CrateRegexQuery (io.crate.lucene.match.CrateRegexQuery)3 Literal (io.crate.analyze.symbol.Literal)2 Bucket (io.crate.data.Bucket)2