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

Added databricks labs ucx revert-migrated-table command #729

Merged
merged 15 commits into from
Dec 28, 2023

Conversation

FastLee
Copy link
Contributor

@FastLee FastLee commented Dec 22, 2023

closes #671
revert-migrated-table scans HMS for tables marked as upgraded.
Looking for the upgraded_to property.
Clears the upgraded_to property to revert the table and allow it to be migrated again.
--schema and --table params are optional and allow scoping the command down to a schema or a single table.

Copy link

codecov bot commented Dec 22, 2023

Codecov Report

Attention: 21 lines in your changes are missing coverage. Please review.

Comparison is base (6c89e67) 79.43% compared to head (365de62) 79.45%.

Files Patch % Lines
src/databricks/labs/ucx/cli.py 11.11% 16 Missing ⚠️
src/databricks/labs/ucx/hive_metastore/tables.py 94.25% 1 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #729      +/-   ##
==========================================
+ Coverage   79.43%   79.45%   +0.01%     
==========================================
  Files          42       42              
  Lines        4411     4516     +105     
  Branches      819      845      +26     
==========================================
+ Hits         3504     3588      +84     
- Misses        693      710      +17     
- Partials      214      218       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@FastLee FastLee force-pushed the feature/revert_migrated_table_671 branch from 9c8f5b2 to 1c9dd4e Compare December 22, 2023 18:31
@FastLee FastLee marked this pull request as ready for review December 22, 2023 19:01
@FastLee FastLee requested review from a team and HariGS-DB December 22, 2023 19:01
@FastLee FastLee force-pushed the feature/revert_migrated_table_671 branch from 8c1bdef to f353a41 Compare December 22, 2023 19:39
Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing integration tests

src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
tests/unit/test_cli.py Outdated Show resolved Hide resolved
Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is incorrect and has some bugs

src/databricks/labs/ucx/cli.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
tests/integration/hive_metastore/test_migrate.py Outdated Show resolved Hide resolved
tests/integration/hive_metastore/test_migrate.py Outdated Show resolved Hide resolved
tests/integration/hive_metastore/test_migrate.py Outdated Show resolved Hide resolved
tests/integration/hive_metastore/test_migrate.py Outdated Show resolved Hide resolved
tests/unit/hive_metastore/test_migrate.py Outdated Show resolved Hide resolved
tests/unit/hive_metastore/test_migrate.py Outdated Show resolved Hide resolved
@nfx
Copy link
Contributor

nfx commented Dec 23, 2023

@FastLee dont we have to remove the table from UC as well?

@FastLee
Copy link
Contributor Author

FastLee commented Dec 24, 2023

@FastLee dont we have to remove the table from UC as well?

I wouldn't mess with removing the table (for now)

@nfx
Copy link
Contributor

nfx commented Dec 24, 2023

I wouldn't mess with removing the table (for now)

@FastLee but then we'd have a corrupt state - HMS thinks table is not migrated, but UC has it migrated already. Incorrect behavior.

Perhaps tune the logic the following way:

  • If table is managed, prevent any reverts
  • if table is external, prompt confirmation before we remove the table and update table properties

Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments were not addressed

src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
tests/integration/hive_metastore/test_migrate.py Outdated Show resolved Hide resolved
tests/integration/hive_metastore/test_migrate.py Outdated Show resolved Hide resolved
tests/integration/hive_metastore/test_migrate.py Outdated Show resolved Hide resolved
tests/integration/hive_metastore/test_migrate.py Outdated Show resolved Hide resolved
tests/integration/hive_metastore/test_migrate.py Outdated Show resolved Hide resolved
Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still has incorrect code

labs.yml Outdated Show resolved Hide resolved
labs.yml Outdated Show resolved Hide resolved
src/databricks/labs/ucx/cli.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/cli.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/cli.py Outdated Show resolved Hide resolved
Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Fix codecov checks to pass
  • invoke real migration methods in the integration tests, not fake
  • see other minor comments, that still have to be addressed

It might be ready for merge after that

