Skip to content

Commit

Permalink
Merge branch 'main' into feat/creat_account_groups
Browse files Browse the repository at this point in the history
  • Loading branch information
william-conti authored Feb 27, 2024
2 parents 3c27160 + 76bdff9 commit 2898b56
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 14 deletions.
20 changes: 8 additions & 12 deletions src/databricks/labs/ucx/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,11 @@ def replace_inventory_variable(self, text: str) -> str:

@classmethod
def v1_migrate(cls, raw: dict) -> dict:
stored_version = raw.pop("version", None)
if stored_version == cls.__version__:
return raw
if stored_version == 1:
raw["include_group_names"] = (
raw.get("groups", {"selected": []})["selected"] if "selected" in raw["groups"] else None
)
raw["renamed_group_prefix"] = raw.get("groups", {"backup_group_prefix": "db-temp-"})["backup_group_prefix"]
raw.pop("groups", None)
return raw
msg = f"Unknown config version: {stored_version}"
raise ValueError(msg)
# See https://github.com/databrickslabs/ucx/blob/v0.5.0/src/databricks/labs/ucx/config.py#L16-L32
groups = raw.pop("groups", {})
selected_groups = groups.get("selected", [])
if selected_groups:
raw["include_group_names"] = selected_groups
raw["renamed_group_prefix"] = groups.get("backup_group_prefix", "db-temp-")
raw["version"] = 2
return raw
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ WITH table_stats AS (
WHEN STARTSWITH(location, "adl") THEN 1
ELSE 0
END AS is_unsupported,
IF(format = "DELTA", 1, 0) AS is_delta
IF(table_format = "DELTA", 1, 0) AS is_delta
FROM $inventory.tables
), database_stats AS (
SELECT `database`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SELECT CONCAT(tables.`database`, '.', tables.name) AS name,
WHEN STARTSWITH(location, "adl") THEN "UNSUPPORTED"
ELSE "EXTERNAL"
END AS storage,
IF(format = "DELTA", "Yes", "No") AS is_delta,
IF(table_format = "DELTA", "Yes", "No") AS is_delta,
location,
CASE
WHEN size_in_bytes IS null THEN "Non DBFS Root"
Expand Down
30 changes: 30 additions & 0 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from databricks.labs.blueprint.installation import MockInstallation

from databricks.labs.ucx.config import WorkspaceConfig


def test_v1_migrate_zeroconf():
installation = MockInstallation(
{'config.yml': {'inventory_database': 'x', 'groups': {}, 'connect': {'host': 'a', 'token': 'b'}}}
)

workspace_config = installation.load(WorkspaceConfig)

assert workspace_config.renamed_group_prefix == 'db-temp-'


def test_v1_migrate_some_conf():
installation = MockInstallation(
{
'config.yml': {
'inventory_database': 'x',
'groups': {'selected': ['foo', 'bar'], 'backup_group_prefix': 'some-'},
'connect': {'host': 'a', 'token': 'b'},
}
}
)

workspace_config = installation.load(WorkspaceConfig)

assert workspace_config.renamed_group_prefix == 'some-'
assert workspace_config.include_group_names == ['foo', 'bar']

0 comments on commit 2898b56

Please sign in to comment.