-
Notifications
You must be signed in to change notification settings - Fork 159
Support query specific attributes for drivers #8266
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
c9a30c5 to
958c7f7
Compare
|
Updated test instance to support |
453ed05 to
ad8f4cd
Compare
4718a62 to
638585b
Compare
runtime/drivers/clickhouse/olap.go
Outdated
| if c.supportSettings { | ||
| if c.config.QuerySettingsOverride != "" { | ||
| stmt.Query += "\n SETTINGS " + c.config.QuerySettingsOverride | ||
| } else { | ||
| stmt.Query += "\n SETTINGS cast_keep_nullable = 1, join_use_nulls = 1, session_timezone = 'UTC', prefer_global_in_and_join = 1, insert_distributed_sync = 1" | ||
| if c.config.QuerySettings != "" { | ||
| stmt.Query += ", " + c.config.QuerySettings | ||
| settings := map[string]any{ | ||
| "cast_keep_nullable": 1, | ||
| "insert_distributed_sync": 1, | ||
| "prefer_global_in_and_join": 1, | ||
| "session_timezone": "UTC", | ||
| "join_use_nulls": 1, | ||
| } | ||
|
|
||
| if c.supportSettings { | ||
| if len(stmt.QueryAttributes) > 0 { | ||
| for k, v := range stmt.QueryAttributes { | ||
| settings[k] = v | ||
| } | ||
| } | ||
|
|
||
| if c.config.QuerySettingsOverride != "" { | ||
| stmt.Query += "\n SETTINGS " + c.config.QuerySettingsOverride | ||
| } else { | ||
| stmt.Query += "\n SETTINGS cast_keep_nullable = 1, join_use_nulls = 1, session_timezone = 'UTC', prefer_global_in_and_join = 1, insert_distributed_sync = 1" | ||
| if c.config.QuerySettings != "" { | ||
| stmt.Query += ", " + c.config.QuerySettings | ||
| } | ||
| } | ||
| } | ||
|
|
||
| ctx = clickhouse.Context(ctx, clickhouse.WithSettings(settings)) |
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.
- It checks
c.supportSettingsafter it has already been checked? - This no longer correctly honors
QuerySettingsOverride, which is supposed to override the default query settings. IfQuerySettingsOverride != "", it should not add the default query settings throughclickhouse.WithSettings. - Now that the default query settings are passed using
clickhouse.WithSettings, it should not also add them to the SQL query (as currently happens on line 160)
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.
@grahamplata After your most recent push, it appears to no longer honor c.config.QuerySettings at all. And it also doesn't address bullet 2 – it still doesn't clear the built-in default settings when QuerySettingsOverride is set.
* add query attributes to MetricsViewSpec * add support for query attributes in OLAP driver and executor * add ClickHouse driver and executor tests * protos * add user claims handling in query attribute resolution * implement query attribute validation and add corresponding tests * output the additional query attributes in the query logging * add tests for query attributes * query attribute handling in ClickHouse queries * handle sql prefix * add custom_settings_prefixes to test clickhouse instance * test_ prefix * log query configuration for drivers * support for user attributes in executor * regen protos * self * update tests * review * update regex * query attributes * use context * ctx * dont parse * verify settings get added to query * review and tests * review * Review * Tests * Review --------- Co-authored-by: Benjamin Egelund-Müller <b@egelund-muller.com>
Support query specific attributes for ClickHouse. This enables end users to enrich queries and leverage our internal routing to our
row_filters.ClickHouse Docs: custom settings
Relates to: #8120 Custom user attributes support
After the above is merged I can leverage the security context for
{{ .user.specific }}attributesChecklist: