Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clickhouse times always truncated to seconds #9051

Open
mzealey opened this issue Dec 16, 2024 · 0 comments
Open

Clickhouse times always truncated to seconds #9051

mzealey opened this issue Dec 16, 2024 · 0 comments
Labels
bug Something isn't working driver:clickhouse Issues related to the ClickHouse driver

Comments

@mzealey
Copy link

mzealey commented Dec 16, 2024

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

public convertTz(field) {
//
// field yields a Date or a DateTime so add in the extra toDateTime64 to support the Date case
//
// https://clickhouse.yandex/docs/en/data_types/datetime/
// https://clickhouse.yandex/docs/en/query_language/functions/date_time_functions/
//
//
return `toTimeZone(toDateTime64(${field}, 0), '${this.timezone}')`;
}

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
@igorlukanin igorlukanin added bug Something isn't working driver:clickhouse Issues related to the ClickHouse driver labels Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working driver:clickhouse Issues related to the ClickHouse driver
Projects
None yet
Development

No branches or pull requests

2 participants