From 87483883de9a85cd21aef63b1be2cd2573e299fb Mon Sep 17 00:00:00 2001 From: Aneesh Durg Date: Fri, 22 Dec 2023 11:23:30 -0600 Subject: [PATCH] Attempt to avoid object type in unwind --- spycy/spycy.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spycy/spycy.py b/spycy/spycy.py index 71953ef..694a021 100755 --- a/spycy/spycy.py +++ b/spycy/spycy.py @@ -274,7 +274,6 @@ def get_var_expr(f): for alias, proj in group_by_keys.items(): expr = proj.oC_Expression() group_by_columns[alias] = self.evaluate_expr(expr) - def get_key(row): def get_tuple(value): if isinstance(value, Node): @@ -404,6 +403,14 @@ def _process_unwind(self, node: CypherParser.OC_UnwindContext): mask.append(value is not pd.NA and len(value) > 0) self.table = self.table[mask] self.table = self.table.explode(alias, ignore_index=True) + try: + new_col = self.table[alias] + types = {type(x) for x in new_col} + if len(types) == 1: + casted_col = new_col.astype(list(types)[0]) + self.table[alias] = casted_col + except (TypeError, ValueError): + pass def _build_intial_match_result_for_row( self, row: int, pgraph: pattern_graph.Graph