{"record":{"id":"979366b9b7836f17","repo":"cube-js/cube","slug":"cannot-transform-interval-expression-interval-979366","errorCode":null,"errorMessage":"Cannot transform interval expression \"${interval}\" to Dremio dialect","messagePattern":"Cannot transform interval expression \"(.+?)\" to Dremio dialect","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-dremio-driver/driver/DremioQuery.js","lineNumber":155,"sourceCode":"    } else if (intervalParsed.quarter && intKeys === 1) {\n      // dremio interval does not support quarter. Convert to month\n      return [`${intervalParsed.quarter * 3}`, 'MONTH'];\n    } else if (intervalParsed.week && intKeys === 1) {\n      // dremio interval does not support week. Convert to days\n      return [`${intervalParsed.week * 7}`, 'DAY'];\n    } else if (intervalParsed.month && intKeys === 1) {\n      return [`${intervalParsed.month}`, 'MONTH'];\n    } else if (intervalParsed.month && intKeys === 1) {\n      return [`${intervalParsed.day}`, 'DAY'];\n    } else if (intervalParsed.hour && intKeys === 1) {\n      return [`${intervalParsed.hour}`, 'HOUR'];\n    } else if (intervalParsed.minute && intKeys === 1) {\n      return [`${intervalParsed.minute}`, 'MINUTE'];\n    } else if (intervalParsed.second && intKeys === 1) {\n      return [`${intervalParsed.second}`, 'SECOND'];\n    }\n\n    throw new Error(`Cannot transform interval expression \"${interval}\" to Dremio dialect`);\n  }\n\n  sqlTemplates() {\n    const templates = super.sqlTemplates();\n    templates.functions.CURRENTDATE = 'CURRENT_DATE';\n    templates.functions.DATETRUNC = 'DATE_TRUNC(\\'{{ date_part }}\\', {{ args_concat }})';\n    templates.functions.DATEPART = 'DATE_PART(\\'{{ date_part }}\\', {{ args_concat }})';\n    // really need the date locale formatting here...\n    templates.functions.DATE = 'TO_DATE({{ args_concat }},\\'YYYY-MM-DD\\', 1)';\n    templates.functions.DATEDIFF = 'DATE_DIFF(DATE, DATE_TRUNC(\\'{{ date_part }}\\', {{ args[1] }}), DATE_TRUNC(\\'{{ date_part }}\\', {{ args[2] }}))';\n    templates.functions.STRING_AGG = 'LISTAGG({% if distinct %}DISTINCT {% endif %}{{ args_concat }})';\n    templates.expressions.interval_single_date_part = 'CAST({{ num }} as INTERVAL {{ date_part }})';\n    templates.expressions.like = '{{ expr }} {% if negated %}NOT {% endif %}LIKE {{ pattern }}{% if default_escape %} ESCAPE \\'\\\\\\'{% endif %}';\n    delete templates.expressions.ilike;\n    delete templates.functions.WIDTH_BUCKET;\n    templates.quotes.identifiers = '\"';\n    return templates;\n  }","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-dremio-driver/driver/DremioQuery.js#L137-L173","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (schema)\nrollingWindow: { trailing: '1 hour 30 minutes' }\n// after\nrollingWindow: { trailing: '90 minutes' }","handlingStrategy":"validation","validationCode":"const UNITS = ['year','month','day','hour','minute','second'];\nfunction isSimpleInterval(interval) {\n  const m = /^(\\d+)\\s+(\\w+)$/.exec(interval.trim());\n  return !!m && UNITS.includes(m[2].toLowerCase());\n}\nif (!isSimpleInterval(myInterval)) {\n  throw new Error(`Dremio supports only single-unit intervals, got: ${myInterval}`);\n}","typeGuard":"function isDremioSafeInterval(v) {\n  return /^\\d+\\s+(year|month|day|hour|minute|second)s?$/i.test(v);\n}","tryCatchPattern":"try {\n  const compiled = await compiler.compile();\n} catch (e) {\n  if (e.message.includes('Cannot transform interval')) {\n    console.error('Unsupported interval for Dremio:', e.message);\n  } else throw e;\n}","preventionTips":["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"],"tags":["query-generation","sql-dialect","dremio","interval"],"backgroundTag":"unsupported-interval-syntax","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}