diff --git a/insights/insights/doctype/insights_data_source_v3/ibis_utils.py b/insights/insights/doctype/insights_data_source_v3/ibis_utils.py index 3eb0085e5..b0c875497 100644 --- a/insights/insights/doctype/insights_data_source_v3/ibis_utils.py +++ b/insights/insights/doctype/insights_data_source_v3/ibis_utils.py @@ -740,6 +740,16 @@ def get_current_columns(self): return {col: getattr(self.query, col) for col in self.query.schema().names} +<<<<<<< HEAD +======= +def clamp(value, lo: int, hi: int) -> int: + try: + return max(lo, min(int(value), hi)) + except (TypeError, ValueError): + return lo + + +>>>>>>> 3eef8111 (fix: update max page_size (#1020)) def execute_ibis_query( query: IbisQuery, limit=100, @@ -749,6 +759,15 @@ def execute_ibis_query( reference_doctype=None, reference_name=None, ): +<<<<<<< HEAD +======= + if hasattr(query, "limit"): + page_size = clamp(page_size, 1, 10_000) + page = clamp(page, 1, 10_000) + offset = (page - 1) * page_size + query = query.limit(page_size, offset=offset) + +>>>>>>> 3eef8111 (fix: update max page_size (#1020)) try: sql = ibis.to_sql(query) except ibis.common.exceptions.OperationNotDefinedError: