-
Notifications
You must be signed in to change notification settings - Fork 6
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
Enhance 'sort' field parser to handle various sort formats #139
Conversation
d048179
to
88a645d
Compare
1804a80
to
2ec1aed
Compare
return sortFields | ||
case map[string]interface{}: | ||
sortFields := make([]string, 0) | ||
|
||
for fieldName, fieldValue := range sortMaps { | ||
if strings.HasPrefix(fieldName, "_") && cw.Table.GetFieldInfo(cw.Ctx, fieldName) == clickhouse.NotExists { | ||
// TODO Elastic internal fields will need to be supported in the future | ||
continue | ||
} | ||
if fieldValue, ok := fieldValue.(string); ok { | ||
sortFields = append(sortFields, fmt.Sprintf("%s %s", strconv.Quote(fieldName), fieldValue)) | ||
} | ||
} | ||
|
||
return sortFields | ||
|
||
case map[string]string: | ||
sortFields := make([]string, 0) | ||
|
||
for fieldName, fieldValue := range sortMaps { | ||
if strings.HasPrefix(fieldName, "_") && cw.Table.GetFieldInfo(cw.Ctx, fieldName) == clickhouse.NotExists { | ||
// TODO Elastic internal fields will need to be supported in the future | ||
continue | ||
} | ||
sortFields = append(sortFields, fmt.Sprintf("%s %s", strconv.Quote(fieldName), fieldValue)) | ||
} | ||
|
||
return sortFields |
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.
in previous implementation, we do ResolveField
. Don't we want to do it in these 2 cases as well?
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.
this is handled at the beginning of each search processing, so we never reach here with nonexistent columns - I will unify that
Parse shorthand forms of
sort
fields like:and:
Also, rewrote tests to run as separate test cases instead of a single test with a loop