labs.yml Outdated Show resolved Hide resolved
labs.yml Outdated Show resolved Hide resolved
src/databricks/labs/ucx/cli.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
tests/integration/conftest.py Outdated Show resolved Hide resolved
tests/integration/hive_metastore/test_migrate.py Outdated Show resolved Hide resolved
Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Add more unit tests to fix codecov failing checks

tests/integration/conftest.py Outdated Show resolved Hide resolved
src/databricks/labs/ucx/hive_metastore/tables.py Outdated Show resolved Hide resolved
Copy link
Contributor

@nfx nfx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some unit tests are incorrect because they change private state instead of mocking depending component interactions

tests/unit/hive_metastore/test_migrate.py Outdated Show resolved Hide resolved
tests/unit/hive_metastore/test_migrate.py Outdated Show resolved Hide resolved
tests/unit/hive_metastore/test_migrate.py Show resolved Hide resolved
@nfx nfx changed the title CLI Command databricks labs ucx revert-migrated-table Added databricks labs ucx revert-migrated-table command Dec 28, 2023
@nfx nfx merged commit 473f137 into main Dec 28, 2023
7 checks passed
@nfx nfx deleted the feature/revert_migrated_table_671 branch December 28, 2023 09:02
nfx added a commit that referenced this pull request Dec 28, 2023
* Added `databricks labs ucx repair-run --step ...` CLI command for repair run of any failed workflows, like `assessment`, `migrate-groups` etc. ([#724](#724)).
* Added `databricks labs ucx revert-migrated-table` command ([#729](#729)).
* Allow specifying a group list when group match options are used ([#725](#725)).
* Fixed installation issue when upgrading from an older version of the tool and improve logs ([#740](#740)).
* Renamed summary panel from Failure Summary to Assessment Summary ([#733](#733)).
* Retry internal error when getting permissions and update legacy table ACL documentation ([#728](#728)).
* Speedup installer execution ([#727](#727)).
@nfx nfx mentioned this pull request Dec 28, 2023
nfx added a commit that referenced this pull request Dec 28, 2023
* Added `databricks labs ucx repair-run --step ...` CLI command for
repair run of any failed workflows, like `assessment`, `migrate-groups`
etc. ([#724](#724)).
* Added `databricks labs ucx revert-migrated-table` command
([#729](#729)).
* Allow specifying a group list when group match options are used
([#725](#725)).
* Fixed installation issue when upgrading from an older version of the
tool and improve logs
([#740](#740)).
* Renamed summary panel from Failure Summary to Assessment Summary
([#733](#733)).
* Retry internal error when getting permissions and update legacy table
ACL documentation
([#728](#728)).
* Speedup installer execution
([#727](#727)).
HariGS-DB pushed a commit that referenced this pull request Jan 2, 2024
* Added `databricks labs ucx repair-run --step ...` CLI command for
repair run of any failed workflows, like `assessment`, `migrate-groups`
etc. ([#724](#724)).
* Added `databricks labs ucx revert-migrated-table` command
([#729](#729)).
* Allow specifying a group list when group match options are used
([#725](#725)).
* Fixed installation issue when upgrading from an older version of the
tool and improve logs
([#740](#740)).
* Renamed summary panel from Failure Summary to Assessment Summary
([#733](#733)).
* Retry internal error when getting permissions and update legacy table
ACL documentation
([#728](#728)).
* Speedup installer execution
([#727](#727)).
FastLee pushed a commit that referenced this pull request Jan 19, 2024
* Added `databricks labs ucx repair-run --step ...` CLI command for
repair run of any failed workflows, like `assessment`, `migrate-groups`
etc. ([#724](#724)).
* Added `databricks labs ucx revert-migrated-table` command
([#729](#729)).
* Allow specifying a group list when group match options are used
([#725](#725)).
* Fixed installation issue when upgrading from an older version of the
tool and improve logs
([#740](#740)).
* Renamed summary panel from Failure Summary to Assessment Summary
([#733](#733)).
* Retry internal error when getting permissions and update legacy table
ACL documentation
([#728](#728)).
* Speedup installer execution
([#727](#727)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add databricks labs ucx revert-migrate-tables command
2 participants