ktmud commented on a change in pull request #15279:
URL: https://github.com/apache/superset/pull/15279#discussion_r668555651



##########
File path: superset/common/query_context.py
##########
@@ -101,21 +104,143 @@ def __init__(  # pylint: disable=too-many-arguments
             "result_format": self.result_format,
         }
 
-    def get_query_result(self, query_object: QueryObject) -> Dict[str, Any]:
-        """Returns a pandas dataframe based on the query object"""
+    @staticmethod
+    def left_join_on_dttm(
+        left_df: pd.DataFrame, right_df: pd.DataFrame
+    ) -> pd.DataFrame:
+        df = left_df.set_index(DTTM_ALIAS).join(right_df.set_index(DTTM_ALIAS))
+        df.reset_index(level=0, inplace=True)
+        return df
+
+    def processing_time_offsets(
+        self, df: pd.DataFrame, query_object: QueryObject,
+    ) -> Tuple[pd.DataFrame, List[str], List[Optional[str]]]:
+        # ensure query_object is immutable
+        query_object_clone = copy.copy(query_object)
+        rv_sql = []
+        cache_keys = []
+
+        time_offsets = query_object.time_offsets
+        outer_from_dttm = query_object.from_dttm
+        outer_to_dttm = query_object.to_dttm
+        for offset in time_offsets:

Review comment:
       > This is because the or operator does not reduce rows scan for the 
database engine. 
   
   It would reduce rows scanned if there are significant overlaps among the 
offset time periods. E.g. you query for two years of data and offset by 1 year.
   
   > unable to easily generate the final dataframe
   
   Isn't each sub-dataframe a between(start_time, end_time) filter on the query 
result dataframe? We should probably use pandas to handle the time periods and 
join by datetime index anyway, if we are not already doing that, so the split & 
join by time process shouldn't be that hard, either.




-- 
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]

Reply via email to