use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testNonPartitionedNotOptimized.
@Test
public void testNonPartitionedNotOptimized() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select * from generated_col where x = 1");
assertThat(whereClause.query(), isSQL("(doc.generated_col.x = 1)"));
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method test4ColPrimaryKey.
@Test
public void test4ColPrimaryKey() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select * from pk4 where i1=10 and i2=20 and i3=30 and i4=40");
assertThat(whereClause.docKeys().get(), contains(isDocKey(10, 20, 30, 40)));
assertFalse(whereClause.noMatch());
whereClause = analyzeSelectWhere("select * from pk4 where i1=10 and i2=20 and i3=30 and i4=40 and i1=10");
assertThat(whereClause.docKeys().get(), contains(isDocKey(10, 20, 30, 40)));
assertFalse(whereClause.noMatch());
whereClause = analyzeSelectWhere("select * from pk4 where i1=1");
assertFalse(whereClause.docKeys().isPresent());
assertFalse(whereClause.noMatch());
whereClause = analyzeSelectWhere("select * from pk4 where i1=10 and i2=20 and i3=30 and i4=40 and i1=11");
assertFalse(whereClause.docKeys().isPresent());
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testCompositePrimaryKey.
@Test
public void testCompositePrimaryKey() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select name from users_multi_pk where id=1");
assertFalse(whereClause.docKeys().isPresent());
assertThat(whereClause.clusteredBy().get(), contains(isLiteral(1L)));
whereClause = analyzeSelectWhere("select name from users_multi_pk where id=1 and name='Douglas'");
assertThat(whereClause.docKeys().get(), contains(isDocKey(1L, "Douglas")));
assertThat(whereClause.clusteredBy().get(), contains(isLiteral(1L)));
whereClause = analyzeSelectWhere("select name from users_multi_pk where id=1 or id=2 and name='Douglas'");
assertFalse(whereClause.docKeys().isPresent());
assertThat(whereClause.clusteredBy().get(), containsInAnyOrder(isLiteral(1L), isLiteral(2L)));
whereClause = analyzeSelectWhere("select name from users_multi_pk where id=1 and name='Douglas' or name='Arthur'");
assertFalse(whereClause.docKeys().isPresent());
assertFalse(whereClause.clusteredBy().isPresent());
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testMultiplePrimaryKeys.
@Test
public void testMultiplePrimaryKeys() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select name from users where id = 2 or id = 1");
assertThat(whereClause.docKeys().get(), containsInAnyOrder(isDocKey("1"), isDocKey("2")));
assertThat(whereClause.clusteredBy().get(), containsInAnyOrder(isLiteral("1"), isLiteral("2")));
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testSelectByIdWithPartitions.
@Test
public void testSelectByIdWithPartitions() throws Exception {
WhereClause whereClause = analyzeSelect("select id from parted where _id=1");
assertFalse(whereClause.docKeys().isPresent());
}
Aggregations