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

[DF-314] Adding method to drop columns from a table #30

Merged
merged 4 commits into from
Dec 11, 2020
Merged

Conversation

jufreire
Copy link
Contributor

Why? 📖

We want to encapsulate logic to drop columns from a table in hive using thrift client classes.

What? 🔧

  • Added drop_columns_from_table method in HiveMetastoreClient to encapsulate logic of getting table object representation from hive, removing columns from the list of columns and calling alter table to drop the columns.
  • Added example on how to use the drop_columns_from_table method.
  • Added unit tests.

Type of change 🗄️

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How everything was tested? 📏

Running locally and with unit tests.

Checklist 📝

  • I have added labels to distinguish the type of pull request.
  • My code follows the style guidelines of this project (docstrings, type hinting and linter compliance);
  • I have performed a self-review of my own code;
  • I have made corresponding changes to the documentation;
  • I have added tests that prove my fix is effective or that my feature works;
  • I have made sure that new and existing unit tests pass locally with my changes;

@jufreire jufreire requested a review from a team as a code owner December 10, 2020 18:53
@jufreire jufreire self-assigned this Dec 10, 2020
@jufreire jufreire added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 10, 2020

mocked_return_get_table = Mock()
mocked_return_get_table.sd.cols = []
mocked_get_table.return_value = mocked_return_get_table
Copy link
Contributor

@LucasMMota LucasMMota Dec 10, 2020

Choose a reason for hiding this comment

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

in this test the get table returns a table with no columns, then you try to delete the cols ["col1", "col2"]. This test could be improved because it isn't testing the cols list that is being removed.

I think this test could have a parameterize that tests the callings of mocked_alter_table with the cols list. To test your for (this test is missing).

About the for looping (from lines 100 to 104) testing: if you think that it applies you can move the for into a separate function and test it separately too.


# assert
mocked_get_table.assert_called_once_with(dbname=db_name, tbl_name=table_name)
mocked_alter_table.assert_called_once_with(
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont get how this test is working. The new_tbl arg from mocked_alter_table should not be equal mocked_return_get_table because the new_table should have only the column col3.

Copy link
Contributor

Choose a reason for hiding this comment

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

As I could see running the test, pytest doesn't validate the Mock object properties.
This is the reason it's working (even with the mocked_return_get_table in new_tbl having the 3 columns) .
But, since you added the assert in line 125, I think it's ok =]

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest we fix this, since it is wrong anyway :(
I will add a commit to adjust this test

LucasMMota
LucasMMota previously approved these changes Dec 11, 2020
felipemiquelim
felipemiquelim previously approved these changes Dec 11, 2020
Copy link
Contributor

@felipemiquelim felipemiquelim left a comment

Choose a reason for hiding this comment

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

LGTM

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@felipemiquelim felipemiquelim merged commit d258830 into main Dec 11, 2020
@felipemiquelim felipemiquelim deleted the DF-314 branch December 11, 2020 14:39
@felipemiquelim felipemiquelim mentioned this pull request Dec 11, 2020
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants