use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testMultipleCompoundPrimaryKeys.
@Test
public void testMultipleCompoundPrimaryKeys() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select * from pk4 where (i1=1 and i2=2 and i3=3 and i4=4) " + "or (i1=1 and i2=5 and i3=6 and i4=4)");
assertThat(whereClause.docKeys().get(), containsInAnyOrder(isDocKey(1, 2, 3, 4), isDocKey(1, 5, 6, 4)));
assertFalse(whereClause.clusteredBy().isPresent());
whereClause = analyzeSelectWhere("select * from pk4 where (i1=1 and i2=2 and i3=3 and i4=4) " + "or (i1=1 and i2=5 and i3=6 and i4=4) or i1 = 3");
assertFalse(whereClause.docKeys().isPresent());
assertFalse(whereClause.clusteredBy().isPresent());
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testAnyLikeConvertableArrayTypeLiterals.
@Test
public void testAnyLikeConvertableArrayTypeLiterals() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select * from users where name like any([1, 2, 3])");
assertThat(whereClause.query(), isFunction(AnyLikeOperator.NAME, ImmutableList.<DataType>of(DataTypes.STRING, new ArrayType(DataTypes.STRING))));
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testClusteredBy.
@Test
public void testClusteredBy() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select name from users where id=1");
assertThat(whereClause.clusteredBy().get(), contains(isLiteral("1")));
assertThat(whereClause.docKeys().get().getOnlyKey(), isDocKey("1"));
whereClause = analyzeSelectWhere("select name from users where id=1 or id=2");
assertThat(whereClause.docKeys().get().size(), is(2));
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 testGenColRoundingFunctionNoSwappingOperatorOptimization.
@Test
public void testGenColRoundingFunctionNoSwappingOperatorOptimization() 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()));
}
use of io.crate.analyze.WhereClause in project crate by crate.
the class WhereClauseAnalyzerTest method testColumnReferencedTwiceInGeneratedColumnPartitioned.
@Test
public void testColumnReferencedTwiceInGeneratedColumnPartitioned() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select * from double_gen_parted where x = 4");
assertThat(whereClause.query(), isSQL("(doc.double_gen_parted.x = 4)"));
assertThat(whereClause.partitions().size(), is(1));
assertThat(whereClause.partitions().get(0), is(".partitioned.double_gen_parted.0813a0hm"));
}
Aggregations