use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testGenColRangeOptimization.
@Test
public void testGenColRangeOptimization() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select * from generated_col where ts >= '2015-01-01T12:00:00' and ts <= '2015-01-02T00:00:00'");
assertThat(whereClause.partitions().size(), is(2));
assertThat(whereClause.partitions().get(0), is(new PartitionName("generated_col", Arrays.asList(new BytesRef("1420070400000"), new BytesRef("-1"))).asIndexName()));
assertThat(whereClause.partitions().get(1), is(new PartitionName("generated_col", Arrays.asList(new BytesRef("1420156800000"), new BytesRef("-2"))).asIndexName()));
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method test1ColPrimaryKeyNotSetLiteral.
@Test
public void test1ColPrimaryKeyNotSetLiteral() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select name from users where id not in ('jalla', 'kelle')");
assertFalse(whereClause.noMatch());
assertFalse(whereClause.docKeys().isPresent());
assertFalse(whereClause.clusteredBy().isPresent());
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testInNormalizedToAnyWithScalars.
@Test
public void testInNormalizedToAnyWithScalars() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select * from users where id in (null, 1+2, 3+4, abs(-99))");
assertThat(whereClause.query(), isFunction(AnyEqOperator.NAME));
assertThat(whereClause.docKeys().isPresent(), is(true));
assertThat(whereClause.docKeys().get(), containsInAnyOrder(isNullDocKey(), isDocKey("3"), isDocKey("7"), isDocKey("99")));
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method test1ColPrimaryKeySetLiteralDiffMatches.
@Test
public void test1ColPrimaryKeySetLiteralDiffMatches() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select name from users where id in ('jalla', 'kelle') and id in ('jalla', 'something')");
assertFalse(whereClause.noMatch());
assertThat(whereClause.docKeys().get(), contains(isDocKey("jalla")));
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testEmptyClusteredByValue.
@Test
public void testEmptyClusteredByValue() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select * from bystring where name = ''");
assertThat(whereClause.clusteredBy().get(), contains(isLiteral("")));
assertThat(whereClause.docKeys().get().getOnlyKey(), isDocKey(""));
}
Aggregations