File tree Expand file tree Collapse file tree 2 files changed +132
-0
lines changed
packages/cubejs-testing/test Expand file tree Collapse file tree 2 files changed +132
-0
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,71 @@ Array [
232232]
233233` ;
234234
235+ exports [` SQL API Postgres (Data) select __user and literal grouped under wrapper: select __user and literal in wrapper 1` ] = `
236+ Array [
237+ Object {
238+ " my_literal" : " 1" ,
239+ " my_status" : " new" ,
240+ " my_user" : null ,
241+ } ,
242+ Object {
243+ " my_literal" : " 1" ,
244+ " my_status" : " processed" ,
245+ " my_user" : null ,
246+ } ,
247+ Object {
248+ " my_literal" : " 1" ,
249+ " my_status" : " shipped" ,
250+ " my_user" : null ,
251+ } ,
252+ ]
253+ ` ;
254+
255+ exports [` SQL API Postgres (Data) select __user and literal grouped: select __user and literal 1` ] = `
256+ Array [
257+ Object {
258+ " Int64(2)" : " 2" ,
259+ " __cubeJoinField" : null ,
260+ " id" : 1 ,
261+ " my_literal" : " 1" ,
262+ " my_status" : " new" ,
263+ " my_user" : null ,
264+ } ,
265+ Object {
266+ " Int64(2)" : " 2" ,
267+ " __cubeJoinField" : null ,
268+ " id" : 2 ,
269+ " my_literal" : " 1" ,
270+ " my_status" : " new" ,
271+ " my_user" : null ,
272+ } ,
273+ Object {
274+ " Int64(2)" : " 2" ,
275+ " __cubeJoinField" : null ,
276+ " id" : 3 ,
277+ " my_literal" : " 1" ,
278+ " my_status" : " processed" ,
279+ " my_user" : null ,
280+ } ,
281+ Object {
282+ " Int64(2)" : " 2" ,
283+ " __cubeJoinField" : null ,
284+ " id" : 4 ,
285+ " my_literal" : " 1" ,
286+ " my_status" : " processed" ,
287+ " my_user" : null ,
288+ } ,
289+ Object {
290+ " Int64(2)" : " 2" ,
291+ " __cubeJoinField" : null ,
292+ " id" : 5 ,
293+ " my_literal" : " 1" ,
294+ " my_status" : " shipped" ,
295+ " my_user" : null ,
296+ } ,
297+ ]
298+ ` ;
299+
235300exports [` SQL API Postgres (Data) select null in subquery with streaming 1` ] = `
236301Array [
237302 Object {
Original file line number Diff line number Diff line change @@ -404,6 +404,73 @@ describe('SQL API', () => {
404404 expect ( res . rows ) . toEqual ( [ { max : null } ] ) ;
405405 } ) ;
406406
407+ test ( 'select __user and literal grouped' , async ( ) => {
408+ const query = `
409+ SELECT
410+ status AS my_status,
411+ __user AS my_user,
412+ 1 AS my_literal,
413+ -- Columns without aliases should also work
414+ id,
415+ __cubeJoinField,
416+ 2
417+ FROM
418+ Orders
419+ GROUP BY 1,2,3,4,5,6
420+ ORDER BY 1,2,3,4,5,6
421+ ` ;
422+
423+ const res = await connection . query ( query ) ;
424+ expect ( res . rows ) . toMatchSnapshot ( 'select __user and literal' ) ;
425+ } ) ;
426+
427+ test ( 'select __user and literal grouped under wrapper' , async ( ) => {
428+ const query = `
429+ WITH
430+ -- This subquery should be represented as CubeScan(ungrouped=false) inside CubeScanWrapper
431+ cube_scan_subq AS (
432+ SELECT
433+ status AS my_status,
434+ __user AS my_user,
435+ 1 AS my_literal,
436+ -- Columns without aliases should also work
437+ id,
438+ __cubeJoinField,
439+ 2
440+ FROM Orders
441+ GROUP BY 1,2,3,4,5,6
442+ ),
443+ filter_subq AS (
444+ SELECT
445+ status status_filter
446+ FROM Orders
447+ GROUP BY
448+ status_filter
449+ )
450+ SELECT
451+ -- Should use SELECT * here to reference columns without aliases.
452+ -- But it's broken ATM in DF, initial plan contains \`Projection: ... #__subquery-0.logs_content_filter\` on top, but it should not be there
453+ -- TODO fix it
454+ my_status,
455+ my_user,
456+ my_literal
457+ FROM cube_scan_subq
458+ WHERE
459+ -- This subquery filter should trigger wrapping of whole query
460+ my_status IN (
461+ SELECT
462+ status_filter
463+ FROM filter_subq
464+ )
465+ GROUP BY 1,2,3
466+ ORDER BY 1,2,3
467+ ;
468+ ` ;
469+
470+ const res = await connection . query ( query ) ;
471+ expect ( res . rows ) . toMatchSnapshot ( 'select __user and literal in wrapper' ) ;
472+ } ) ;
473+
407474 test ( 'where segment is false' , async ( ) => {
408475 const query =
409476 'SELECT value AS val, * FROM "SegmentTest" WHERE segment_eq_1 IS FALSE ORDER BY value;' ;
You can’t perform that action at this time.
0 commit comments