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

Add to_bigquery() function to BigQueryRetrievalJob #1634

Merged
merged 7 commits into from
Jun 16, 2021

Conversation

vtao2
Copy link
Contributor

@vtao2 vtao2 commented Jun 10, 2021

What this PR does / why we need it:
This PR adds a to_bigquery() function to the BigQueryRetrievalJob class so that get_historical_features() can scale. This way, instead of writing to a dataframe (resulting in a Response too large to return error), we can write to a temporary destination table in BigQuery.

Without this, get_historical_features() does not scale. It is unable to return a large dataset (eg: ~5B rows) as this data is too big for dataframes.

Which issue(s) this PR fixes:

Fixes #1637

Does this PR introduce a user-facing change?:

Adding a `to_bigquery()` method to BigQueryRetrievalJob

@feast-ci-bot
Copy link
Collaborator

Hi @vtao2. Thanks for your PR.

I'm waiting for a feast-dev member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@mavysavydav
Copy link
Collaborator

Could we add a parameter for dry run in the method? QueryJobConfig has a dry_run option

@MattDelac
Copy link
Collaborator

Could we add a parameter for dry run in the method? QueryJobConfig has a dry_run option

Hi @mavysavydav ,

What would be the dry-run used for ? When would that be used with Feast CLI commands ?
This sounds like out of scope for this PR no ?

@vtao2 vtao2 changed the title Vt/to bigquery function Add to_bigquery() function to BigQueryRetrievalJob Jun 14, 2021
@vtao2
Copy link
Contributor Author

vtao2 commented Jun 15, 2021

/retest

print(
"This query will process {} bytes.".format(bq_job.total_bytes_processed)
)
return path
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we just return nothing when we asked for a dry_run ? I don't understand the utility of the path if the table never been created. What I am missing 🤔 ?

if dry_run:
    return

...
return path

It just means that this function will output an Optional[str]

def to_bigquery(self, dry_run=False) -> Optional[str]:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point :) changed :D

@@ -441,6 +441,23 @@ def test_historical_features_from_bigquery_sources(
],
)

# Just a dry run, should not create table
bq_dry_run = job_from_sql.to_bigquery(dry_run=True)
with pytest.raises(Exception):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you have access to a more accurate exception like TableNotFound ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually, since we won't return the path, can just test that nothing is returned when calling dry run :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed it to reflect that

Copy link
Collaborator

@MattDelac MattDelac left a comment

Choose a reason for hiding this comment

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

LGTM

@vtao2
Copy link
Contributor Author

vtao2 commented Jun 15, 2021

/retest

@codecov-commenter
Copy link

codecov-commenter commented Jun 15, 2021

Codecov Report

Merging #1634 (d2090f2) into master (b32e766) will increase coverage by 0.14%.
The diff coverage is 96.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1634      +/-   ##
==========================================
+ Coverage   83.39%   83.54%   +0.14%     
==========================================
  Files          71       71              
  Lines        6113     6173      +60     
==========================================
+ Hits         5098     5157      +59     
- Misses       1015     1016       +1     
Flag Coverage Δ
integrationtests 83.46% <96.87%> (+0.14%) ⬆️
unittests 76.25% <15.62%> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
sdk/python/feast/infra/offline_stores/bigquery.py 86.45% <95.65%> (+0.99%) ⬆️
sdk/python/tests/test_historical_retrieval.py 98.98% <100.00%> (+0.04%) ⬆️
sdk/python/tests/test_online_retrieval.py 100.00% <0.00%> (ø)
sdk/python/feast/online_response.py 97.43% <0.00%> (+0.21%) ⬆️

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 b32e766...d2090f2. Read the comment docs.

@woop
Copy link
Member

woop commented Jun 15, 2021

@vtao2 Just a small nitpick, but I noticed we're deleting our commits and force pushing the same commit message. This makes it impossible to see the history of changes and also leads to broken links which makes reviews hard, for example https://github.com/feast-dev/feast/pull/1634/files/6b6398530c69f221629b837225be2870fde75263..4cb2f010de767e8d1aef827c0446a0b968baded9

sdk/python/setup.py Outdated Show resolved Hide resolved
Signed-off-by: Vivian Tao <[email protected]>
@feast-ci-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: MattDelac, vtao2, woop

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@woop
Copy link
Member

woop commented Jun 16, 2021

/lgtm

@feast-ci-bot feast-ci-bot merged commit 3c46a4d into feast-dev:master Jun 16, 2021
tsotnet pushed a commit that referenced this pull request Jun 17, 2021
* Add to_bigquery() function for bq retrieval job

Signed-off-by: Vivian Tao <[email protected]>

* Using tenacity for retries

Signed-off-by: Vivian Tao <[email protected]>

* Refactoring to_biquery function

Signed-off-by: Vivian Tao <[email protected]>

* Adding tenacity dependency and changing temp table prefix to historical

Signed-off-by: Vivian Tao <[email protected]>

* Use self.client instead of creating a new client

Signed-off-by: Vivian Tao <[email protected]>

* pin tenacity to major version

Signed-off-by: Vivian Tao <[email protected]>

* Tenacity dependency range

Signed-off-by: Vivian Tao <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add to_bq() to BigQueryRetrievalJob
6 participants