Add asc keyword to sort command#4113
Conversation
Swiddis
left a comment
There was a problem hiding this comment.
Needs doc, otherwise LGTM
c03f1ef to
4c67f91
Compare
Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com>
Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com>
Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com>
Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com>
Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com>
9fe664f to
6c54b41
Compare
RyanL1997
left a comment
There was a problem hiding this comment.
Hi @ritvibhatt, thanks for taking this on, and i just left some comments.
| * [+|-]: optional. The plus [+] stands for ascending order and NULL/MISSING first and a minus [-] stands for descending order and NULL/MISSING last. **Default:** ascending order and NULL/MISSING first. | ||
| * sort-field: mandatory. The field used to sort. Can use ``auto(field)``, ``str(field)``, ``ip(field)``, or ``num(field)`` to specify how to interpret field values. | ||
| * [desc|d]: optional. Reverses the sort results. If multiple fields are specified, reverses order of the first field then for all duplicate values of the first field, reverses the order of the values of the second field and so on. | ||
| * [asc|a|desc|d] (Since 3.3): optional. asc/a keeps the sort order as specified. desc/d reverses the sort results. If multiple fields are specified with desc/d, reverses order of the first field then for all duplicate values of the first field, reverses the order of the values of the second field and so on. **Default:** asc. |
There was a problem hiding this comment.
nit: Consider rewording to 'sorts in ascending order' for clarity.
There was a problem hiding this comment.
The behavior for asc is it will keep whatever the specified field sort order was, so for sort firstname, -lastname asc firstname will still be sorted ascending and lastname will still be sorted descending. Don't know if 'sorts in ascending order' would make that behavior clear
|
|
||
|
|
||
| * count: optional. The number of results to return. **Default:** returns all results. Specifying a count of 0 or less than 0 also returns all results. | ||
| * count (Since 3.3): optional. The number of results to return. **Default:** returns all results. Specifying a count of 0 or less than 0 also returns all results. |
There was a problem hiding this comment.
Do we have these covered in example section?
There was a problem hiding this comment.
Yes! just added 'Since 3.3' in this PR but added examples in previous PR
|
|
||
| sortCommand | ||
| : SORT (count = integerLiteral)? sortbyClause (DESC | D)? | ||
| : SORT (count = integerLiteral)? sortbyClause (ASC | A | DESC | D)? |
There was a problem hiding this comment.
Should we consider the precedence if someone accidentally specifies both asc and desc? The grammar allows it but behavior might be undefined.
There was a problem hiding this comment.
Just checked using both asc and desc will result in an error
There was a problem hiding this comment.
got it. Thanks for confirming that.
| } | ||
|
|
||
| @Test | ||
| public void testSortWithAscKeyword() throws IOException { |
There was a problem hiding this comment.
nit: Consider adding negative test cases:
- Invalid combinations like 'sort field asc desc'
- Edge cases with count=0"
* add asc keyword to sort Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com> * add tests and update docs Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com> * remove a Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com> * add a keyword Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com> * update doc Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com> * empty Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com> * fix formatting Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com> * empty Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com> --------- Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com> (cherry picked from commit 6db8d80) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* add asc keyword to sort * add tests and update docs * remove a * add a keyword * update doc * empty * fix formatting * empty --------- (cherry picked from commit 6db8d80) Signed-off-by: Ritvi Bhatt <ribhatt@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Description
CaclitePPlSortITfor desc keyword, count, and type casting enhancementsChanges
ASCandAtokens to PPL lexer and parser grammarasc/akeywords alongside existingdesc/dRelated Issues
Resolves #[Issue number to be closed when this PR is merged]
Check List
--signoffor-s.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.