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

Fix error uploading offset datetime #263

Merged
merged 2 commits into from
Aug 20, 2024
Merged

Conversation

crisptrutski
Copy link
Contributor

@crisptrutski crisptrutski commented Aug 20, 2024

Closes metabase/metabase#47007

Description

Without this change Metabase will throw the following error when uploading a CSV with a datetime with an offset value:

class java.time.OffsetDateTime` cannot be cast to class `java.lang.String`

This is because we were missing a case in the insert method, and it was falling through the the catch all case. The first fix is to add an explicit case for this type to fix the JDBC integration.

The second fix is to update the config for how we map CSV columns to database types in particular. Since Clickhouse does not preserve the input offset, we made the product choice to keep these values as their raw input string. By returning nil for this type we can trigger this behavior.

Testing

I am not sure how to get this tested (incl the CSV upload path) in CI.

I have tested manually in my local dev environment, and it works.

### Description

Without this change Metabase will throw the following error when uploading a CSV with a datetime with an offset value:

```
class java.time.OffsetDateTime` cannot be cast to class `java.lang.String`
```

This is because we were missing a case in the insert method, and it was falling through the the catch all case. The first fix is to add an explicit case for this type to fix the JDBC integration.

The second fix is to update the config for how we map CSV columns to database types in particular. Since Clickhouse does not preserve the input offset, we made the product choice to keep these values as their raw input string. By returning `nil` for this type we can trigger this behavior.
@CLAassistant
Copy link

CLAassistant commented Aug 20, 2024

CLA assistant check
All committers have signed the CLA.

@slvrtrn slvrtrn merged commit b1557fa into ClickHouse:master Aug 20, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSV uploads broken for Clickhouse when data contains datetime with offset
3 participants