Skip to content

Commit

Permalink
Merge pull request #123 from mabel-dev/FIX/#119
Browse files Browse the repository at this point in the history
Fix/#119
  • Loading branch information
joocer committed May 15, 2022
2 parents 6f540a0 + cad95c9 commit ce3adda
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/Release Notes/Change Log.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- [#112](https://github.com/mabel-dev/opteryx/issues/112) `SHOW COLUMNS` doesn't work for non sample datasets ([@joocer](https://github.com/joocer]))
- [#113](https://github.com/mabel-dev/opteryx/issues/113) Sample data has NaN as a string, rather than the value ([@joocer](https://github.com/joocer]))
- [#111](https://github.com/mabel-dev/opteryx/issues/111) `CROSS JOIN UNNEST` should return a `NONE` when the list is empty (or `NONE`) ([@joocer](https://github.com/joocer]))
- [#119](https://github.com/mabel-dev/opteryx/issues/119) 'NoneType' object is not iterable error on `UNNEST` ([@joocer](https://github.com/joocer]))


### [0.0.1] - 2022-05-09
Expand Down
5 changes: 4 additions & 1 deletion opteryx/engine/planner/operations/cross_join_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ def _cross_join_unnest(left, column, alias):

metadata = None

if alias is None:
alias = f"UNNEST({column[0]})"

for left_page in left:

if metadata is None:
Expand All @@ -149,7 +152,7 @@ def _cross_join_unnest(left, column, alias):
new_column = []
for i, value in enumerate(column_data):
# if the value isn't valid, we can't UNNEST it
if value.is_valid:
if value.is_valid and len(value.values) != 0:
indexes.extend([i] * len(value))
new_column.extend(value)
else:
Expand Down
2 changes: 1 addition & 1 deletion opteryx/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
2) we can import it in setup.py for the same reason
"""

__version__ = "0.0.2-beta.3"
__version__ = "0.0.2-beta.4"
10 changes: 10 additions & 0 deletions tests/data/unnest_test/year_2000/month_01/day_01/unnest_test.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ "id": 0, "values": [""] }
{ "id": 1, "values": [] }
{ "id": 2, "values": [null] }
{ "id": 3, "values": null }
{ "id": 4, "values": [] }
{ "id": 5, "values": ["value", null] }
{ "id": 6, "values": [null, "value"] }
{ "id": 7, "values": ["value1", "value2", "value3"] }
{ "id": 8, "values": [null, null] }
{ "id": 9 }
2 changes: 2 additions & 0 deletions tests/sql_battery/test_battery_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@
("SELECT * FROM $planets LEFT JOIN $satellites ON $satellites.planetId = $planets.id ORDER BY $planets.name", 179, 28),
# NAMED SUBQUERIES
("SELECT P.name FROM ( SELECT * FROM $planets ) AS P", 9, 1),
# UNNEST
("SELECT * FROM tests.data.unnest_test CROSS JOIN UNNEST (values) AS value FOR '2000-01-01'", 15, 3),
]
# fmt:on

Expand Down

0 comments on commit ce3adda

Please sign in to comment.