From e6e5305f52d0947ee605959005433d0893e1edaa Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Wed, 17 Jul 2024 10:56:07 +0100 Subject: [PATCH] lisa.trace: Support polars 1.2.0 FIX JSON format for LazyFrame.serialize() has slightly changed since 1.1.0. --- lisa/trace.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lisa/trace.py b/lisa/trace.py index d19e8a619..9db083ad3 100644 --- a/lisa/trace.py +++ b/lisa/trace.py @@ -252,9 +252,24 @@ def _logical_plan_update_paths(plan, update_path): except KeyError: return fixup_scans(obj.values()) else: + # Polars 1.2.0 has a slightly changed format where + # scan['paths'] is no longer a plain list[str]. It is a + # list[list[str] | bool]. This function handles both formats. + def dispatch_update(paths): + if isinstance(paths, str): + path = paths + return str(update_path(path)) + elif isinstance(paths, Iterable): + return [ + dispatch_update(path) + for path in paths + ] + else: + return paths + scan['paths'] = [ - str(update_path(path)) - for path in scan['paths'] + dispatch_update(paths) + for paths in scan['paths'] ] elif isinstance(obj, str): return -- GitLab