Search in sources :

Example 11 with PartitionName

use of io.crate.metadata.PartitionName in project crate by crate.

the class CopyAnalyzerTest method testCopyFromPartitionedTablePARTITIONKeywordValidArgs.

@Test
public void testCopyFromPartitionedTablePARTITIONKeywordValidArgs() throws Exception {
    CopyFromAnalyzedStatement analysis = e.analyze("copy parted partition (date=1395874800000) from '/some/distant/file.ext'");
    String parted = new PartitionName("parted", Collections.singletonList(new BytesRef("1395874800000"))).ident();
    assertThat(analysis.partitionIdent(), equalTo(parted));
}
Also used : PartitionName(io.crate.metadata.PartitionName) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 12 with PartitionName

use of io.crate.metadata.PartitionName in project crate by crate.

the class CopyAnalyzerTest method testCopyToFileWithPartitionClause.

@Test
public void testCopyToFileWithPartitionClause() throws Exception {
    CopyToAnalyzedStatement analysis = e.analyze("copy parted partition (date=1395874800000) to directory '/blah'");
    String parted = new PartitionName("parted", Collections.singletonList(new BytesRef("1395874800000"))).asIndexName();
    QuerySpec querySpec = analysis.subQueryRelation().querySpec();
    assertThat(querySpec.where().partitions(), contains(parted));
}
Also used : PartitionName(io.crate.metadata.PartitionName) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 13 with PartitionName

use of io.crate.metadata.PartitionName in project crate by crate.

the class CopyAnalyzerTest method testCopyToWithPartitionIdentAndWhereClause.

@Test
public void testCopyToWithPartitionIdentAndWhereClause() throws Exception {
    CopyToAnalyzedStatement analysis = e.analyze("copy parted partition (date=1395874800000) where id = 1 to directory '/tmp/foo'");
    String parted = new PartitionName("parted", Collections.singletonList(new BytesRef("1395874800000"))).asIndexName();
    QuerySpec querySpec = analysis.subQueryRelation().querySpec();
    assertThat(querySpec.where().partitions(), contains(parted));
    assertThat(querySpec.where().query(), isFunction("op_="));
}
Also used : PartitionName(io.crate.metadata.PartitionName) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 14 with PartitionName

use of io.crate.metadata.PartitionName in project crate by crate.

the class CopyAnalyzerTest method testCopyToWithPartitionInWhereClause.

@Test
public void testCopyToWithPartitionInWhereClause() throws Exception {
    CopyToAnalyzedStatement analysis = e.analyze("copy parted where date = 1395874800000 to directory '/tmp/foo'");
    String parted = new PartitionName("parted", Collections.singletonList(new BytesRef("1395874800000"))).asIndexName();
    QuerySpec querySpec = analysis.subQueryRelation().querySpec();
    assertThat(querySpec.where().partitions(), contains(parted));
    assertThat(analysis.overwrites().size(), is(1));
}
Also used : PartitionName(io.crate.metadata.PartitionName) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 15 with PartitionName

use of io.crate.metadata.PartitionName in project crate by crate.

the class CopyAnalyzerTest method testCopyToWithPartitionIdentAndPartitionInWhereClause.

@Test
public void testCopyToWithPartitionIdentAndPartitionInWhereClause() throws Exception {
    CopyToAnalyzedStatement analysis = e.analyze("copy parted partition (date=1395874800000) where date = 1395874800000 to directory '/tmp/foo'");
    String parted = new PartitionName("parted", Collections.singletonList(new BytesRef("1395874800000"))).asIndexName();
    QuerySpec querySpec = analysis.subQueryRelation().querySpec();
    assertThat(querySpec.where().partitions(), contains(parted));
}
Also used : PartitionName(io.crate.metadata.PartitionName) BytesRef(org.apache.lucene.util.BytesRef) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

PartitionName (io.crate.metadata.PartitionName)58 BytesRef (org.apache.lucene.util.BytesRef)50 Test (org.junit.Test)44 CrateUnitTest (io.crate.test.integration.CrateUnitTest)20 GetIndexTemplatesResponse (org.elasticsearch.action.admin.indices.template.get.GetIndexTemplatesResponse)10 WhereClause (io.crate.analyze.WhereClause)8 TableIdent (io.crate.metadata.TableIdent)8 MappingMetaData (org.elasticsearch.cluster.metadata.MappingMetaData)7 Settings (org.elasticsearch.common.settings.Settings)7 DocTableInfo (io.crate.metadata.doc.DocTableInfo)6 GetSettingsResponse (org.elasticsearch.action.admin.indices.settings.get.GetSettingsResponse)5 IndexTemplateMetaData (org.elasticsearch.cluster.metadata.IndexTemplateMetaData)5 SQLTransportIntegrationTest (io.crate.integrationtests.SQLTransportIntegrationTest)4 SQLResponse (io.crate.testing.SQLResponse)4 Map (java.util.Map)4 Table (io.crate.sql.tree.Table)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)3 MetaData (org.elasticsearch.cluster.metadata.MetaData)3