Skip to content

Commit 8069c96

Browse files
committed
tests
1 parent e143b70 commit 8069c96

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

packages/cubejs-schema-compiler/test/integration/postgres/sql-generation.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ describe('SQL Generation', () => {
231231
sql: \`\${revenue}\`,
232232
type: 'sum',
233233
group_by: [id]
234+
},
235+
min_created_at: {
236+
type: 'time',
237+
sql: 'MIN(created_at)'
234238
}
235239
},
236240
@@ -1560,6 +1564,45 @@ SELECT 1 AS revenue, cast('2024-01-01' AS timestamp) as time UNION ALL
15601564
});
15611565
});
15621566

1567+
it('having filter (time measure)', async () => {
1568+
await compiler.compile();
1569+
1570+
const query = new PostgresQuery({ joinGraph, cubeEvaluator, compiler }, {
1571+
measures: [
1572+
'visitors.min_created_at'
1573+
],
1574+
dimensions: [
1575+
'visitors.source'
1576+
],
1577+
timeDimensions: [],
1578+
timezone: 'America/Los_Angeles',
1579+
filters: [{
1580+
dimension: 'visitors.min_created_at',
1581+
operator: 'inDateRange',
1582+
values: ['2017-01-01', '2018-01-01']
1583+
}],
1584+
order: [{
1585+
id: 'visitors.source'
1586+
}]
1587+
});
1588+
1589+
console.log(query.buildSqlAndParams());
1590+
1591+
return dbRunner.testQuery(query.buildSqlAndParams()).then(res => {
1592+
console.log(JSON.stringify(res));
1593+
expect(res).toEqual([
1594+
{
1595+
visitors__min_created_at: '2017-01-06T00:00:00.000Z',
1596+
visitors__source: 'google',
1597+
},
1598+
{
1599+
visitors__min_created_at: '2017-01-03T00:00:00.000Z',
1600+
visitors__source: 'some',
1601+
},
1602+
]);
1603+
});
1604+
});
1605+
15631606
it('having filter without measure', async () => {
15641607
await compiler.compile();
15651608

0 commit comments

Comments
 (0)