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

fix: Handle nested fields from BigQuery source when getting default column_names #522

Merged

Conversation

ivanmkc
Copy link
Contributor

@ivanmkc ivanmkc commented Jul 1, 2021

Fixes 'ds.column_names doesn't contain nested fields in BigQuery table' issue.

According to the product team, only "leaf node" fields should be passed to AutoML tabular.

Added unit test for it.

Fixes b/191864144 🦕

@ivanmkc ivanmkc requested a review from a team as a code owner July 1, 2021 20:06
@product-auto-label product-auto-label bot added the api: aiplatform Issues related to the AI Platform API. label Jul 1, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jul 1, 2021
@ivanmkc ivanmkc requested a review from sirtorry July 1, 2021 20:06
@ivanmkc ivanmkc changed the title Handle nested fields from BigQuery source when getting default column_names [WIP] Handle nested fields from BigQuery source when getting default column_names Jul 1, 2021
@ivanmkc ivanmkc changed the title [WIP] Handle nested fields from BigQuery source when getting default column_names Handle nested fields from BigQuery source when getting default column_names Jul 1, 2021
@ivanmkc ivanmkc requested a review from tswast July 1, 2021 21:21
@ivanmkc ivanmkc force-pushed the imkc--tabular-default-bq-nested-columns branch from 549357e to e581093 Compare July 1, 2021 21:30
@ivanmkc ivanmkc changed the title Handle nested fields from BigQuery source when getting default column_names fix: Handle nested fields from BigQuery source when getting default column_names Jul 1, 2021
@ivanmkc ivanmkc requested a review from sasha-gitg July 1, 2021 21:52
Copy link
Contributor

@geraint0923 geraint0923 left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

@@ -40,7 +42,7 @@ class TabularDataset(datasets._Dataset):
)

@property
def column_names(self) -> List[str]:
Copy link
Member

Choose a reason for hiding this comment

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

Changing the return type introduces a breaking change. Perhaps convert back to list after after deduping with set. What is the scenario where the same column name is populated more than once? Assuming that's the motivation using set. Trying to understand if this is worth introducing a breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The set comparison is trivial because col_names are unique and order is not a factor.

List implies an order which is not relevant for column names and makes the unit tests a tiny (very tiny) bit more complicated to write.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see your point about a breaking change. What do you recommend?

Copy link
Member

Choose a reason for hiding this comment

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

I agree with the motivation to change the return type to a Set. Let's do the following:

  1. Leave the return type as List to avoid the breaking change.
  2. Proceed with this PR mainly as is.
  3. Open a ticket to track the return type change to Set.
  4. Tentatively plan to implement the return type change when we get closer to a larger breaking change and major version rev.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed on all points.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tracked in b/193044977

Copy link
Contributor Author

@ivanmkc ivanmkc Jul 7, 2021

Choose a reason for hiding this comment

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

I kept the private method return types as Set as I assume that it's acceptable to make breaking changes to private methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sasha-gitg made the changes.

tests/unit/aiplatform/test_datasets.py Outdated Show resolved Hide resolved
google/cloud/aiplatform/datasets/tabular_dataset.py Outdated Show resolved Hide resolved
@@ -1045,7 +1098,16 @@ def test_tabular_dataset_column_name_bq_with_creds(self, bq_client_mock):
def test_tabular_dataset_column_name_bigquery(self):
my_dataset = datasets.TabularDataset(dataset_name=_TEST_NAME)

assert my_dataset.column_names == ["column_1", "column_2"]
assert my_dataset.column_names == set(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sasha-gitg Using a set means that when I write a unit-test, I don't have to know about the implementation details on how the list is ordered.

There are workarounds, but using a set seems cleanest.

@ivanmkc ivanmkc force-pushed the imkc--tabular-default-bq-nested-columns branch from 40c6a30 to cc90645 Compare July 7, 2021 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: aiplatform Issues related to the AI Platform API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants