From eb321ba347ea5fa2791c6e122156148374ac55ed Mon Sep 17 00:00:00 2001 From: rusackas Date: Mon, 10 Aug 2026 13:12:12 -0700 Subject: [PATCH] fix(common): remove unsupported "cross" join mode from left_join_df left_join_df's how parameter advertised Literal["left", "right", "inner", "outer", "cross"], but the join is implemented via DataFrame.set_index(...).join(...), whose underlying Index.join does not support "cross" the way pd.merge does -- passing how="cross" silently drops the join keys instead of producing a real cross join. Narrow the type to the modes that are actually supported. _perform_join in models/helpers.py forwards its own how parameter straight into left_join_df, so its signature is narrowed the same way to stay consistent. Follow-up to #41334. Co-Authored-By: Claude --- superset/common/utils/dataframe_utils.py | 7 +++++-- superset/models/helpers.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/superset/common/utils/dataframe_utils.py b/superset/common/utils/dataframe_utils.py index 630ed1df3b74..d85fabc5ded2 100644 --- a/superset/common/utils/dataframe_utils.py +++ b/superset/common/utils/dataframe_utils.py @@ -32,12 +32,15 @@ def left_join_df( join_keys: list[str], lsuffix: str = "", rsuffix: str = "", - how: Literal["left", "right", "inner", "outer", "cross"] = "left", + how: Literal["left", "right", "inner", "outer"] = "left", ) -> pd.DataFrame: # `how` defaults to "left" so callers that only want the left frame's rows are # unaffected. Passing how="outer" keeps right-only rows, which is used by the # time-comparison "full range" option so historical series are not truncated to - # the main series' time range. + # the main series' time range. "cross" is intentionally excluded: the join is + # implemented via `Index.join`, which doesn't support cross joins the way + # `pd.merge` does, so passing "cross" here would silently drop the join keys + # instead of producing a real cross join. df = left_df.set_index(join_keys).join( right_df.set_index(join_keys), how=how, lsuffix=lsuffix, rsuffix=rsuffix ) diff --git a/superset/models/helpers.py b/superset/models/helpers.py index aeb9e79a21a0..eac9da084ca1 100644 --- a/superset/models/helpers.py +++ b/superset/models/helpers.py @@ -2705,7 +2705,7 @@ def _perform_join( df: pd.DataFrame, offset_df: pd.DataFrame, actual_join_keys: list[str], - how: Literal["left", "right", "inner", "outer", "cross"] = "left", + how: Literal["left", "right", "inner", "outer"] = "left", ) -> pd.DataFrame: """Perform the appropriate join operation.""" if actual_join_keys: