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"));
}
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'");
RelationName relationName = new RelationName("doc", "generated_col");
assertThat(whereClause.partitions(), containsInAnyOrder(new PartitionName(relationName, Arrays.asList("1420070400000", "-1")).asIndexName(), new PartitionName(relationName, Arrays.asList("1420156800000", "-2")).asIndexName()));
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method test_where_on_date_with_null_partition_or_id_can_match_all_partitions.
@Test
public void test_where_on_date_with_null_partition_or_id_can_match_all_partitions() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select id, name from parted where date = 1395961200000::timestamp or id = 1");
assertThat(whereClause.partitions(), containsInAnyOrder(".partitioned.parted.0400", ".partitioned.parted.04732cpp6ksjcc9i60o30c1g", ".partitioned.parted.04732cpp6ks3ed1o60o30c1g"));
assertThat(whereClause.queryOrFallback(), isSQL("((doc.parted.date = 1395961200000::bigint) OR (doc.parted.id = 1))"));
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testAnyILikeArrayLiteral.
@Test
public void testAnyILikeArrayLiteral() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select * from users where name ilike any(['a', 'b', 'c'])");
assertThat(whereClause.query(), isFunction(LikeOperators.ANY_ILIKE, List.of(DataTypes.STRING, new ArrayType<>(DataTypes.STRING))));
}
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(new RelationName("doc", "generated_col"), Arrays.asList("1420156800000", "-2")).asIndexName()));
}
Aggregations