Describe the bug
When CUBEJS_TESSERACT_SQL_PLANNER=true, string filters (contains, notContains, startsWith, endsWith) on a Pinot-backed cube generate SQL that Pinot can't run, because of:
- Cube emits
ILIKE, which Pinot has no function for. It only has (LIKE)[https://docs.pinot.apache.org/build-with-pinot/querying-and-sql/sql-syntax/sql-reference#like].
- The
LIKE pattern is built with the || operator ('%' || ? || '%'), but Pinot requires the LIKE pattern to be a literal.
Generated SQL for a contains filter:
SELECT count("stats".playerID) "stats__count"
FROM baseballStats AS "stats"
WHERE (("stats".playerName ILIKE '%' || ? || '%'))
LIMIT 10000
Pinot errors:
QueryValidationError: No match found for function signature ILIKE
After rewriting ILIKE to LOWER(...) LIKE LOWER(...), the ||-built pattern still fails:
For LIKE predicate, the operands except for the first one must be literal
I looked at the codebase and see that BigQuery overrides tesseract.ilike to LOWER({{ expr }}) LIKE LOWER({{ pattern }}).
To Reproduce
- Configure a Cube project with the Pinot driver.
- Define a cube with a string dimension.
- Enable Tesseract with
CUBEJS_TESSERACT_SQL_PLANNER=true.
- Query a measure with a
contains (or startsWith / endsWith / notContains) filter on the string dimension.
- Observe that the generated SQL uses
ILIKE and a ||-built pattern, and that Pinot rejects it.
Expected behavior
The filter should use a Pinot-compatible, case-insensitive match with a literal pattern:
WHERE LOWER("stats".playerName) LIKE LOWER('%son%')
Minimally reproducible Cube Schema
cube(`Stats`, {
sql_table: `baseballStats`,
measures: {
count: { type: `count` },
},
dimensions: {
playerName: { sql: `playerName`, type: `string` },
},
});
Query:
{
"measures": ["Stats.count"],
"filters": [
{ "member": "Stats.playerName", "operator": "contains", "values": ["son"] }
]
}
Version:
Additional context
I cherry-picked this diff first: #11001
Describe the bug
When
CUBEJS_TESSERACT_SQL_PLANNER=true, string filters (contains,notContains,startsWith,endsWith) on a Pinot-backed cube generate SQL that Pinot can't run, because of:ILIKE, which Pinot has no function for. It only has (LIKE)[https://docs.pinot.apache.org/build-with-pinot/querying-and-sql/sql-syntax/sql-reference#like].LIKEpattern is built with the||operator ('%' || ? || '%'), but Pinot requires theLIKEpattern to be a literal.Generated SQL for a
containsfilter:Pinot errors:
After rewriting
ILIKEtoLOWER(...) LIKE LOWER(...), the||-built pattern still fails:I looked at the codebase and see that BigQuery overrides
tesseract.iliketoLOWER({{ expr }}) LIKE LOWER({{ pattern }}).To Reproduce
CUBEJS_TESSERACT_SQL_PLANNER=true.contains(orstartsWith/endsWith/notContains) filter on the string dimension.ILIKEand a||-built pattern, and that Pinot rejects it.Expected behavior
The filter should use a Pinot-compatible, case-insensitive match with a literal pattern:
Minimally reproducible Cube Schema
Query:
{ "measures": ["Stats.count"], "filters": [ { "member": "Stats.playerName", "operator": "contains", "values": ["son"] } ] }Version:
Additional context
I cherry-picked this diff first: #11001