Skip to content

Commit

Permalink
feat(schema-compiler): Athena rollingWindow support
Browse files Browse the repository at this point in the history
  • Loading branch information
paveltiunov committed Apr 23, 2019
1 parent 9c52dc8 commit f112c69
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/cubejs-schema-compiler/adapter/PrestodbQuery.js
Expand Up @@ -39,7 +39,7 @@ class PrestodbQuery extends BaseQuery {
}

dateTimeCast(value) {
return `CAST(${value} as TIMESTAMP)`; // TODO
return `from_iso8601_timestamp(${value})`;
}

convertTz(field) {
Expand All @@ -53,11 +53,22 @@ class PrestodbQuery extends BaseQuery {
return `date_trunc('${GRANULARITY_TO_INTERVAL[granularity]}', ${dimension})`;
}

subtractInterval(date, interval) {
const [intervalValue, intervalUnit] = interval.split(" ");
return `${date} - interval '${intervalValue}' ${intervalUnit}`;
}

addInterval(date, interval) {
const [intervalValue, intervalUnit] = interval.split(" ");
return `${date} + interval '${intervalValue}' ${intervalUnit}`;
}

seriesSql(timeDimension) {
const values = timeDimension.timeSeries().map(
([from, to]) => `select '${from}' f, '${to}' t`
).join(' UNION ALL ');
return `SELECT from_iso8601_timestamp(dates.f) date_from, from_iso8601_timestamp(dates.t) date_to FROM (${values}) AS dates`;
}
}

module.exports = PrestodbQuery;

0 comments on commit f112c69

Please sign in to comment.