@@ -224,3 +224,120 @@ async fn cubescan_limit_offset_limit_offset() {
224224 ) ;
225225 }
226226}
227+
228+ /// Test that LIMIT 0 is pushed to grouped CubeScan
229+ #[ tokio:: test]
230+ async fn cubescan_limit_zero ( ) {
231+ init_testing_logger ( ) ;
232+
233+ let query_plan = convert_select_to_query_plan (
234+ // language=PostgreSQL
235+ r#"
236+ SELECT
237+ customer_gender
238+ FROM
239+ KibanaSampleDataEcommerce
240+ GROUP BY
241+ 1
242+ LIMIT 0
243+ "#
244+ . to_string ( ) ,
245+ DatabaseProtocol :: PostgreSQL ,
246+ )
247+ . await ;
248+
249+ let logical_plan = query_plan. as_logical_plan ( ) ;
250+ assert_eq ! (
251+ logical_plan. find_cube_scan( ) . request,
252+ V1LoadRequestQuery {
253+ measures: Some ( vec![ ] ) ,
254+ dimensions: Some ( vec![ "KibanaSampleDataEcommerce.customer_gender" . to_string( ) ] ) ,
255+ segments: Some ( vec![ ] ) ,
256+ order: Some ( vec![ ] ) ,
257+ limit: Some ( 0 ) ,
258+ ..Default :: default ( )
259+ }
260+ ) ;
261+ }
262+
263+ /// Test that LIMIT 0 is pushed to ungrouped CubeScan
264+ #[ tokio:: test]
265+ async fn cubescan_ungrouped_limit_zero ( ) {
266+ init_testing_logger ( ) ;
267+
268+ let query_plan = convert_select_to_query_plan (
269+ // language=PostgreSQL
270+ r#"
271+ SELECT
272+ customer_gender
273+ FROM
274+ KibanaSampleDataEcommerce
275+ LIMIT 0
276+ "#
277+ . to_string ( ) ,
278+ DatabaseProtocol :: PostgreSQL ,
279+ )
280+ . await ;
281+
282+ let logical_plan = query_plan. as_logical_plan ( ) ;
283+ assert_eq ! (
284+ logical_plan. find_cube_scan( ) . request,
285+ V1LoadRequestQuery {
286+ measures: Some ( vec![ ] ) ,
287+ dimensions: Some ( vec![ "KibanaSampleDataEcommerce.customer_gender" . to_string( ) ] ) ,
288+ segments: Some ( vec![ ] ) ,
289+ order: Some ( vec![ ] ) ,
290+ limit: Some ( 0 ) ,
291+ ungrouped: Some ( true ) ,
292+ ..Default :: default ( )
293+ }
294+ ) ;
295+ }
296+
297+ /// Test that LIMIT 0 is pushed to CubeScan for SELECT *
298+ #[ tokio:: test]
299+ async fn cubescan_star_limit_zero ( ) {
300+ init_testing_logger ( ) ;
301+
302+ let query_plan = convert_select_to_query_plan (
303+ // language=PostgreSQL
304+ r#"
305+ SELECT
306+ *
307+ FROM
308+ KibanaSampleDataEcommerce
309+ LIMIT 0
310+ "#
311+ . to_string ( ) ,
312+ DatabaseProtocol :: PostgreSQL ,
313+ )
314+ . await ;
315+
316+ let logical_plan = query_plan. as_logical_plan ( ) ;
317+ assert_eq ! (
318+ logical_plan. find_cube_scan( ) . request,
319+ V1LoadRequestQuery {
320+ measures: Some ( vec![
321+ "KibanaSampleDataEcommerce.count" . to_string( ) ,
322+ "KibanaSampleDataEcommerce.maxPrice" . to_string( ) ,
323+ "KibanaSampleDataEcommerce.sumPrice" . to_string( ) ,
324+ "KibanaSampleDataEcommerce.minPrice" . to_string( ) ,
325+ "KibanaSampleDataEcommerce.avgPrice" . to_string( ) ,
326+ "KibanaSampleDataEcommerce.countDistinct" . to_string( ) ,
327+ ] ) ,
328+ dimensions: Some ( vec![
329+ "KibanaSampleDataEcommerce.order_date" . to_string( ) ,
330+ "KibanaSampleDataEcommerce.last_mod" . to_string( ) ,
331+ "KibanaSampleDataEcommerce.customer_gender" . to_string( ) ,
332+ "KibanaSampleDataEcommerce.notes" . to_string( ) ,
333+ "KibanaSampleDataEcommerce.taxful_total_price" . to_string( ) ,
334+ "KibanaSampleDataEcommerce.has_subscription" . to_string( ) ,
335+ ] ) ,
336+ segments: Some ( vec![ ] ) ,
337+ order: Some ( vec![ ] ) ,
338+ limit: Some ( 0 ) ,
339+ ungrouped: Some ( true ) ,
340+ ..Default :: default ( )
341+ }
342+ ) ;
343+ }
0 commit comments