-
Notifications
You must be signed in to change notification settings - Fork 162
[PLAT-377] add cast operator support in metrics sql, also enable "cast_string_to_date_time_mode" for clickhouse #8612
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
Conversation
…date_time_mode for clickhouse
|
Tests failing because test CH is old version not supporting this config added in 25.6. |
runtime/metricsview/astexpr.go
Outdated
| return err | ||
| } | ||
| b.writeString(" AS ") | ||
| b.writeString(cond.Expressions[1].Value.(string)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Unsafe type cast – can we make it safe? (Just to protect against panics)
- Since SQL types differ between different OLAPs, can we use a generic type here that is not DB-specific? Maybe accept a
runtimev1.Type_Codeand usedrivers.Dialectto map it to a SQL type for common types (can just handle timestamps for now)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using runtimev1.Type and also added a test.
Also not setting cast_string_to_date_time_mode in the code by default because we have check for min supported version of 22.7 and this config is available in 25.6. We can set it through connector.clickhouse.query_settings="cast_string_to_date_time_mode='best_effort'" for projects needing this.
…t_string_to_date_time_mode" for clickhouse (#8612) * add cast operator support in metrics sql, also enable cast_string_to_date_time_mode for clickhouse * upgrade ch image * test, review comments * lint * better handling * comment * fix web code quality CI
CH does not support automatically converting zulu formatted time
2025-12-25T00:00:00Zto DateTime. A configcast_string_to_date_time_modeenables this but still needs a cast to be added to the string typed time value.This fix adds support for CAST operator in
metrics_sqlbut only for DateTime and Timestamp type. This will enables api users to pass in datetime as string with the condition that they cast the param in api likeday >= CAST('{{ .args.startDate }}' AS DateTime). This also supports Rill time functions so this is also supportedday > CAST(time_range_start('P30D') AS DateTime).Checklist: