Skip to content

Conversation

manikrishna-m
Copy link
Contributor

Summary:

This change fixes a ValueError in the _serialize_value_for_sql function when trying to serialize lists or arrays. The function previously failed with arrays, as pd.isna would return a boolean array, triggering the error "The truth value of an array with more than one element is ambiguous".

What was changed:

  • The function now checks if value is a list or np.ndarray before calling pd.isna(). Lists/arrays are serialized into a SQL array format instead of being processed by pd.isna().
  • This prevents the error and ensures arrays and lists are properly serialized for SQL queries.

Testing:

  • The patch was tested by adding several test cases (arrays, lists, and scalar values) to ensure the function handles all types correctly.
  • Unit tests were run to confirm no regressions.

Justification:

This fix ensures that when _serialize_value_for_sql encounters lists or arrays, they are correctly serialized into SQL format instead of causing errors. It improves the robustness of the tool when interacting with arrays in SQL serialization.

Fixes issue #343.

@google-cla
Copy link

google-cla bot commented Sep 18, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@mstyer-google mstyer-google merged commit 47b0830 into google:main Oct 6, 2025
4 checks passed
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.

2 participants