Skip to content

Improve handling of mixed type Gremlin results #592

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 3 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Starting with v1.31.6, this file will contain a record of major features and upd

- New notebooks showing Telco examples leveraging GNN and LLM ([Link to PR](https://github.com/aws/graph-notebook/pull/587))
- Path: 02-Neptune-ML > 03-Sample-Applications > 04-Telco-Networks
- Added KMS encryption support to NeptuneDB Notebook CloudFormation template (https://github.com/aws/graph-notebook/pull/590)
- Added KMS encryption support to NeptuneDB Notebook CloudFormation template ([Link to PR]https://github.com/aws/graph-notebook/pull/590)
- Improved handling of mixed type Gremlin results ([Link to PR]https://github.com/aws/graph-notebook/pull/592)

## Release 4.2.0 (April 4, 2024)

Expand Down
9 changes: 5 additions & 4 deletions src/graph_notebook/magics/graph_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,10 +1200,11 @@ def gremlin(self, line, cell, local_ns: dict = None):

mixed_results = False
if query_res:
# If the results set contains multiple datatypes, and the first result is a map, we need to insert a
# temp non-map first element, or we will get an error when creating the Dataframe.
if isinstance(query_res[0], dict) and len(query_res) > 1:
if not all(isinstance(x, dict) for x in query_res[1:]):
# If the results set contains multiple datatypes, and the first result is a map or list, we need to
# insert a temp string first element, or we will get an error when creating the Dataframe.
first_res_type = type(query_res[0])
if first_res_type in [dict, list, set] and len(query_res) > 1:
if not all(isinstance(x, first_res_type) for x in query_res[1:]):
mixed_results = True
query_res_deque = deque(query_res)
query_res_deque.appendleft('x')
Expand Down
Loading