Search in sources :

Example 81 with RelationName

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

the class SnapshotRestoreAnalyzerTest method testRestoreSinglePartitionToUnknownTable.

@Test
public void testRestoreSinglePartitionToUnknownTable() throws Exception {
    BoundRestoreSnapshot statement = analyze(e, "RESTORE SNAPSHOT my_repo.my_snapshot TABLE unknown_parted PARTITION (date=123)");
    PartitionName partitionName = new PartitionName(new RelationName("doc", "unknown_parted"), List.of("123"));
    assertThat(statement.restoreTables().size(), is(1));
    var table = statement.restoreTables().iterator().next();
    assertThat(table.partitionName(), is(partitionName));
    assertThat(table.tableIdent(), is(new RelationName(Schemas.DOC_SCHEMA_NAME, "unknown_parted")));
}
Also used : PartitionName(io.crate.metadata.PartitionName) RelationName(io.crate.metadata.RelationName) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 82 with RelationName

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

the class SnapshotRestoreAnalyzerTest method testRestoreSinglePartition.

@Test
public void testRestoreSinglePartition() throws Exception {
    BoundRestoreSnapshot statement = analyze(e, "RESTORE SNAPSHOT my_repo.my_snapshot TABLE parted PARTITION (date=123)");
    PartitionName partition = new PartitionName(new RelationName("doc", "parted"), List.of("123"));
    assertThat(statement.restoreTables().size(), is(1));
    var table = statement.restoreTables().iterator().next();
    assertThat(table.partitionName(), is(partition));
    assertThat(table.tableIdent(), is(new RelationName(Schemas.DOC_SCHEMA_NAME, "parted")));
    assertThat(statement.includeTables(), is(true));
    assertThat(statement.includeCustomMetadata(), is(false));
    assertThat(statement.includeGlobalSettings(), is(false));
}
Also used : PartitionName(io.crate.metadata.PartitionName) RelationName(io.crate.metadata.RelationName) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 83 with RelationName

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

the class CopyAnalyzerTest method testCopyToWithPartitionIdentAndWhereClause.

@Test
public void testCopyToWithPartitionIdentAndWhereClause() throws Exception {
    BoundCopyTo analysis = analyze("COPY parted PARTITION (date=1395874800000) WHERE id = 1 TO DIRECTORY '/tmp/foo'");
    String parted = new PartitionName(new RelationName("doc", "parted"), Collections.singletonList("1395874800000")).asIndexName();
    WhereClause where = analysis.whereClause();
    assertThat(where.partitions(), contains(parted));
    assertThat(where.query(), isFunction("op_="));
}
Also used : PartitionName(io.crate.metadata.PartitionName) RelationName(io.crate.metadata.RelationName) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 84 with RelationName

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

the class CopyAnalyzerTest method testCopyFromPartitionedTablePARTITIONKeywordValidArgs.

@Test
public void testCopyFromPartitionedTablePARTITIONKeywordValidArgs() throws Exception {
    BoundCopyFrom analysis = analyze("COPY parted PARTITION (date=1395874800000) FROM '/some/distant/file.ext'");
    String parted = new PartitionName(new RelationName("doc", "parted"), Collections.singletonList("1395874800000")).ident();
    assertThat(analysis.partitionIdent(), equalTo(parted));
}
Also used : PartitionName(io.crate.metadata.PartitionName) RelationName(io.crate.metadata.RelationName) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 85 with RelationName

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

the class CopyAnalyzerTest method testCopyToFileWithPartitionClause.

@Test
public void testCopyToFileWithPartitionClause() throws Exception {
    BoundCopyTo analysis = analyze("COPY parted PARTITION (date=1395874800000) TO DIRECTORY '/blah'");
    String parted = new PartitionName(new RelationName("doc", "parted"), Collections.singletonList("1395874800000")).asIndexName();
    assertThat(analysis.whereClause().partitions(), contains(parted));
}
Also used : PartitionName(io.crate.metadata.PartitionName) RelationName(io.crate.metadata.RelationName) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Aggregations

RelationName (io.crate.metadata.RelationName)180 Test (org.junit.Test)100 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)55 PartitionName (io.crate.metadata.PartitionName)47 Symbol (io.crate.expression.symbol.Symbol)42 Reference (io.crate.metadata.Reference)37 ColumnIdent (io.crate.metadata.ColumnIdent)31 AnalyzedRelation (io.crate.analyze.relations.AnalyzedRelation)21 ReferenceIdent (io.crate.metadata.ReferenceIdent)21 DocTableInfo (io.crate.metadata.doc.DocTableInfo)21 Map (java.util.Map)20 HashMap (java.util.HashMap)19 SqlExpressions (io.crate.testing.SqlExpressions)18 ArrayList (java.util.ArrayList)18 List (java.util.List)17 Before (org.junit.Before)17 DocTableRelation (io.crate.analyze.relations.DocTableRelation)13 SQLExecutor (io.crate.testing.SQLExecutor)11 CoordinatorTxnCtx (io.crate.metadata.CoordinatorTxnCtx)10 IndexTemplateMetadata (org.elasticsearch.cluster.metadata.IndexTemplateMetadata)10