Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporarily ignore MANAGED HMS tables on external storage location #2837

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/databricks/labs/ucx/hive_metastore/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ def what(self) -> What:
return What.UNKNOWN

def sql_migrate_external(self, target_table_key):
if self.object_type == "MANAGED":
return f"SYNC TABLE {escape_sql_identifier(target_table_key)} AS EXTERNAL FROM {escape_sql_identifier(self.key)};"
return f"SYNC TABLE {escape_sql_identifier(target_table_key)} FROM {escape_sql_identifier(self.key)};"

def sql_migrate_ctas_external(self, target_table_key, dst_table_location) -> str:
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/hive_metastore/test_table_migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_migrate_dbfs_root_tables_should_produce_proper_queries(ws):
in backend.queries
)
assert (
"SYNC TABLE `ucx_default`.`db1_dst`.`managed_mnt` FROM `hive_metastore`.`db1_src`.`managed_mnt`;"
"SYNC TABLE `ucx_default`.`db1_dst`.`managed_mnt` AS EXTERNAL FROM `hive_metastore`.`db1_src`.`managed_mnt`;"
in backend.queries
)
assert (
Expand All @@ -82,7 +82,7 @@ def test_migrate_dbfs_root_tables_should_produce_proper_queries(ws):
f"'{Table.UPGRADED_FROM_WS_PARAM}' = '12345');"
) in backend.queries
assert (
"SYNC TABLE `ucx_default`.`db1_dst`.`managed_other` FROM `hive_metastore`.`db1_src`.`managed_other`;"
"SYNC TABLE `ucx_default`.`db1_dst`.`managed_other` AS EXTERNAL FROM `hive_metastore`.`db1_src`.`managed_other`;"
in backend.queries
)
migrate_grants.apply.assert_called()
Expand Down
14 changes: 13 additions & 1 deletion tests/unit/hive_metastore/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_sql_managed_non_delta():
catalog="catalog",
database="db",
name="managed_table",
object_type="MANAGED",
object_type="EXTERNAL",
table_format="DELTA",
location="dbfs:/mnt/location/table",
),
Expand Down Expand Up @@ -98,6 +98,18 @@ def test_sql_managed_non_delta():
"new_catalog.db.external_table",
"SYNC TABLE `new_catalog`.`db`.`external_table` FROM `catalog`.`db`.`external_table`;",
),
(
Table(
catalog="catalog",
database="db",
name="external_managed_table",
object_type="MANAGED",
table_format="DELTA",
location="s3a://foo/bar",
),
"new_catalog.db.external_managed_table",
"SYNC TABLE `new_catalog`.`db`.`external_managed_table` AS EXTERNAL FROM `catalog`.`db`.`external_managed_table`;",
),
],
)
def test_uc_sql(table, target, query):
Expand Down