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
fix: Handle nested fields from BigQuery source when getting default column_names #522
Conversation
…s to return a Set instead of a List
549357e
to
e581093
Compare
There was a problem hiding this 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]: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
- Leave the return type as List to avoid the breaking change.
- Proceed with this PR mainly as is.
- Open a ticket to track the return type change to Set.
- Tentatively plan to implement the return type change when we get closer to a larger breaking change and major version rev.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed on all points.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tracked in b/193044977
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@@ -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( |
There was a problem hiding this comment.
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.
…ot introduce a breaking change at this time
40c6a30
to
cc90645
Compare
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 🦕