john-bodley commented on code in PR #24176: URL: https://github.com/apache/superset/pull/24176#discussion_r1212110157
########## superset/common/query_context_processor.py: ########## @@ -74,6 +74,19 @@ stats_logger: BaseStatsLogger = config["STATS_LOGGER"] logger = logging.getLogger(__name__) +AGGREGATED_JOIN_COLUMN = "__aggregated_join_column" + +AGGREGATED_JOIN_GRAINS = { Review Comment: @michael-s-molina how are other time grains—day, hour, minute, etc.—handled? ########## superset/db_engine_specs/base.py: ########## @@ -63,6 +63,7 @@ from typing_extensions import TypedDict from superset import security_manager, sql_parse +from superset.constants import TimeGrain as TimeGrainConstants Review Comment: Why do we need to alias `TimeGrain` here? ########## superset/common/query_context_processor.py: ########## @@ -444,10 +467,48 @@ def processing_time_offsets( # pylint: disable=too-many-locals,too-many-stateme datasource_uid=query_context.datasource.uid, region=CacheRegion.DATA, ) - rv_dfs.append(offset_slice) + offset_dfs.append(offset_metrics_df) + + if offset_dfs: + # iterate on offset_dfs, left join each with df + for offset_df in offset_dfs: + df = dataframe_utils.left_join_df( + left_df=df, + right_df=offset_df, + join_keys=join_keys, + rsuffix="_right", + ) + + # remove AGGREGATED_JOIN_COLUMN from df + if use_aggregated_join_column: + df.drop(columns=[AGGREGATED_JOIN_COLUMN], inplace=True) - rv_df = pd.concat(rv_dfs, axis=1, copy=False) if time_offsets else df - return CachedTimeOffset(df=rv_df, queries=queries, cache_keys=cache_keys) + return CachedTimeOffset(df=df, queries=queries, cache_keys=cache_keys) + + @staticmethod + def get_aggregated_join_column( + row: pd.Series, column_index: int, time_grain: str Review Comment: Should `time_grain` be defined as `TimeGrain` rather than `str`? ########## superset/db_engine_specs/ascend.py: ########## @@ -16,6 +16,7 @@ # under the License. from sqlalchemy.dialects import registry +from superset.constants import TimeGrain Review Comment: Nice! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org