Skip to content

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Sep 13, 2024
1 parent 876535b commit 93ae94c
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ describe('ClickHouse JoinGraph', () => {
type: 'number',
sql: new Function('visitor_revenue', 'visitor_count', 'return visitor_revenue + "/" + visitor_count')
}
cube(\`visitors\`, {
sql: \`
select * from visitors WHERE \${USER_CONTEXT.source.filter('source')} AND
\${USER_CONTEXT.sourceArray.filter(sourceArray => \`source in (\${sourceArray.join(',')})\`)}
select * from visitors WHERE \${SECURITY_CONTEXT.source.filter('source')} AND
\${SECURITY_CONTEXT.sourceArray.filter(sourceArray => \`source in (\${sourceArray.join(',')})\`)}
\`,
refreshKey: {
sql: 'SELECT 1',
},
Expand Down Expand Up @@ -113,24 +113,24 @@ describe('ClickHouse JoinGraph', () => {
type: 'time',
sql: 'created_at'
},
createdAtSqlUtils: {
type: 'time',
sql: SQL_UTILS.convertTz('created_at')
},
checkins: {
sql: \`\${visitor_checkins.visitor_checkins_count}\`,
type: \`number\`,
subQuery: true
},
subQueryFail: {
sql: '2',
type: \`number\`,
subQuery: true
},
doubledCheckings: {
sql: \`\${checkins} * 2\`,
type: 'number'
Expand Down Expand Up @@ -210,7 +210,7 @@ describe('ClickHouse JoinGraph', () => {
subQuery: true
},
},
// preAggregations: {
// checkinSource: {
// type: 'rollup',
Expand Down Expand Up @@ -255,27 +255,27 @@ describe('ClickHouse JoinGraph', () => {
}
}
})
cube('ReferenceVisitors', {
sql: \`
select * from \${visitors.sql()} as t
select * from \${visitors.sql()} as t
WHERE \${FILTER_PARAMS.ReferenceVisitors.createdAt.filter(\`addDays(t.created_at, 28)\`)} AND
\${FILTER_PARAMS.ReferenceVisitors.createdAt.filter((from, to) => \`(addDays(t.created_at,28)) >= parseDateTimeBestEffort(\${from}) AND (addDays(t.created_at, 28)) <= parseDateTimeBestEffort(\${to})\`)}
\`,
measures: {
count: {
type: 'count'
},
googleSourcedCount: {
type: 'count',
filters: [{
sql: \`\${CUBE}.source = 'google'\`
}]
},
},
dimensions: {
createdAt: {
type: 'time',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ describe('MSSqlUngrouped', () => {
type: 'number',
sql: new Function('visitor_revenue', 'visitor_count', 'return visitor_revenue + "/" + visitor_count')
}
cube(\`visitors\`, {
sql: \`
select * from ##visitors WHERE \${USER_CONTEXT.source.filter('source')} AND
\${USER_CONTEXT.sourceArray.filter(sourceArray => \`source in (\${sourceArray.join(',')})\`)}
select * from ##visitors WHERE \${SECURITY_CONTEXT.source.filter('source')} AND
\${SECURITY_CONTEXT.sourceArray.filter(sourceArray => \`source in (\${sourceArray.join(',')})\`)}
\`,
rewriteQueries: true,
refreshKey: {
sql: 'SELECT 1',
},
Expand Down Expand Up @@ -122,37 +122,37 @@ describe('MSSqlUngrouped', () => {
type: 'time',
sql: 'created_at'
},
createdAtSqlUtils: {
type: 'time',
sql: SQL_UTILS.convertTz('created_at')
},
checkins: {
sql: \`\${visitor_checkins.visitor_checkins_count}\`,
type: \`number\`,
subQuery: true
},
checkinsRolling: {
sql: \`\${visitor_checkins.visitorCheckinsRolling}\`,
type: \`number\`,
subQuery: true
},
checkinsWithPropagation: {
sql: \`\${visitor_checkins.visitor_checkins_count}\`,
type: \`number\`,
subQuery: true,
propagateFiltersToSubQuery: true
},
subQueryFail: {
sql: '2',
type: \`number\`,
subQuery: true
},
doubledCheckings: {
sql: \`\${checkins} * 2\`,
type: 'number'
Expand Down Expand Up @@ -181,11 +181,11 @@ describe('MSSqlUngrouped', () => {
cube('visitor_checkins', {
sql: \`
select * from ##visitor_checkins WHERE
select * from ##visitor_checkins WHERE
\${FILTER_PARAMS.visitor_checkins.created_at.filter('created_at')} AND
\${FILTER_GROUP(FILTER_PARAMS.visitor_checkins.created_at.filter("dateadd(day, -3, created_at)"), FILTER_PARAMS.visitor_checkins.source.filter('source'))}
\`,
rewriteQueries: true,
joins: {
Expand All @@ -199,14 +199,14 @@ describe('MSSqlUngrouped', () => {
visitor_checkins_count: {
type: 'count'
},
visitorCheckinsRolling: {
type: 'count',
rollingWindow: {
trailing: 'unbounded'
}
},
revenue_per_checkin: {
type: 'number',
sql: \`\${visitors.visitor_revenue} / \${visitor_checkins_count}\`
Expand Down Expand Up @@ -259,7 +259,7 @@ describe('MSSqlUngrouped', () => {
subQuery: true
},
},
preAggregations: {
checkinSource: {
type: 'rollup',
Expand Down Expand Up @@ -331,9 +331,9 @@ describe('MSSqlUngrouped', () => {
}
}
})
`);

async function runQueryTest(q, expectedResult) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ describe('SQL Generation', () => {
type: 'number',
sql: new Function('visitor_revenue', 'visitor_count', 'return visitor_revenue + "/" + visitor_count')
}
cube(\`visitors\`, {
sql: \`
select * from visitors WHERE \${USER_CONTEXT.source.filter('source')} AND
\${USER_CONTEXT.sourceArray.filter(sourceArray => \`source in (\${sourceArray.join(',')})\`)}
select * from visitors WHERE \${SECURITY_CONTEXT.source.filter('source')} AND
\${SECURITY_CONTEXT.sourceArray.filter(sourceArray => \`source in (\${sourceArray.join(',')})\`)}
\`,
rewriteQueries: true,
refreshKey: {
sql: 'SELECT 1',
},
Expand Down Expand Up @@ -109,31 +109,31 @@ describe('SQL Generation', () => {
type: 'time',
sql: 'created_at'
},
createdAtSqlUtils: {
type: 'time',
sql: SQL_UTILS.convertTz('created_at')
},
checkins: {
sql: \`\${visitor_checkins.visitor_checkins_count}\`,
type: \`number\`,
subQuery: true
},
checkinsWithPropagation: {
sql: \`\${visitor_checkins.visitor_checkins_count}\`,
type: \`number\`,
subQuery: true,
propagateFiltersToSubQuery: true
},
subQueryFail: {
sql: '2',
type: \`number\`,
subQuery: true
},
doubledCheckings: {
sql: \`\${checkins} * 2\`,
type: 'number'
Expand All @@ -160,7 +160,7 @@ describe('SQL Generation', () => {
sql: \`
select * from visitor_checkins WHERE \${FILTER_PARAMS.visitor_checkins.created_at.filter('created_at')}
\`,
rewriteQueries: true,
joins: {
Expand Down Expand Up @@ -215,7 +215,7 @@ describe('SQL Generation', () => {
subQuery: true
},
},
preAggregations: {
checkinSource: {
type: 'rollup',
Expand Down Expand Up @@ -260,42 +260,42 @@ describe('SQL Generation', () => {
}
}
})
cube('ReferenceVisitors', {
sql: \`
select * from \${visitors.sql()} as t
select * from \${visitors.sql()} as t
WHERE \${FILTER_PARAMS.ReferenceVisitors.createdAt.filter(\`(t.created_at + interval '28 day')\`)} AND
\${FILTER_PARAMS.ReferenceVisitors.createdAt.filter((from, to) => \`(t.created_at + interval '28 day') >= \${from} AND (t.created_at + interval '28 day') <= \${to}\`)}
\`,
measures: {
count: {
type: 'count'
},
googleSourcedCount: {
type: 'count',
filters: [{
sql: \`\${CUBE}.source = 'google'\`
}]
},
},
dimensions: {
createdAt: {
type: 'time',
sql: 'created_at'
}
}
})
cube('CubeWithVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLongName', {
sql: \`
select * from cards
\`,
sqlAlias: 'cube_with_long_name',
dataSource: 'oracle',
measures: {
Expand Down
Loading

0 comments on commit 93ae94c

Please sign in to comment.