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

issue 148 - add array sort asc #149

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DaniellePoleg
Copy link
Collaborator

No description provided.

@@ -845,6 +845,18 @@ def array_slice(array: ArrayType, start: NumberType, end: NumberType) -> _ArrayE
"""
return _ArrayExpression(KQL(f'array_slice({_to_kql(array)}, {_to_kql(start)}, {_to_kql(end)})'))

@staticmethod
def array_sort_asc(array1: ArrayType, nulls_last: BooleanType = None, *more_arrays: ArrayType) -> _ArrayExpression:
Copy link
Collaborator

Choose a reason for hiding this comment

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

the order of the variables is a bit confusing, due to the mismatch between KQL and python.
My suggestion is to use instead:
def array_sort_asc(to_sort: Union[ArrayType, List[ArrayType]], nulls_last: BooleanType = None) -> _ArrayExpression:...

and then handle to_sort according to type.
WDYT?
also @ymost

Copy link
Contributor

Choose a reason for hiding this comment

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

Little known Python 3 feature: you can put a keyword argument after a varargs argument, and then it becomes a keyword-only argument.
So we can do this:
def array_sort_asc(*arrays: ArrayType, nulls_last: BooleanType = True) -> _ArrayExpression:
The only down side is that the user will be forced to use keyword notation (e.g. nulls_last=False ).
Also note that per the Kusto default, our default should be 'True'.

@ymost ymost linked an issue Jul 28, 2021 that may be closed by this pull request
@ymost ymost added the enhancement New feature or request label Jul 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add function array_sort_asc
3 participants