Skip to content

Commit 6d75c60

Browse files
cpcpn-emilKSDaemon
andauthored
fix(druid-driver): Fix case sensitivity in like flow (#8658)
* Update the likeIgnoreCase method for the druid driver * Update test --------- Co-authored-by: Konstantin Burkalev <[email protected]>
1 parent aab9e8f commit 6d75c60

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/cubejs-druid-driver/src/DruidQuery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ class DruidFilter extends BaseFilter {
1616
public likeIgnoreCase(column, not, param, type: string) {
1717
const p = (!type || type === 'contains' || type === 'ends') ? '%' : '';
1818
const s = (!type || type === 'contains' || type === 'starts') ? '%' : '';
19-
return `${column}${not ? ' NOT' : ''} LIKE CONCAT('${p}', ${this.allocateParam(param)}, '${s}')`;
19+
return `LOWER(${column})${not ? ' NOT' : ''} LIKE CONCAT('${p}', LOWER(${this.allocateParam(param)}), '${s}')`;
2020
}
2121
}
2222

2323
export class DruidQuery extends BaseQuery {
2424
public newFilter(filter) {
2525
return new DruidFilter(this, filter);
2626
}
27-
27+
2828
public timeGroupedColumn(granularity: string, dimension: string) {
2929
return GRANULARITY_TO_INTERVAL[granularity](dimension);
3030
}

packages/cubejs-druid-driver/test/druid-query.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('DruidQuery', () => {
3232
type: 'time',
3333
}
3434
}
35-
35+
3636
})
3737
`, {});
3838

@@ -54,7 +54,7 @@ describe('DruidQuery', () => {
5454
},
5555
);
5656
const queryAndParams = query.buildSqlAndParams();
57-
expect(queryAndParams[0]).toContain('LIKE CONCAT(\'%\', ?, \'%\'))');
57+
expect(queryAndParams[0]).toContain('LIKE CONCAT(\'%\', LOWER(?), \'%\'))');
5858
}));
5959

6060
it('druid query timezone shift test', () => compiler.compile().then(() => {

0 commit comments

Comments
 (0)