michael-s-molina commented on code in PR #24176:
URL: https://github.com/apache/superset/pull/24176#discussion_r1204710408
##########
superset/common/query_context_processor.py:
##########
@@ -444,10 +460,47 @@ 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 = df.drop(columns=[self.AGGREGATED_JOIN_COLUMN])
+
+ return CachedTimeOffset(df=df, queries=queries, cache_keys=cache_keys)
+
+ def get_aggregated_join_column(
+ self, row: pd.Series, column_index: int, time_grain: str
+ ) -> str:
+ # weekly time grain
+ if "P1W" in time_grain:
+ if time_grain in (
+ WeeklyTimeGrain.WEEK_STARTING_SUNDAY,
+ WeeklyTimeGrain.WEEK_ENDING_SATURDAY,
+ ):
+ return row[column_index].strftime("%Y-W%U")
+ else:
+ return row[column_index].strftime("%Y-W%W")
+
+ # monthly time grain
+ elif "P1M" in time_grain:
+ return row[column_index].strftime("%Y-%m")
+
+ # quarterly time grain
+ elif "P3M" in time_grain:
+ return row[column_index].strftime("%Y-Q") +
str(row[column_index].quarter)
- 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)
+ # yearly time grain
+ return row[column_index].strftime("%Y")
Review Comment:
Hi @zhaoyongjie. Hope you're doing fine! This PR is still in draft mode,
that's why there's no description yet 😉
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]