1+ import { getEnv } from '@cubejs-backend/shared' ;
12import { BaseQuery , PostgresQuery } from '../../../src/adapter' ;
23import { prepareCompiler } from '../../unit/PrepareCompiler' ;
34import { dbRunner } from './PostgresDBRunner' ;
@@ -12,9 +13,9 @@ cube(\`Orders\`, {
1213 UNION ALL
1314 SELECT 2 as id, 2 as product_id, 'completed' as status, '2022-01-02T00:00:00.000Z'::timestamptz as created_at
1415 \`,
15-
16+
1617 shown: false,
17-
18+
1819 refreshKey: {
1920 sql: \`SELECT MAX(created_at) FROM \${Orders.sql()} orders WHERE \${FILTER_PARAMS.Orders.createdAt.filter('created_at')}\`
2021 },
@@ -47,7 +48,7 @@ cube(\`Orders\`, {
4748 type: \`count\`,
4849 //drillMembers: [id, createdAt]
4950 },
50-
51+
5152 runningTotal: {
5253 type: \`count\`,
5354 rollingWindow: {
@@ -67,28 +68,28 @@ cube(\`Orders\`, {
6768 sql: \`status\`,
6869 type: \`string\`
6970 },
70-
71+
7172 statusProduct: {
7273 sql: \`\${CUBE}.status || '_' || \${Products.name}\`,
7374 type: \`string\`
7475 },
75-
76+
7677 createdAt: {
7778 sql: \`created_at\`,
7879 type: \`time\`
7980 },
80-
81+
8182 productId: {
8283 sql: \`product_id\`,
8384 type: \`number\`,
8485 },
85-
86+
8687 productAndCategory: {
8788 sql: \`\${Products.name} || '_' || \${Products.ProductCategories.name}\`,
8889 type: \`string\`
8990 },
9091 },
91-
92+
9293 segments: {
9394 potatoOnly: {
9495 sql: \`\${CUBE}.product_id = 2 AND \${FILTER_PARAMS.Orders.productId.filter(\`\${CUBE.productId}\`)}\`,
@@ -104,7 +105,7 @@ cube(\`Products\`, {
104105 UNION ALL
105106 SELECT 2 as id, 1 as product_category_id, 'Potato' as name
106107 \`,
107-
108+
108109 joins: {
109110 ProductCategories: {
110111 sql: \`\${CUBE}.product_category_id = \${ProductCategories}.id\`,
@@ -129,7 +130,7 @@ cube(\`Products\`, {
129130 sql: \`name\`,
130131 type: \`string\`
131132 },
132-
133+
133134 proxyName: {
134135 sql: \`\${name}\`,
135136 type: \`string\`,
@@ -201,7 +202,7 @@ cube(\`ProductCategories\`, {
201202view(\`OrdersView\`, {
202203 includes: [Orders],
203204 excludes: [Orders.createdAt],
204-
205+
205206 measures: {
206207 productCategoryCount: {
207208 sql: \`\${Orders.ProductsAlt.ProductCategories.count}\`,
@@ -224,7 +225,7 @@ view(\`OrdersView\`, {
224225 sql: \`\${Orders.ProductsAlt.ProductCategories.name}\`,
225226 type: \`string\`
226227 },
227-
228+
228229 productCategory: {
229230 sql: \`\${Orders.ProductsAlt.name} || '_' || \${Orders.ProductsAlt.ProductCategories.name} || '_' || \${categoryName}\`,
230231 type: \`string\`
@@ -412,12 +413,23 @@ view(\`OrdersView3\`, {
412413 expect ( cube . config . measures . filter ( ( ( { isVisible } ) => isVisible ) ) . length ) . toBe ( 0 ) ;
413414 } ) ;
414415
415- it ( 'split views' , async ( ) => runQueryTest ( {
416- measures : [ 'OrdersView3.count' ] ,
417- dimensions : [ 'OrdersView3_ProductCategories.name' ] ,
418- order : [ { id : 'OrdersView3_ProductCategories.name' } ] ,
419- } , [ {
420- orders_view3__count : '2' ,
421- orders_view3__product_categories__name : 'Groceries' ,
422- } ] ) ) ;
416+ if ( getEnv ( 'nativeSqlPlanner' ) ) {
417+ it ( 'split views' , async ( ) => runQueryTest ( {
418+ measures : [ 'OrdersView3.count' ] ,
419+ dimensions : [ 'OrdersView3_ProductCategories.name' ] ,
420+ order : [ { id : 'OrdersView3_ProductCategories.name' } ] ,
421+ } , [ {
422+ orders_view3__count : '2' ,
423+ orders_view3_product_categories__name : 'Groceries' ,
424+ } ] ) ) ;
425+ } else {
426+ it ( 'split views' , async ( ) => runQueryTest ( {
427+ measures : [ 'OrdersView3.count' ] ,
428+ dimensions : [ 'OrdersView3_ProductCategories.name' ] ,
429+ order : [ { id : 'OrdersView3_ProductCategories.name' } ] ,
430+ } , [ {
431+ orders_view3__count : '2' ,
432+ orders_view3__product_categories__name : 'Groceries' ,
433+ } ] ) ) ;
434+ }
423435} ) ;
0 commit comments