cube-js / cube-js/cube

Clickhouse times always truncated to seconds

Open
#9,051 1 comment 0 reactions 0 assignees View on GitHub
driver:clickhouse
Dominant language
Rust
Stars
20.8k
Forks
2.1k
Avg merge
1d 2h
Merged PRs (30d)
181

Description

In anything marked as a `type: time`, the following code causes Clickhouse `DateTime64()` columns to be truncated to per-second:

https://github.com/cube-js/cube/blob/1cf867ac752d940c32fc1b5c69f005183db6ac74/packages/cubejs-schema-compiler/src/adapter/ClickHouseQuery.ts#L42-L51

In our case we are wanting to pull logs from the server (with `ungrouped: true`) and get them ordered according to millisecond/microsecond timestamps which are in the database.

In order to work around this issue I've had to resort to the following hack:

```
- name: created
sql: created
type: time
primary_key: true

- name: timestamp
description: The unix epoch timestamp of the message
sql: "toFloat64({CUBE}.created)"
type: number
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.