Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat: enable local json string validations #1614

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

Merged
merged 4 commits into from
Apr 18, 2025

Conversation

chelsea-lin
Copy link
Contributor

Fixes internal issue 401055880 🦕

@chelsea-lin chelsea-lin requested review from a team as code owners April 12, 2025 05:05
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Apr 12, 2025
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. label Apr 12, 2025
@chelsea-lin chelsea-lin force-pushed the main_chelsealin_jsonlocalvalid branch 2 times, most recently from 8f9e7bc to 7dc54ae Compare April 12, 2025 05:19
@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: m Pull request size is medium. labels Apr 12, 2025
@GarrettWu GarrettWu removed their assignment Apr 15, 2025
@chelsea-lin chelsea-lin force-pushed the main_chelsealin_jsonlocalvalid branch 3 times, most recently from 3de56f1 to 6643f93 Compare April 17, 2025 21:21
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Apr 17, 2025
@chelsea-lin chelsea-lin force-pushed the main_chelsealin_jsonlocalvalid branch 2 times, most recently from fbe0d40 to f668cce Compare April 17, 2025 21:31
@chelsea-lin chelsea-lin added the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 17, 2025
@@ -150,6 +151,38 @@ def validate(self):
f"Field {bf_field} has arrow array type: {arrow_type}, expected type: {expected_arrow_type}"
)

if include_context:
Copy link
Contributor

Choose a reason for hiding this comment

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

content, not context

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Thanks for catching that.

values = array.to_pandas()
for data in values:
# Skip scalar null values to avoid `TypeError` from json.load.
if not utils.is_list_like(data) and pd.isna(data):
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't everything a string or a null? how do you get a list-like?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now, the data is formatted using pyarrow storage, so these checks are no longer necessary. They are only required to handle values like None, or [] in pandas.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re-adding null value checks to ensure compatibility with Python 3.9 tests.

@@ -329,3 +362,15 @@ def _physical_type_replacements(dtype: pa.DataType) -> pa.DataType:
if dtype in _ARROW_MANAGED_STORAGE_OVERRIDES:
return _ARROW_MANAGED_STORAGE_OVERRIDES[dtype]
return dtype


def _is_valid_json_series(s: pd.Series):
Copy link
Contributor

Choose a reason for hiding this comment

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

can drop this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Dropped.

@bigframes-bot bigframes-bot removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Apr 17, 2025
@chelsea-lin chelsea-lin force-pushed the main_chelsealin_jsonlocalvalid branch from 3cea4f7 to 58e672a Compare April 17, 2025 23:10
@chelsea-lin chelsea-lin force-pushed the main_chelsealin_jsonlocalvalid branch from 58e672a to 772e490 Compare April 18, 2025 16:36
@chelsea-lin chelsea-lin merged commit 233347a into main Apr 18, 2025
23 of 24 checks passed
@chelsea-lin chelsea-lin deleted the main_chelsealin_jsonlocalvalid branch April 18, 2025 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the googleapis/python-bigquery-dataframes API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants