Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] test(clickhouse): Add integration test for question mark in query for ClickHouse #8940

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ export class ClickHouseDbRunner extends BaseDbRunner {
} : {};

for (const [query, params] of queries) {
console.log("ClickHOuse testQueries", query, params);
console.log("ClickHOuse prepared", formatSql(query, params));
requests.push(clickHouse.querying(formatSql(query, params), {
dataObjects: true,
queryOptions: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,4 +506,84 @@ describe('ClickHouse DataSchemaCompiler', () => {
]);
}
);

it('question mark filter', () => {
const { compiler, cubeEvaluator, joinGraph } = testPrepareCompiler(`
cube('visitors', {
sql: \`
select * from visitors
\`,

measures: {
visitor_count: {
type: 'count',
sql: 'id'
},
visitor_revenue: {
type: 'sum',
sql: 'amount'
},
per_visitor_revenue: {
type: 'number',
sql: visitor_revenue + "/" + visitor_count
}
},

dimensions: {
source: {
type: 'string',
sql: 'source'
},
created_at: {
type: 'time',
sql: 'created_at'
},
updated_at: {
type: 'time',
sql: 'updated_at'
},
questionMark: {
sql: \`replace('some string question string ? ? ? ???', 'string', 'with some ? ? ? ???')\`,
type: 'string'
}
}
})
`);
const result = compiler.compile().then(() => {
const query = new ClickHouseQuery({ joinGraph, cubeEvaluator, compiler }, {
measures: ['visitors.visitor_count'],
dimensions: [],
timeDimensions: [],
timezone: 'America/Los_Angeles',
filters: [{
or: [{
member: 'visitors.questionMark',
operator: 'contains',
values: ['with some']
}, {
member: 'visitors.questionMark',
operator: 'equals',
values: [null]
}, {
member: 'visitors.questionMark',
operator: 'equals',
values: [null, 'with some']
}]
}],
order: []
});

logSqlAndParams(query);

return dbRunner.testQuery(query.buildSqlAndParams()).then((res: any) => {
expect(res).toEqual(
[
{ visitors__visitor_count_foo_bar: '6' }
]
);
});
});

return result;
});
});
Loading