@Override public Schema schema() { return current.schema(); }
@Override public Schema schema() { return ops.current().schema(); }
SchemaUpdate(TableOperations ops) { this.ops = ops; this.base = ops.current(); this.schema = base.schema(); this.lastColumnId = base.lastColumnId(); }
SchemaParser.toJson(metadata.schema(), generator);
ops.current().schema(), deleteExpression);
(int) currentTimeMillis / 1000, Integer.MAX_VALUE, storageDescriptor(metadata.schema()), Collections.emptyList(), new HashMap<>(), tbl.setSd(storageDescriptor(metadata.schema())); // set to pickup any schema changes final String metadataLocation = tbl.getParameters().get(METADATA_LOCATION_PROP); if (!Objects.equals(currentMetadataLocation(), metadataLocation)) {
SchemaParser.toJson(metadata.schema(), generator);
private void verifyMetadata(TableMetadata read) { Assert.assertEquals(EXPECTED.schema().asStruct(), read.schema().asStruct()); Assert.assertEquals(EXPECTED.location(), read.location()); Assert.assertEquals(EXPECTED.lastColumnId(), read.lastColumnId()); Assert.assertEquals(EXPECTED.properties(), read.properties()); }
@Override public List<ManifestFile> apply(TableMetadata base) { if (validateAddedFiles) { PartitionSpec spec = writeSpec(); Expression rowFilter = rowFilter(); Expression inclusiveExpr = Projections.inclusive(spec).project(rowFilter); Evaluator inclusive = new Evaluator(spec.partitionType(), inclusiveExpr); Expression strictExpr = Projections.strict(spec).project(rowFilter); Evaluator strict = new Evaluator(spec.partitionType(), strictExpr); StrictMetricsEvaluator metrics = new StrictMetricsEvaluator( base.schema(), rowFilter); for (DataFile file : addedFiles()) { // the real test is that the strict or metrics test matches the file, indicating that all // records in the file match the filter. inclusive is used to avoid testing the metrics, // which is more complicated ValidationException.check( inclusive.eval(file.partition()) && (strict.eval(file.partition()) || metrics.eval(file)), "Cannot append file with rows that do not match filter: %s: %s", rowFilter, file.path()); } } return super.apply(base); } }
@Test public void testCreateTransaction() throws IOException { File tableDir = temp.newFolder(); Assert.assertTrue(tableDir.delete()); Transaction t = TestTables.beginCreate(tableDir, "test_create", SCHEMA, unpartitioned()); Assert.assertNull("Starting a create transaction should not commit metadata", TestTables.readMetadata("test_create")); Assert.assertNull("Should have no metadata version", TestTables.metadataVersion("test_create")); t.commitTransaction(); TableMetadata meta = TestTables.readMetadata("test_create"); Assert.assertNotNull("Table metadata should be created after transaction commits", meta); Assert.assertEquals("Should have metadata version 0", 0, (int) TestTables.metadataVersion("test_create")); Assert.assertEquals("Should have 0 manifest files", 0, listManifestFiles(tableDir).size()); Assert.assertEquals("Table schema should match with reassigned IDs", assignFreshIds(SCHEMA).asStruct(), meta.schema().asStruct()); Assert.assertEquals("Table spec should match", unpartitioned(), meta.spec()); Assert.assertEquals("Table should not have any snapshots", 0, meta.snapshots().size()); }
assignFreshIds(SCHEMA).asStruct(), meta.schema().asStruct()); Assert.assertEquals("Table spec should match", unpartitioned(), meta.spec()); Assert.assertEquals("Table should not have any snapshots", 0, meta.snapshots().size());
PartitionSpec newSpec = PartitionSpec.builderFor(base.schema()) .bucket("data", 16) .bucket("id", 4)
PartitionSpec newSpec = PartitionSpec.builderFor(base.schema()) .bucket("data", 16) .bucket("id", 4)
assignFreshIds(SCHEMA).asStruct(), meta.schema().asStruct()); Assert.assertEquals("Table spec should match", unpartitioned(), meta.spec()); Assert.assertEquals("Table should not have any snapshots", 0, meta.snapshots().size());
@Test public void testCreateAndAppendWithTransaction() throws IOException { File tableDir = temp.newFolder(); Assert.assertTrue(tableDir.delete()); Transaction t = TestTables.beginCreate(tableDir, "test_append", SCHEMA, unpartitioned()); Assert.assertNull("Starting a create transaction should not commit metadata", TestTables.readMetadata("test_append")); Assert.assertNull("Should have no metadata version", TestTables.metadataVersion("test_append")); t.newAppend() .appendFile(FILE_A) .appendFile(FILE_B) .commit(); Assert.assertNull("Appending in a transaction should not commit metadata", TestTables.readMetadata("test_append")); Assert.assertNull("Should have no metadata version", TestTables.metadataVersion("test_append")); t.commitTransaction(); TableMetadata meta = TestTables.readMetadata("test_append"); Assert.assertNotNull("Table metadata should be created after transaction commits", meta); Assert.assertEquals("Should have metadata version 0", 0, (int) TestTables.metadataVersion("test_append")); Assert.assertEquals("Should have 1 manifest file", 1, listManifestFiles(tableDir).size()); Assert.assertEquals("Table schema should match with reassigned IDs", assignFreshIds(SCHEMA).asStruct(), meta.schema().asStruct()); Assert.assertEquals("Table spec should match", unpartitioned(), meta.spec()); Assert.assertEquals("Table should have one snapshot", 1, meta.snapshots().size()); validateSnapshot(null, meta.currentSnapshot(), FILE_A, FILE_B); }
assignFreshIds(SCHEMA).asStruct(), meta.schema().asStruct()); Assert.assertEquals("Table spec should match", unpartitioned(), meta.spec()); Assert.assertEquals("Table should have one snapshot", 1, meta.snapshots().size());
assignFreshIds(SCHEMA).asStruct(), meta.schema().asStruct()); Assert.assertEquals("Table spec should match", unpartitioned(), meta.spec()); Assert.assertEquals("Table should have one snapshot", 1, meta.snapshots().size());