use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testMultipleColumnsOptimization.
@Test
public void testMultipleColumnsOptimization() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select * from generated_col where ts > '2015-01-01T12:00:00' and y = 1");
assertThat(whereClause.partitions().size(), is(1));
assertThat(whereClause.partitions().get(0), is(new PartitionName("generated_col", Arrays.asList(new BytesRef("1420070400000"), new BytesRef("-1"))).asIndexName()));
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testClusteredByOnly.
@Test
public void testClusteredByOnly() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select name from users_clustered_by_only where id=1");
assertFalse(whereClause.docKeys().isPresent());
assertThat(whereClause.clusteredBy().get(), contains(isLiteral(1L)));
whereClause = analyzeSelectWhere("select name from users_clustered_by_only where id=1 or id=2");
assertFalse(whereClause.docKeys().isPresent());
assertThat(whereClause.clusteredBy().get(), containsInAnyOrder(isLiteral(1L), isLiteral(2L)));
whereClause = analyzeSelectWhere("select name from users_clustered_by_only where id in (3,4,5)");
assertFalse(whereClause.docKeys().isPresent());
assertThat(whereClause.clusteredBy().get(), containsInAnyOrder(isLiteral(3L), isLiteral(4L), isLiteral(5L)));
// TODO: optimize this case: there are two routing values here, which are currently not set
whereClause = analyzeSelectWhere("select name from users_clustered_by_only where id=1 and id=2");
assertFalse(whereClause.docKeys().isPresent());
assertFalse(whereClause.clusteredBy().isPresent());
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testMultiplicationGenColNoOptimization.
@Test
public void testMultiplicationGenColNoOptimization() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select * from generated_col where y > 1");
// no optimization is done
assertThat(whereClause.partitions().size(), is(0));
assertThat(whereClause.noMatch(), is(false));
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testEqualGenColOptimization.
@Test
public void testEqualGenColOptimization() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select * from generated_col where y = 1");
assertThat(whereClause.partitions().size(), is(1));
assertThat(whereClause.partitions().get(0), is(new PartitionName("generated_col", Arrays.asList(new BytesRef("1420070400000"), new BytesRef("-1"))).asIndexName()));
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testInConvertedToAnyIfOnlyLiterals.
@Test
public void testInConvertedToAnyIfOnlyLiterals() throws Exception {
StringBuilder sb = new StringBuilder("select id from sys.shards where id in (");
int i = 0;
for (; i < 1500; i++) {
sb.append(i);
sb.append(',');
}
sb.append(i++);
sb.append(')');
String s = sb.toString();
WhereClause whereClause = analyzeSelectWhere(s);
assertThat(whereClause.query(), isFunction(AnyEqOperator.NAME, ImmutableList.<DataType>of(DataTypes.INTEGER, new ArrayType(DataTypes.INTEGER))));
}
Aggregations