From 21a5a950866cbd3f4a0ecb3253ec9db732cad09c Mon Sep 17 00:00:00 2001 From: Michael Chin Date: Fri, 10 May 2024 20:21:58 -0700 Subject: [PATCH 1/3] Improve handling of mixed type Gremlin results --- src/graph_notebook/magics/graph_magic.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/graph_notebook/magics/graph_magic.py b/src/graph_notebook/magics/graph_magic.py index 0d28cc96..74100d6d 100644 --- a/src/graph_notebook/magics/graph_magic.py +++ b/src/graph_notebook/magics/graph_magic.py @@ -1202,8 +1202,9 @@ def gremlin(self, line, cell, local_ns: dict = None): 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:]): + 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') From 44f82a44bba716c4f0c8736377c780c8ca880a38 Mon Sep 17 00:00:00 2001 From: Michael Chin Date: Fri, 10 May 2024 20:29:25 -0700 Subject: [PATCH 2/3] update comment --- src/graph_notebook/magics/graph_magic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/graph_notebook/magics/graph_magic.py b/src/graph_notebook/magics/graph_magic.py index 74100d6d..e6d83d03 100644 --- a/src/graph_notebook/magics/graph_magic.py +++ b/src/graph_notebook/magics/graph_magic.py @@ -1200,8 +1200,8 @@ 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 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:]): From a49999bfa4bf56355962e9a478c2921641e8972b Mon Sep 17 00:00:00 2001 From: Michael Chin Date: Fri, 10 May 2024 20:30:33 -0700 Subject: [PATCH 3/3] update changelog --- ChangeLog.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 18f42eb3..8561ea34 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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)