Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/cubejs-duckdb-server-driver/src/DuckDBServerDriver.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios, { AxiosError, AxiosInstance } from 'axios';
import axios, { AxiosError, AxiosInstance, InternalAxiosRequestConfig } from 'axios';
import {
BaseDriver,
DriverInterface,
Expand Down Expand Up @@ -94,6 +94,19 @@ export class DuckDBServerDriver extends BaseDriver implements DriverInterface {
};

this.client = axios.create({ baseURL: url });

this.client.interceptors.request.use(
(request: InternalAxiosRequestConfig): InternalAxiosRequestConfig => {
console.log('DuckDB Server query', {
method: request.method?.toUpperCase(),
url: `${request.baseURL}${request.url}`,
headers: JSON.stringify(request.headers, null, 2),
data: JSON.stringify(request.data, null, 2)
});
return request;
},
(error) => Promise.reject(error)
);
}

public readOnly() {
Expand Down
13 changes: 12 additions & 1 deletion packages/cubejs-duckdb-server-driver/src/DuckDBServerQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ export class DuckDBServerQuery extends BaseQuery {
return GRANULARITY_TO_INTERVAL[granularity](dimension);
}

public timeStampCast(value: string) {
const noTimestampCast = process.env.CUBEJS_DEFINITE_NO_DUCKDB_SERVER_TIMESTAMP_CAST;
const timestampCastFunction = process.env.CUBEJS_DEFINITE_DUCKDB_SERVER_TIMESTAMP_CAST_FUNCTION;
if (noTimestampCast === 'true' || noTimestampCast === '1') {
return value;
} else if (timestampCastFunction) {
return `${value}::${timestampCastFunction}`;
} else {
return `${value}::timestamptz`;
}
}

/**
* Returns sql for source expression floored to timestamps aligned with
* intervals relative to origin timestamp point.
Expand All @@ -53,7 +65,6 @@ export class DuckDBServerQuery extends BaseQuery {
templates.functions.DATETRUNC = 'DATE_TRUNC({{ args_concat }})';
templates.functions.LEAST = 'LEAST({{ args_concat }})';
templates.functions.GREATEST = 'GREATEST({{ args_concat }})';
templates.filters.time_range_filter = '{{ column }}::timestamptz >= {{ from_timestamp }} AND {{ column }}::timestamptz <= {{ to_timestamp }}';
return templates;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cubejs-schema-compiler/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "../../tsconfig.base.json",
"include": ["src", "test"],
"include": ["src"],
"compilerOptions": {
"outDir": "dist",
"rootDir": ".",
Expand Down