@@ -127,14 +127,21 @@ export function useQueriedChartConfig(
127127 queryFn : streamedQuery ( {
128128 streamFn : context =>
129129 fetchDataInChunks ( config , clickhouseClient , context . signal ) ,
130+ /**
131+ * This mode ensures that data remains in the cache until the next full streamed result is available.
132+ * By default, the cache would be cleared before new data starts arriving, which results in the query briefly
133+ * going back into the loading/pending state when multiple observers are sharing the query result resulting
134+ * in flickering or render loops.
135+ */
136+ refetchMode : 'replace' ,
137+ initialValue : { data : [ ] , meta : [ ] , rows : 0 } as TQueryFnData ,
130138 reducer : ( acc , chunk ) => {
131139 return {
132140 data : [ ...( acc ?. data || [ ] ) , ...( chunk . data || [ ] ) ] ,
133141 meta : chunk . meta ,
134142 rows : ( acc ?. rows || 0 ) + ( chunk . rows || 0 ) ,
135143 } ;
136144 } ,
137- initialValue : { data : [ ] , meta : [ ] , rows : 0 } as TQueryFnData ,
138145 } ) ,
139146 retry : 1 ,
140147 refetchOnWindowFocus : false ,
@@ -144,23 +151,17 @@ export function useQueriedChartConfig(
144151 if ( query . isError && options ?. onError ) {
145152 options . onError ( query . error ) ;
146153 }
154+
147155 return query ;
148156}
149157
150158// TODO: Can we always search backwards or do we need to support forwards too?
151- // TODO: Check if this is impacted by timezones or DST changes
152- // TODO: What happens if date range is not provided? --> No pagination, or a default pagination?
153- // - In the sidebar onboarding checklist component
154- // - where else?
159+ // TODO: Check if this is impacted by timezones or DST changes --> Everything UTC? Should be fine.
155160// TODO: See if we can combine this with the useOffsetPaginatedQuery stuff
156161// TODO: How does live mode affect this?
157162// TODO: Can we remove the IS_MTVIEWS_ENABLED stuff?
158163// TODO: How is caching working?
159- // TODO: Granularity not provided --> use any default, or is this every automatically added?
160- // - In the patterns table
161- // - where else?
162- // TODO: What if we group by something that isn't a date?
163- // - Probably OK if we are also grouping by time, but not OK if we aren't also grouping by time?
164+ // Test that this works as expected with no pagination in place (eg. no granularity or no date range)
164165
165166export function useRenderedSqlChartConfig (
166167 config : ChartConfigWithOptDateRange ,
0 commit comments