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

CH Sorting Key: Introduce sorting key expression #2215

Closed
wants to merge 1 commit into from

Conversation

Amogh-Bharadwaj
Copy link
Contributor

@Amogh-Bharadwaj Amogh-Bharadwaj commented Nov 4, 2024

This PR introduces the backend to support specifying sorting keys such as function(column) Ex: toDate(updated_at)

@@ -233,7 +233,11 @@ func getOrderedOrderByColumns(

orderbyColumns := make([]string, len(orderby))
for idx, col := range orderby {
orderbyColumns[idx] = getColName(colNameMap, col.SourceName)
sortingKeyName := col.SourceName
if col.SortingKeyExpression != nil && *col.SortingKeyExpression != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking for both defeats the purpose of an optional string
either switch to just string or ensure you don't send empty string from upstream

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer not using optional

orderbyColumns[idx] = getColName(colNameMap, col.SourceName)
sortingKeyName := col.SourceName
if col.SortingKeyExpression != nil && *col.SortingKeyExpression != "" {
sortingKeyName = *col.SortingKeyExpression
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lack of validation means this opens up using ; to run an arbitrary query. Hard to say what our threat model is, but we should explicitly get the okay that our threat model assumes anyone with access to ui has access to run arbitrary queries with any clickhouse peer

@Amogh-Bharadwaj
Copy link
Contributor Author

Closing for now as requires more consideration than initially estimated

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.

3 participants