cube-js/cube · error
Cannot transform interval expression "${interval}" to Dremio
Error message
Cannot transform interval expression "${interval}" to Dremio dialect What it means
DremioQuery.formatInterval() converts Cube's generic interval expressions (e.g. an interval with multiple or unsupported time units) into Dremio SQL dialect. It only handles an interval composed of exactly ONE unit among specific date parts; anything else falls through and throws. This is a query-generation failure, thrown before any SQL is sent to Dremio.
Source
Thrown at packages/cubejs-dremio-driver/driver/DremioQuery.js:155
} else if (intervalParsed.quarter && intKeys === 1) {
// dremio interval does not support quarter. Convert to month
return [`${intervalParsed.quarter * 3}`, 'MONTH'];
} else if (intervalParsed.week && intKeys === 1) {
// dremio interval does not support week. Convert to days
return [`${intervalParsed.week * 7}`, 'DAY'];
} else if (intervalParsed.month && intKeys === 1) {
return [`${intervalParsed.month}`, 'MONTH'];
} else if (intervalParsed.month && intKeys === 1) {
return [`${intervalParsed.day}`, 'DAY'];
} else if (intervalParsed.hour && intKeys === 1) {
return [`${intervalParsed.hour}`, 'HOUR'];
} else if (intervalParsed.minute && intKeys === 1) {
return [`${intervalParsed.minute}`, 'MINUTE'];
} else if (intervalParsed.second && intKeys === 1) {
return [`${intervalParsed.second}`, 'SECOND'];
}
throw new Error(`Cannot transform interval expression "${interval}" to Dremio dialect`);
}
sqlTemplates() {
const templates = super.sqlTemplates();
templates.functions.CURRENTDATE = 'CURRENT_DATE';
templates.functions.DATETRUNC = 'DATE_TRUNC(\'{{ date_part }}\', {{ args_concat }})';
templates.functions.DATEPART = 'DATE_PART(\'{{ date_part }}\', {{ args_concat }})';
// really need the date locale formatting here...
templates.functions.DATE = 'TO_DATE({{ args_concat }},\'YYYY-MM-DD\', 1)';
templates.functions.DATEDIFF = 'DATE_DIFF(DATE, DATE_TRUNC(\'{{ date_part }}\', {{ args[1] }}), DATE_TRUNC(\'{{ date_part }}\', {{ args[2] }}))';
templates.functions.STRING_AGG = 'LISTAGG({% if distinct %}DISTINCT {% endif %}{{ args_concat }})';
templates.expressions.interval_single_date_part = 'CAST({{ num }} as INTERVAL {{ date_part }})';
templates.expressions.like = '{{ expr }} {% if negated %}NOT {% endif %}LIKE {{ pattern }}{% if default_escape %} ESCAPE \'\\\'{% endif %}';
delete templates.expressions.ilike;
delete templates.functions.WIDTH_BUCKET;
templates.quotes.identifiers = '"';
return templates;
}View on GitHub (pinned to 7d981676b3)
Solutions
- Change the interval to a single supported unit (year/month/day/hour/minute/second), e.g. use '90 minutes' instead of '1 hour 30 minutes'.
- Express odd intervals in seconds/minutes: '5400 seconds' or '90 minutes'.
- If you need the unit, extend the Dremio driver's formatInterval/sqlTemplates to map the missing date part.
Example fix
// before (schema)
rollingWindow: { trailing: '1 hour 30 minutes' }
// after
rollingWindow: { trailing: '90 minutes' } Defensive patterns
Strategy: validation
Validate before calling
const UNITS = ['year','month','day','hour','minute','second'];
function isSimpleInterval(interval) {
const m = /^(\d+)\s+(\w+)$/.exec(interval.trim());
return !!m && UNITS.includes(m[2].toLowerCase());
}
if (!isSimpleInterval(myInterval)) {
throw new Error(`Dremio supports only single-unit intervals, got: ${myInterval}`);
} Type guard
function isDremioSafeInterval(v) {
return /^\d+\s+(year|month|day|hour|minute|second)s?$/i.test(v);
} Try / catch
try {
const compiled = await compiler.compile();
} catch (e) {
if (e.message.includes('Cannot transform interval')) {
console.error('Unsupported interval for Dremio:', e.message);
} else throw e;
} Prevention
- Use single-unit intervals in dateRange/rollingWindow definitions for Dremio
- Prefer seconds/minutes for non-round intervals
- Test schema compilation against the Dremio dialect in CI
When it happens
Trigger: Compiling a Cube query whose time dimension/date range or rolling window uses an interval that parses to more than one unit (e.g. '1 hour 30 minutes') or a unit not mapped by formatInterval's branches (e.g. quarter/millisecond), typically via formattedTimeIntervals.
Common situations: Using dateRange strings or rollingWindow intervals like '2 quarters', '90 minutes' expressed as '1 hour 30 minutes', or custom granularity intervals not supported by the Dremio dialect.
Related errors
- Cannot transform interval expression "${interval}" to Databr
- dremioAuthToken is blank
- ${data.errorMessage}
- Job ${jobId} has been canceled
- DremioQuery job timeout reached ${this.config.pollTimeout}ms
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/979366b9b7836f17.
Report an issue: GitHub.