szehon-ho commented on a change in pull request #2266:
URL: https://github.com/apache/iceberg/pull/2266#discussion_r605749944



##########
File path: python/tests/hive/test_hive_tables.py
##########
@@ -157,3 +154,84 @@ def test_create_tables(client, current_call, 
base_scan_schema, base_scan_partiti
     current_call.return_value = tbl[0].args[0].parameters['metadata_location']
 
     tables.load("test.test_123")
+
+
[email protected]("iceberg.hive.HiveTableOperations.refresh_from_metadata_location")
[email protected]("iceberg.hive.HiveTableOperations.current")
[email protected]("iceberg.hive.HiveTables.get_client")
+def test_drop_tables(client, metadata, refresh_call, tmpdir):
+
+    parameters = {"table_type": "ICEBERG",
+                  "partition_spec": [],
+                  "metadata_location": "s3://path/to/iceberg.metadata.json"}
+
+    client.return_value.__enter__.return_value.get_table.return_value = 
MockHMSTable(parameters)
+    conf = {"hive.metastore.uris": 'thrift://hms:port',
+            "hive.metastore.warehouse.dir": tmpdir}
+    tables = HiveTables(conf)
+    tables.drop("test", "test_123", purge=False)
+    
client.return_value.__enter__.return_value.drop_table.assert_called_with("test",
 "test_123", deleteData=False)
+
+
[email protected]("iceberg.hive.HiveTableOperations.refresh_from_metadata_location")
[email protected]("iceberg.hive.HiveTables.new_table_ops")
[email protected]("iceberg.hive.HiveTables.get_client")
+def test_drop_tables_purge(client, current_ops, refresh_call, tmpdir):
+    mock_snapshots = [MockSnapshot(location="snap-a.avro",
+                                   manifests=[
+                                       MockManifest("a-manifest.avro"),
+                                       MockManifest("b-manifest.avro")],
+                                   manifest_to_entries={
+                                       "a-manifest.avro": MockReader(
+                                           [MockManifestEntry("a.parquet"),
+                                            MockManifestEntry("b.parquet")]),
+                                       "b-manifest.avro": MockReader(
+                                           [MockManifestEntry("c.parquet"),
+                                            MockManifestEntry("d.parquet")])
+                                   }),
+                      MockSnapshot(location="snap-b.avro",
+                                   manifests=[
+                                       MockManifest("b-manifest.avro"),
+                                       MockManifest("c-manifest.avro"),
+                                       MockManifest("d-manifest.avro")],
+                                   manifest_to_entries={
+                                       "b-manifest.avro": MockReader(
+                                           [MockManifestEntry("c.parquet"),
+                                            MockManifestEntry("d.parquet")]),
+                                       "c-manifest.avro": MockReader(
+                                           [MockManifestEntry("e.parquet"),
+                                            MockManifestEntry("f.parquet")]),
+                                       "d-manifest.avro": MockReader(
+                                           [MockManifestEntry("g.parquet"),
+                                            MockManifestEntry("h.parquet")])
+                                   })
+                      ]
+    ops = MockTableOperations(MockMetadata(mock_snapshots), "a.json")
+    current_ops.return_value = ops
+
+    parameters = {"table_type": "ICEBERG",
+                  "partition_spec": [],
+                  "metadata_location": "s3://path/to/iceberg.metadata.json"}
+    client.return_value.__enter__.return_value.get_table.return_value = 
MockHMSTable(parameters)
+
+    conf = {"hive.metastore.uris": 'thrift://hms:port',
+            "hive.metastore.warehouse.dir": tmpdir}
+    tables = HiveTables(conf)
+    tables.drop("test", "test_123", purge=True)
+
+    assert len(ops.deleted) == len(set(ops.deleted)), "Paths should only be 
deleted once"

Review comment:
       Validation for files referred to multiple times by various snapshots




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to