Search in sources :

Example 1 with DeleteAnalyzedStatement

use of io.crate.analyze.DeleteAnalyzedStatement in project crate by crate.

the class WhereClauseAnalyzerTest method testWhereSinglePKColumnEq.

@Test
public void testWhereSinglePKColumnEq() throws Exception {
    DeleteAnalyzedStatement statement = e.analyze("delete from users where id = ?", new Object[][] { new Object[] { 1 }, new Object[] { 2 }, new Object[] { 3 } });
    DocTableRelation tableRelation = statement.analyzedRelation();
    WhereClauseAnalyzer whereClauseAnalyzer = new WhereClauseAnalyzer(e.functions(), tableRelation);
    assertThat(whereClauseAnalyzer.analyze(statement.whereClauses().get(0), transactionContext).docKeys().get(), contains(isDocKey("1")));
    assertThat(whereClauseAnalyzer.analyze(statement.whereClauses().get(1), transactionContext).docKeys().get(), contains(isDocKey("2")));
    assertThat(whereClauseAnalyzer.analyze(statement.whereClauses().get(2), transactionContext).docKeys().get(), contains(isDocKey("3")));
}
Also used : DocTableRelation(io.crate.analyze.relations.DocTableRelation) DeleteAnalyzedStatement(io.crate.analyze.DeleteAnalyzedStatement) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 2 with DeleteAnalyzedStatement

use of io.crate.analyze.DeleteAnalyzedStatement in project crate by crate.

the class WhereClauseAnalyzerTest method testWherePartitionedByColumn.

@Test
public void testWherePartitionedByColumn() throws Exception {
    DeleteAnalyzedStatement statement = e.analyze("delete from parted where date = 1395874800000");
    WhereClause whereClause = statement.whereClauses().get(0);
    assertThat(whereClause.hasQuery(), is(false));
    assertThat(whereClause.noMatch(), is(false));
    assertThat(whereClause.partitions(), Matchers.contains(new PartitionName("parted", Arrays.asList(new BytesRef("1395874800000"))).asIndexName()));
}
Also used : PartitionName(io.crate.metadata.PartitionName) WhereClause(io.crate.analyze.WhereClause) DeleteAnalyzedStatement(io.crate.analyze.DeleteAnalyzedStatement) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

DeleteAnalyzedStatement (io.crate.analyze.DeleteAnalyzedStatement)2 CrateUnitTest (io.crate.test.integration.CrateUnitTest)2 Test (org.junit.Test)2 WhereClause (io.crate.analyze.WhereClause)1 DocTableRelation (io.crate.analyze.relations.DocTableRelation)1 PartitionName (io.crate.metadata.PartitionName)1 BytesRef (org.apache.lucene.util.BytesRef)1