Skip to content

Commit ff3f5c9

Browse files
authored
fix(druid-driver): Emulate ILIKE for Tesseract and SQL API push down (#11164)
1 parent 8d76ec2 commit ff3f5c9

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,16 @@ export class DruidQuery extends BaseQuery {
5151
public nowTimestampSql(): string {
5252
return 'CURRENT_TIMESTAMP';
5353
}
54+
55+
public sqlTemplates() {
56+
const templates = super.sqlTemplates();
57+
58+
// Druid doesn't support ILIKE, so case-insensitive matching is emulated with LOWER(...) LIKE CONCAT(...)
59+
templates.expressions.ilike = 'LOWER({{ expr }}) {% if negated %}NOT {% endif %}LIKE LOWER({{ pattern }})';
60+
delete templates.expressions.like_escape;
61+
templates.filters.like_pattern = 'CONCAT({% if start_wild %}\'%\'{% else %}\'\'{% endif %}, LOWER({{ value }}), {% if end_wild %}\'%\'{% else %}\'\'{% endif %})';
62+
templates.tesseract.ilike = 'LOWER({{ expr }}) {% if negated %}NOT {% endif %}LIKE {{ pattern }}';
63+
64+
return templates;
65+
}
5466
}

0 commit comments

Comments
 (0)