File tree Expand file tree Collapse file tree 2 files changed +96
-0
lines changed
packages/cubejs-testing/test Expand file tree Collapse file tree 2 files changed +96
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,40 @@ Array [
9696]
9797` ;
9898
99+ exports [` SQL API Postgres (Data) measure with ad-hoc filter and original measure: measure-with-ad-hoc-filters-and-original-measure 1` ] = `
100+ Array [
101+ Object {
102+ " new_amount" : 300 ,
103+ " total_amount" : 1700 ,
104+ } ,
105+ ]
106+ ` ;
107+
108+ exports [` SQL API Postgres (Data) measure with ad-hoc filter: measure-with-ad-hoc-filters 1` ] = `
109+ Array [
110+ Object {
111+ " new_amount" : 300 ,
112+ } ,
113+ ]
114+ ` ;
115+
116+ exports [` SQL API Postgres (Data) measure with replaced aggregation and original measure: measure-with-replaced-aggregation-and-original-measure 1` ] = `
117+ Array [
118+ Object {
119+ " min_amount" : 100 ,
120+ " sum_amount" : 1700 ,
121+ } ,
122+ ]
123+ ` ;
124+
125+ exports [` SQL API Postgres (Data) measure with replaced aggregation: measure-with-replaced-aggregation 1` ] = `
126+ Array [
127+ Object {
128+ " min_amount" : 100 ,
129+ } ,
130+ ]
131+ ` ;
132+
99133exports [` SQL API Postgres (Data) metabase max number: metabase max number 1` ] = `
100134Array [
101135 Object {
Original file line number Diff line number Diff line change @@ -660,5 +660,67 @@ filter_subq AS (
660660 const res = await connection . query ( query ) ;
661661 expect ( res . rows ) . toMatchSnapshot ( 'query-view-deep-joins' ) ;
662662 } ) ;
663+
664+ test ( 'measure with replaced aggregation' , async ( ) => {
665+ const query = `
666+ SELECT
667+ MIN(totalAmount) AS min_amount
668+ FROM
669+ Orders
670+ ` ;
671+
672+ const res = await connection . query ( query ) ;
673+ expect ( res . rows ) . toMatchSnapshot ( 'measure-with-replaced-aggregation' ) ;
674+ } ) ;
675+
676+ test ( 'measure with replaced aggregation and original measure' , async ( ) => {
677+ const query = `
678+ SELECT
679+ SUM(totalAmount) AS sum_amount,
680+ MIN(totalAmount) AS min_amount
681+ FROM
682+ Orders
683+ ` ;
684+
685+ const res = await connection . query ( query ) ;
686+ expect ( res . rows ) . toMatchSnapshot ( 'measure-with-replaced-aggregation-and-original-measure' ) ;
687+ } ) ;
688+
689+ test ( 'measure with ad-hoc filter' , async ( ) => {
690+ const query = `
691+ SELECT
692+ SUM(
693+ CASE status = 'new'
694+ WHEN TRUE
695+ THEN totalAmount
696+ ELSE NULL
697+ END
698+ ) AS new_amount
699+ FROM
700+ Orders
701+ ` ;
702+
703+ const res = await connection . query ( query ) ;
704+ expect ( res . rows ) . toMatchSnapshot ( 'measure-with-ad-hoc-filters' ) ;
705+ } ) ;
706+
707+ test ( 'measure with ad-hoc filter and original measure' , async ( ) => {
708+ const query = `
709+ SELECT
710+ SUM(totalAmount) AS total_amount,
711+ SUM(
712+ CASE status = 'new'
713+ WHEN TRUE
714+ THEN totalAmount
715+ ELSE NULL
716+ END
717+ ) AS new_amount
718+ FROM
719+ Orders
720+ ` ;
721+
722+ const res = await connection . query ( query ) ;
723+ expect ( res . rows ) . toMatchSnapshot ( 'measure-with-ad-hoc-filters-and-original-measure' ) ;
724+ } ) ;
663725 } ) ;
664726} ) ;
You can’t perform that action at this time.
0 commit comments