Repository navigation
fix(episode): allow null elements in numeric list columns in to_arrow (#662) #664
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,7 +136,9 @@ def _is_numeric_sequence(value: Any) -> bool: | |
| if isinstance(value, np.ndarray): | ||
| return value.size > 0 and value.dtype.kind in "iuf" | ||
| if isinstance(value, (list, tuple)): | ||
| return len(value) > 0 and _is_numeric_scalar(value[0]) | ||
| for item in value: | ||
| if item is not None: | ||
| return _is_numeric_scalar(item) | ||
|
Comment on lines
+139
to
+141
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Knowledge Base Used: Episode storage and identity |
||
| return False | ||
|
|
||
|
|
||
|
|
@@ -154,7 +156,9 @@ def _is_arrow_scalar(value: Any) -> bool: | |
| def _is_empty_sequence(value: Any) -> bool: | ||
| if isinstance(value, np.ndarray): | ||
| return value.size == 0 | ||
| return isinstance(value, (list, tuple)) and len(value) == 0 | ||
| if isinstance(value, (list, tuple)): | ||
| return len(value) == 0 or all(item is None for item in value) | ||
|
Comment on lines
+159
to
+160
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An all-null list now counts as having no shape during the column check. If another message has a scalar in the same field, Knowledge Base Used: Episode storage and identity |
||
| return False | ||
|
|
||
|
|
||
| def _arrow_field_values(messages: Sequence[Any]) -> dict[str, list[Any]]: | ||
|
|
@@ -213,7 +217,7 @@ def _arrow_column_values(topic: str, field_name: str, values: Sequence[Any]) -> | |
| # An empty numeric array keeps its dtype, so it types the column. | ||
| saw_list = True | ||
| elif _is_empty_sequence(value): | ||
| # `[]` carries no element type; an empty numeric ndarray above | ||
| # `[]` or an all-null sequence carries no element type; an empty numeric ndarray above | ||
| # does. Keep the slot null unless a typed sample arrives. | ||
| continue | ||
| else: | ||
|
|
||
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.
A JSON list like
[null, 1.0, {"note": "bad"}]is now marked numeric because its first non-null item is a number. If every sample of that field has this shape,to_arrow()used to skip the nested field. Now it sends the mixed list to Arrow, which cannot make a numeric list from it, so the caller loses the whole table. Check the later items before marking the list numeric.Knowledge Base Used: Episode storage and identity