Search in sources :

Example 1 with Overwrite

use of org.apache.drill.metastore.mongo.operate.Overwrite in project drill by apache.

the class TestTablesOperationTransformer method testToOverwriteOperation.

@Test
public void testToOverwriteOperation() {
    TableMetadataUnit unit = TableMetadataUnit.builder().storagePlugin("dfs").workspace("tmp").tableName("nation").metadataType(MetadataType.TABLE.name()).metadataIdentifier("s1").build();
    List<Overwrite> operations = transformer.toOverwrite(Collections.singletonList(unit));
    InputDataTransformer<TableMetadataUnit> inputDataTransformer = ((MongoTables) metastore.tables()).transformer().inputData();
    Document expected = new Document();
    expected.append("storagePlugin", "dfs");
    expected.append("workspace", "tmp");
    expected.append("tableName", "nation");
    expected.append("metadataType", MetadataType.TABLE.name());
    expected.append("metadataIdentifier", "s1");
    assertEquals(new Document().append(MongoConfigConstants.ID, inputDataTransformer.createId(expected)), operations.get(0).filter());
    assertEquals(expected, operations.get(0).data().get(MongoConfigConstants.ID));
}
Also used : Overwrite(org.apache.drill.metastore.mongo.operate.Overwrite) TableMetadataUnit(org.apache.drill.metastore.components.tables.TableMetadataUnit) Document(org.bson.Document) Test(org.junit.Test)

Aggregations

TableMetadataUnit (org.apache.drill.metastore.components.tables.TableMetadataUnit)1 Overwrite (org.apache.drill.metastore.mongo.operate.Overwrite)1 Document (org.bson.Document)1 Test (org.junit.Test)1