Describe the bug
When CUBEJS_TESSERACT_SQL_PLANNER=true, any Pinot-backed feature that shifts or offsets a timestamp -- time_shift and rolling_window -- generates calls to functions that Pinot does not have.
addInterval / subtractInterval build the expression as:
`${timeStampCast(date)} + fromEpoch${intervalUnit}(${intervalValue})`
intervalUnit is taken verbatim from the interval string ("1 year" -> year, "7 day" -> day), producing fromEpochyear(1), fromEpochday(7), fromEpochminute(30), etc. Pinot has neither the lowercase-singular spellings nor any year/month/week variant.
Generated SQL for a time_shift measure:
CAST("airline".ts as TIMESTAMP) + fromEpochyear(1)
Pinot errors:
QueryValidationError: No match found for function signature fromEpochyear(<NUMERIC>)
Generated SQL for a rolling_window uses fromEpochday(7), which fails the same way.
To Reproduce
- Configure a Cube project with the Pinot driver.
- Define a cube with a
type: time dimension over a TIMESTAMP/epoch-millis column.
- Add a
multi_stage time_shift measure and/or a trailing rolling_window measure.
- Enable Tesseract with
CUBEJS_TESSERACT_SQL_PLANNER=true.
- Query the measure across the time dimension.
- Observe
No match found for function signature fromEpoch<unit> from Pinot.
Expected behavior
The driver should emit interval arithmetic Pinot supports.
| Expression |
Result |
ts - fromEpochday(7) (driver output) |
error -- no such function |
ts - fromEpochyear(1) / fromEpochmonth / fromEpochweek (driver output) |
error -- no such function |
ts - fromEpochminute(30) (driver output) |
error -- no such function |
ts - fromEpochDays(7) (correct fixed-unit name) |
OK |
ts - fromEpochMinutes(30) (correct fixed-unit name) |
OK |
TIMESTAMPADD(YEAR, 1, ts) |
OK |
CAST(ts AS TIMESTAMP) + INTERVAL '7' DAY (on a column) |
error -- Unsupported ColumnDataType: OBJECT |
Minimally reproducible Cube Schema
cubes:
- name: airline
sql_table: airlineStats
dimensions:
- name: flight_num
sql: FlightNum
type: number
primary_key: true
- name: created_at
sql: "{CUBE}.ts" # ts is a TIMESTAMP column
type: time
measures:
- name: total_distance
sql: Distance
type: sum
- name: distance_prior_year
sql: "{CUBE.total_distance}"
type: number
multi_stage: true
time_shift:
- time_dimension: "{CUBE.created_at}"
interval: 1 year
type: prior
- name: distance_rolling_7d
sql: Distance
type: sum
rolling_window:
trailing: 7 day
Query:
{
"measures": ["airline.total_distance", "airline.distance_prior_year"],
"timeDimensions": [
{ "dimension": "airline.created_at", "granularity": "month",
"dateRange": ["2013-01-01", "2014-12-31"] }
]
}
Version:
Additional context
I cherry-picked this diff first: #11001
Describe the bug
When
CUBEJS_TESSERACT_SQL_PLANNER=true, any Pinot-backed feature that shifts or offsets a timestamp --time_shiftandrolling_window-- generates calls to functions that Pinot does not have.addInterval/subtractIntervalbuild the expression as:intervalUnitis taken verbatim from the interval string ("1 year"->year,"7 day"->day), producingfromEpochyear(1),fromEpochday(7),fromEpochminute(30), etc. Pinot has neither the lowercase-singular spellings nor any year/month/week variant.Generated SQL for a
time_shiftmeasure:Pinot errors:
Generated SQL for a
rolling_windowusesfromEpochday(7), which fails the same way.To Reproduce
type: timedimension over aTIMESTAMP/epoch-millis column.multi_stagetime_shiftmeasure and/or a trailingrolling_windowmeasure.CUBEJS_TESSERACT_SQL_PLANNER=true.No match found for function signature fromEpoch<unit>from Pinot.Expected behavior
The driver should emit interval arithmetic Pinot supports.
ts - fromEpochday(7)(driver output)ts - fromEpochyear(1)/fromEpochmonth/fromEpochweek(driver output)ts - fromEpochminute(30)(driver output)ts - fromEpochDays(7)(correct fixed-unit name)ts - fromEpochMinutes(30)(correct fixed-unit name)TIMESTAMPADD(YEAR, 1, ts)CAST(ts AS TIMESTAMP) + INTERVAL '7' DAY(on a column)Unsupported ColumnDataType: OBJECTMinimally reproducible Cube Schema
Query:
{ "measures": ["airline.total_distance", "airline.distance_prior_year"], "timeDimensions": [ { "dimension": "airline.created_at", "granularity": "month", "dateRange": ["2013-01-01", "2014-12-31"] } ] }Version:
Additional context
I cherry-picked this diff first: #11001