Skip to content

Commit

Permalink
fix(druid-driver): Fix case sensitivity in like flow (#8658)
Browse files Browse the repository at this point in the history
* Update the likeIgnoreCase method for the druid driver

* Update test

---------

Co-authored-by: Konstantin Burkalev <[email protected]>
  • Loading branch information
cpcpn-emil and KSDaemon authored Jan 17, 2025
1 parent aab9e8f commit 6d75c60
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/cubejs-druid-driver/src/DruidQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ class DruidFilter extends BaseFilter {
public likeIgnoreCase(column, not, param, type: string) {
const p = (!type || type === 'contains' || type === 'ends') ? '%' : '';
const s = (!type || type === 'contains' || type === 'starts') ? '%' : '';
return `${column}${not ? ' NOT' : ''} LIKE CONCAT('${p}', ${this.allocateParam(param)}, '${s}')`;
return `LOWER(${column})${not ? ' NOT' : ''} LIKE CONCAT('${p}', LOWER(${this.allocateParam(param)}), '${s}')`;
}
}

export class DruidQuery extends BaseQuery {
public newFilter(filter) {
return new DruidFilter(this, filter);
}

public timeGroupedColumn(granularity: string, dimension: string) {
return GRANULARITY_TO_INTERVAL[granularity](dimension);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cubejs-druid-driver/test/druid-query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('DruidQuery', () => {
type: 'time',
}
}
})
`, {});

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

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

0 comments on commit 6d75c60

Please sign in to comment.