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

[AIRFLOW-3490] BigQueryHook's Ability to Patch Table/View #4299

Merged
merged 8 commits into from
Jan 25, 2019

Conversation

ryanyuan
Copy link
Contributor

@ryanyuan ryanyuan commented Dec 10, 2018

Add patch_table() to BQHook, and its unit tests

Make sure you have checked all steps below.

Jira

  • My PR addresses the following Airflow-3490 issues and references them in the PR title.

Description

  • Here are some details about my PR, including screenshots of any UI changes:
    Add patch_table() to BigQueryBaseCursor in BigQueryHook so that it has ability to patch tables and patch views.

Tests

  • My PR adds the following unit tests OR does not need testing for this extremely good reason:
    tests.contrib.hooks.test_bigquery_hook:TestBigQueryBaseCursor.test_patch_table
    tests.contrib.hooks.test_bigquery_hook:TestBigQueryBaseCursor.test_patch_view

Commits

  • My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Documentation

  • In case of new functionality, my PR adds documentation that describes how to use it.
    • When adding new operators/hooks/sensors, the autoclass documentation generation needs to be added.
    • All the public functions and the classes in the PR contain docstrings that explain what it does

Code Quality

  • Passes flake8

@ryanyuan
Copy link
Contributor Author

Hi @kaxil, could you please review this?
The Travis just threw some random errors. First time it failed in python2 docker with sqlite. The second time it failed in python3 k8s with postgres.

@codecov-io
Copy link

codecov-io commented Dec 10, 2018

Codecov Report

Merging #4299 into master will decrease coverage by 3.83%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4299      +/-   ##
==========================================
- Coverage   78.59%   74.76%   -3.84%     
==========================================
  Files         204      428     +224     
  Lines       16453    29638   +13185     
==========================================
+ Hits        12932    22159    +9227     
- Misses       3521     7479    +3958
Impacted Files Coverage Δ
airflow/contrib/hooks/bigquery_hook.py 57.5% <88.88%> (ø)
airflow/www/blueprints.py 92.85% <0%> (-7.15%) ⬇️
airflow/operators/dagrun_operator.py 94.73% <0%> (-1.42%) ⬇️
airflow/utils/cli_action_loggers.py 73.33% <0%> (-0.87%) ⬇️
airflow/bin/cli.py 64.76% <0%> (-0.27%) ⬇️
airflow/www_rbac/utils.py 73.95% <0%> (-0.14%) ⬇️
airflow/api/common/experimental/mark_tasks.py 97.6% <0%> (-0.06%) ⬇️
airflow/models/__init__.py 92.54% <0%> (-0.06%) ⬇️
airflow/www_rbac/app.py 97.05% <0%> (-0.03%) ⬇️
airflow/www/app.py 98.95% <0%> (-0.02%) ⬇️
... and 246 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 11a36d1...beef08f. Read the comment docs.

view=None):
"""
Patch information in an existing table/view.
Schema changes can only be applied to tables, not views.
Copy link
Member

Choose a reason for hiding this comment

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

This needs to support more than just updating schema as done by the api https://cloud.google.com/bigquery/docs/reference/rest/v2/tables/patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kaxil Updated. Please review.

Add more parameters to patch_table to support more information to be patched

:param project_id: The project containing the table to be patched.
:type project_id: str
:param dataset_id: The dataset containing the tableto be patched.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
:param dataset_id: The dataset containing the tableto be patched.
:param dataset_id: The dataset containing the table to be patched.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kaxil Changed.

def patch_table(self,
dataset_id,
table_id,
project_id=None,
Copy link
Member

Choose a reason for hiding this comment

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

I have updated this as project_id can be None as we take that info from the connection.

Can you update the tests accordingly.

Update BigQueryHook's patch_table tests for optional project_id
@kaxil kaxil merged commit db06d4f into apache:master Jan 25, 2019
@kaxil
Copy link
Member

kaxil commented Jan 25, 2019

Thanks @ryanyuan

@ryanyuan
Copy link
Contributor Author

Thanks @ryanyuan

Thank you @kaxil

ashb pushed a commit to ashb/airflow that referenced this pull request Mar 27, 2019
wmorris75 pushed a commit to modmed/incubator-airflow that referenced this pull request Jul 29, 2019
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.

3 participants