File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed
packages/cubejs-testing/test Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,19 @@ Array [
7070]
7171` ;
7272
73+ exports [` SQL API Postgres (Data) join with grouped query on coalesce: join grouped on coalesce 1` ] = `
74+ Array [
75+ Object {
76+ " count" : " 2" ,
77+ " status" : " processed" ,
78+ } ,
79+ Object {
80+ " count" : " 1" ,
81+ " status" : " shipped" ,
82+ } ,
83+ ]
84+ ` ;
85+
7386exports [` SQL API Postgres (Data) join with grouped query: join grouped 1` ] = `
7487Array [
7588 Object {
Original file line number Diff line number Diff line change @@ -535,6 +535,36 @@ filter_subq AS (
535535 expect ( res . rows ) . toMatchSnapshot ( 'join grouped with filter' ) ;
536536 } ) ;
537537
538+ test ( 'join with grouped query on coalesce' , async ( ) => {
539+ const query = `
540+ SELECT
541+ "Orders".status AS status,
542+ COUNT(*) AS count
543+ FROM
544+ "Orders"
545+ INNER JOIN
546+ (
547+ SELECT
548+ status,
549+ SUM(totalAmount)
550+ FROM
551+ "Orders"
552+ GROUP BY 1
553+ ORDER BY 2 DESC
554+ LIMIT 2
555+ ) top_orders
556+ ON
557+ (COALESCE("Orders".status, '') = COALESCE(top_orders.status, '')) AND
558+ (("Orders".status IS NOT NULL) = (top_orders.status IS NOT NULL))
559+ GROUP BY 1
560+ ORDER BY 1
561+ ` ;
562+
563+ const res = await connection . query ( query ) ;
564+ // Expect only top statuses 2 by total amount: processed and shipped
565+ expect ( res . rows ) . toMatchSnapshot ( 'join grouped on coalesce' ) ;
566+ } ) ;
567+
538568 test ( 'where segment is false' , async ( ) => {
539569 const query =
540570 '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