� ?��g�[��:�ddlmZmZmZmZmZmZmZmZm Z m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHddlImJZJddlKZKddlLmMZMddlNZNddlOZPddlOmQZQddlRmSZSd�ZTeJdd ��ZUd �ZVd �ZWd �ZXd �ZYd�ZZd�Z[d�Z\d�Z]e]��d d�Z^d!dd�d�Z_ddd�d�Z`d�Zad"dd�d�Zbd"dd�d�Zcdddd�d�Zdd�Zed�ZfdS)#�)H�Function�FunctionOptions�FunctionRegistry�HashAggregateFunction�HashAggregateKernel�Kernel�ScalarAggregateFunction�ScalarAggregateKernel�ScalarFunction� ScalarKernel�VectorFunction� VectorKernel�ArraySortOptions�AssumeTimezoneOptions� CastOptions� CountOptions�CumulativeOptions�CumulativeSumOptions�DayOfWeekOptions�DictionaryEncodeOptions�RunEndEncodeOptions�ElementWiseAggregateOptions�ExtractRegexOptions� FilterOptions� IndexOptions� JoinOptions�ListSliceOptions�ListFlattenOptions�MakeStructOptions�MapLookupOptions�MatchSubstringOptions� ModeOptions� NullOptions� PadOptions�PairwiseOptions�PartitionNthOptions�QuantileOptions� RandomOptions� RankOptions�ReplaceSliceOptions�ReplaceSubstringOptions�RoundBinaryOptions� RoundOptions�RoundTemporalOptions�RoundToMultipleOptions�ScalarAggregateOptions�SelectKOptions�SetLookupOptions� SliceOptions� SortOptions� SplitOptions�SplitPatternOptions�StrftimeOptions�StrptimeOptions�StructFieldOptions� TakeOptions�TDigestOptions� TrimOptions�Utf8NormalizeOptions�VarianceOptions� WeekOptions� call_function�function_registry� get_function�list_functions�call_tabular_function�register_scalar_function�register_tabular_function�register_aggregate_function�register_vector_function� UdfContext� Expression)� namedtupleN)�dedent)�_compute_docstrings)� docscrapec��|jjS�N)�_doc� arg_names)�funcs �_/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/pyarrow/compute.py�_get_arg_namesrUks �� �9� ���_OptionsClassDoc)�paramsc�p�|jsdStj|j��}t|d��S)N� Parameters)�__doc__rN�NumpyDocStringrW)� options_class�docs rT�_scrape_options_class_docr_rs8�� � ���t� � "�=�#8� 9� 9�C� �C� �-� .� .�.rVc ���|j}t|j|j|j|j���|_||_||_g}|j }|s*|jdkrdnd}d� |j|��}|� |�d���|j }|r|� |�d���tj�|j��} |� t!d����t#|��} | D]@} |jd vrd } nd } |� | �d | �d ���|� d���A|��"t'|��} | rS| jD]J}|� |j�d |j�d ���|jD]}|� d|�d �����Kn�t/jd|j�d�t2��t5j|��}|j���D]B}|� t!d� |j|j�������C|� t!d|j�d�����|� t!d����| �H|� d� t!| ���d ������d�|��|_ |S)N)�name�arityr]�options_required�� arguments�argumentz,Call compute function {!r} with the given {}z. z z. Parameters ---------- )�vector�scalar_aggregatez Array-likezArray-like or scalar-likez : � z" Argument to compute function. z zOptions class z does not have a docstringz� {0} : optional Parameter for {1} constructor. Either `options` or `{0}` can be passed, but not both at the same time. z& options : pyarrow.compute.zK, optional Alternative way of passing options. z� memory_pool : pyarrow.MemoryPool, optional If not passed, will allocate memory from the default memory pool. z {} �)!rQ�dictrarbr]rc�__arrow_compute_function__�__name__� __qualname__�summary�format�append� descriptionrM�function_doc_additions�getrLrU�kindr_rX�type�desc�warnings�warn�RuntimeWarning�inspect� signature� parameters�values�strip�joinr[)�wrapper� exposed_namerSr]�cpp_doc� doc_piecesro�arg_strrr� doc_additionrR�arg_name�arg_type�options_class_doc�p�s� options_sigs rT�_decorate_compute_functionr�ys����i�G�)-� �Y��j��+� �1� *3�*3�*3�G�&� $�G��'�G���J��o�G� �0�!%��a���+�+�Z��A��F�4�9�g�.�.� �����'�'�'�(�(�(��%�K��0����[�.�.�.�/�/�/�&�=�A�A�$�)�L�L�L����f� � � ���� �t�$�$�I��A�A�� �9�6� 6� 6�#�H�H�2�H����X�6�6�(�6�6�6�7�7�7����?�@�@�@�@�� �5�m�D�D�� � =�&�-� 4� 4���!�!�Q�V�":�":���":�":�":�;�;�;���4�4�A��%�%�l�Q�l�l�l�3�3�3�3�4� 4� �M�7�=�+A�7�7�7�8F� H� H� H�!�+�M�:�:�K� �+�2�2�4�4� =� =���!�!�&�*��F�1�6�=�#9�:�:� #<�#<�=�=�=�=� ���&�"�'4�'=�"�"�"��� � � � ���f� � � ���� �����(�/�/�&��*>�*>�*D�*D�T�*J�*J�K�K�L�L�L��g�g�j�)�)�G�O� �NrVc���|jj}|sdS t��|S#t$r1t jd�|��t��YdSwxYw)Nz!Python binding for {} not exposed)rQr]�globals�KeyErrorrxryrprz)rS� class_names rT�_get_options_classr��su����(�J� ���t���y�y��$�$�� ����� �9��v�j�)�)�>� ;� ;� ;��t�t����s�&�7A!� A!c �*�|s|r,|�"td�|�����||i|��S|�`t|t��r|di|��St||��r|Std�||t |�������dS)NzMFunction {!r} called with both an 'options' argument and additional argumentsz-Function {!r} expected a {} parameter, got {}�)� TypeErrorrp� isinstancerkrv)rar]�options�args�kwargss rT�_handle_optionsr��s��� �.�v�.� � ��+�������� ��}�d�-�f�-�-�-��� �g�t� $� $� � �=�+�+�7�+�+� +� ��� /� /� ��N�� ;� �V�D�-��g��� 7� 7�9�9� 9� �4rVc�@������� dd����fd� }n ddd�����fd� }|S)N�� memory_poolc �2���tur8t|���kr%t��d��dt|���d����|r=t|dt��r"t j�t |����S��|d|��S)N� takes � positional argument(s), but � were givenr)�Ellipsis�lenr�r�rJ�_call�list�call)r�r�rbrS� func_names ���rTr�z&_make_generic_wrapper.<locals>.wrapper�s�����H�$�$��T���e�);�);�� �2�2��2�2��t�9�9�2�2�2����� ?� �4��7�J�7�7� ?�!�'� �4��:�:�>�>�>��9�9�T�4��5�5� 5rV)r�r�c ����turMt|���kr%t��d��dt|���d����|�d�}|d��}nd}t��|||��}|r>t |dt ��r#t j�t|��|��S��|||��S)Nr�r�r�r�r) r�r�r�r�r�rJr�r�r�) r�r�r�r�� option_argsrbrSr�r]s ����rTr�z&_make_generic_wrapper.<locals>.wrapper�s�����H�$�$��t�9�9�u�$�$�#�$�6�6�U�6�6�"�4�y�y�6�6�6����#�5�6�6�l� ��F�U�F�|��� � �%�i���&1�6�;�;�G�� H� �4��7�J�7�7� H�!�'� �4��:�:�w�G�G�G��9�9�T�7�K�8�8� 8rVr�)r�rSr]rbr�s```` rT�_make_generic_wrapperr��s���������'+� 6� 6� 6� 6� 6� 6� 6� 6� 6� 6�(,�T� 9� 9� 9� 9� 9� 9� 9� 9� 9� 9� �NrVc�l�ddlm}g}|D]&}|�|||j�����'|D]&}|�|||j�����'|��tj|��}|j���D]K}|j|j |j fvsJ�|r|� |j ���}|�|���L|�|d|j d�����|�|d|j d�����tj |��S)Nr)� Parameter)rur�)�defaultr�) r{r�rq�POSITIONAL_ONLY�VAR_POSITIONALr|r}r~ru�POSITIONAL_OR_KEYWORD� KEYWORD_ONLY�replace� Signature)rR� var_arg_namesr]r�rXrar�r�s rT�_make_signaturer� s���!�!�!�!�!�!� �F��B�B��� � �i�i��i�&?�@�@�A�A�A�A��A�A��� � �i�i��i�&>�?�?�@�@�@�@�� ��'� �6�6� ��'�.�.�0�0� � �A��6�i�=�'�4�6�6�6�6�6�� ;��I�I�9�#9�I�:�:�� �M�M�!� � � � �� � �i�i� �9�+A�(,�.�.�.� /� /� /� �M�M�)�)�M�9�+A�$(�*�*�*�+�+�+� � �V� $� $�$rVc�R�t|��}t|��}|o|d�d��}|r)|����d��g}ng}t ||||j���}t|||��|_t||||��S)N������*)rb) r�rU� startswith�pop�lstripr�rbr�� __signature__r�)rarSr]rR� has_varargr�r�s rT�_wrap_functionr�#s���&�t�,�,�M��t�$�$�I��<�y��}�7�7��<�<�J���"�����/�/��4�4�5� � �� �#� �d�M���5�5�5�G�+�I�}�,9�;�;�G�� %�g�t�T�=� I� I�IrVc�^�t��}t��}ddd�}|���D]v}|�||��}|�|��}|jdkr�9|jdkr |jdkr�P||vs J|���t||��x||<||<�wdS)z� Make global functions wrapping each compute function. Note that some of the automatically-generated wrappers may be overridden by custom versions below. �and_�or_)�and�or�hash_aggregaterhrN)r�rArCrtrBrurbr�)�g�reg�rewrites�cpp_namerarSs rT�_make_global_functionsr�3s��� � � �A� � � �C�����H��&�&�(�(� ;� ;���|�|�H�h�/�/������)�)�� �9�(� (� (� � �9�*� *� *�t�z�Q��� ��1�}�}�}�d�}�}�}� .�t�T� :� :�:��(� �a��g�g� ;� ;rVc��|dup|du}|r|�td���|�Qtjj�|��}|durt j|��}nt j|��}td|g||��S)a� Cast array values to another data type. Can also be invoked as an array instance method. Parameters ---------- arr : Array-like target_type : DataType or str Type to cast to safe : bool, default True Check for overflows or other unsafe conversions options : CastOptions, default None Additional checks pass by CastOptions memory_pool : MemoryPool, optional memory pool to use for allocations during function execution. Examples -------- >>> from datetime import datetime >>> import pyarrow as pa >>> arr = pa.array([datetime(2010, 1, 1), datetime(2015, 1, 1)]) >>> arr.type TimestampType(timestamp[us]) You can use ``pyarrow.DataType`` objects to specify the target type: >>> cast(arr, pa.timestamp('ms')) <pyarrow.lib.TimestampArray object at ...> [ 2010-01-01 00:00:00.000, 2015-01-01 00:00:00.000 ] >>> cast(arr, pa.timestamp('ms')).type TimestampType(timestamp[ms]) Alternatively, it is also supported to use the string aliases for these types: >>> arr.cast('timestamp[ms]') <pyarrow.lib.TimestampArray object at ...> [ 2010-01-01 00:00:00.000, 2015-01-01 00:00:00.000 ] >>> arr.cast('timestamp[ms]').type TimestampType(timestamp[ms]) Returns ------- casted : Array The cast result as a new Array NzRMust either pass values for 'target_type' and 'safe' or pass a value for 'options'F�cast) � ValueError�pa�types�lib� ensure_typer�unsafe�safer@)�arr� target_typer�r�r��safe_vars_passeds rTr�r�Ss���l�D�(�F�k��.E���;�W�0��:�;�;� ;����h�l�.�.�{�;�;� � �5�=�=�!�(��5�5�G�G�!�&�{�3�3�G� ��#���� =� =�=rVr�c�v�|�2|�|�|||z ��}n.|�|��}n|�|�d|��}t|tj��stj||j���}n=|j|jkr-tj|���|j���}t|���}td|g||��}|�T|���dkr<tj|���|ztj �����}|S)a Find the index of the first occurrence of a given value. Parameters ---------- data : Array-like value : Scalar-like object The value to search for. start : int, optional end : int, optional memory_pool : MemoryPool, optional If not passed, will allocate memory from the default memory pool. Returns ------- index : int the index, or -1 if not found Examples -------- >>> import pyarrow as pa >>> import pyarrow.compute as pc >>> arr = pa.array(["Lorem", "ipsum", "dolor", "sit", "Lorem", "ipsum"]) >>> pc.index(arr, "ipsum") <pyarrow.Int64Scalar: 1> >>> pc.index(arr, "ipsum", start=2) <pyarrow.Int64Scalar: 5> >>> pc.index(arr, "amet") <pyarrow.Int64Scalar: -1> Nr�rv��value�index) �slicer�r��Scalar�scalarrv�as_pyrr@�int64)�datar��start�endr�r��results rTr�r��s��> �� �?��:�:�e�S�5�[�1�1�D�D��:�:�e�$�$�D�D� ���z�z�!�S�!�!�� �e�R�Y� '� '�9�� �%�d�i�0�0�0��� ��e�j� � �� �%�+�+�-�-�d�i�8�8�8����'�'�'�G� �7�T�F�G�[� A� A�F� ��V�\�\�^�^�q�0�0���6�<�<�>�>�E�1��� � �C�C�C�� �MrVT)� boundscheckr�c�J�t|���}td||g||��S)a� Select values (or records) from array- or table-like data given integer selection indices. The result will be of the same type(s) as the input, with elements taken from the input array (or record batch / table fields) at the given indices. If an index is null then the corresponding value in the output will be null. Parameters ---------- data : Array, ChunkedArray, RecordBatch, or Table indices : Array, ChunkedArray Must be of integer type boundscheck : boolean, default True Whether to boundscheck the indices. If False and there is an out of bounds index, will likely cause the process to crash. memory_pool : MemoryPool, optional If not passed, will allocate memory from the default memory pool. Returns ------- result : depends on inputs Selected values for the given indices Examples -------- >>> import pyarrow as pa >>> arr = pa.array(["a", "b", "c", None, "e", "f"]) >>> indices = pa.array([0, None, 4, 3]) >>> arr.take(indices) <pyarrow.lib.StringArray object at ...> [ "a", null, "e", null ] )r��take)r:r@)r��indicesr�r�r�s rTr�r��s-��P�k�2�2�2�G� ��$���'�;� G� G�GrVc�:�t|tjtjtjf��stj||j���}n=|j|jkr-tj|���|j���}td||g��S)aeReplace each null element in values with a corresponding element from fill_value. If fill_value is scalar-like, then every null element in values will be replaced with fill_value. If fill_value is array-like, then the i-th element in values will be replaced with the i-th element in fill_value. The fill_value's type must be the same as that of values, or it must be able to be implicitly casted to the array's type. This is an alias for :func:`coalesce`. Parameters ---------- values : Array, ChunkedArray, or Scalar-like object Each null element is replaced with the corresponding value from fill_value. fill_value : Array, ChunkedArray, or Scalar-like object If not same type as values, will attempt to cast. Returns ------- result : depends on inputs Values with all null elements replaced Examples -------- >>> import pyarrow as pa >>> arr = pa.array([1, 2, None, 3], type=pa.int8()) >>> fill_value = pa.scalar(5, type=pa.int8()) >>> arr.fill_null(fill_value) <pyarrow.lib.Int8Array object at ...> [ 1, 2, 5, 3 ] >>> arr = pa.array([1, 2, None, 4, None]) >>> arr.fill_null(pa.array([10, 20, 30, 40, 50])) <pyarrow.lib.Int64Array object at ...> [ 1, 2, 30, 4, 50 ] r��coalesce) r�r��Array� ChunkedArrayr�r�rvr�r@)r~� fill_values rT� fill_nullr��s���f �j�2�8�R�_�b�i�"H� I� I�E��Y�z�� �<�<�<� � � �� �� '� '��Y�z�/�/�1�1�� �D�D�D� � ��f�j�%9� :� :�:rVc���|�g}t|tjtjf��r|�d��nt d�|��}t ||��}td|g||��S)a� Select the indices of the top-k ordered elements from array- or table-like data. This is a specialization for :func:`select_k_unstable`. Output is not guaranteed to be stable. Parameters ---------- values : Array, ChunkedArray, RecordBatch, or Table Data to sort and get top indices from. k : int The number of `k` elements to keep. sort_keys : List-like Column key names to order by when input is table-like data. memory_pool : MemoryPool, optional If not passed, will allocate memory from the default memory pool. Returns ------- result : Array Indices of the top-k ordered elements Examples -------- >>> import pyarrow as pa >>> import pyarrow.compute as pc >>> arr = pa.array(["a", "b", "c", None, "e", "f"]) >>> pc.top_k_unstable(arr, k=3) <pyarrow.lib.UInt64Array object at ...> [ 5, 4, 2 ] N)�dummy� descendingc� �|dfS)Nr�r���key_names rT�<lambda>z top_k_unstable.<locals>.<lambda>[s ��(�L�)A�rV�select_k_unstable�r�r�r�r�rq�mapr1r@�r~�k� sort_keysr�r�s rT�top_k_unstabler�1s}��J��� ��&�2�8�R�_�5�6�6�N����0�1�1�1�1��A�A�9�M�M� ��Q� �*�*�G� �,�v�h��� M� M�MrVc���|�g}t|tjtjf��r|�d��nt d�|��}t ||��}td|g||��S)a� Select the indices of the bottom-k ordered elements from array- or table-like data. This is a specialization for :func:`select_k_unstable`. Output is not guaranteed to be stable. Parameters ---------- values : Array, ChunkedArray, RecordBatch, or Table Data to sort and get bottom indices from. k : int The number of `k` elements to keep. sort_keys : List-like Column key names to order by when input is table-like data. memory_pool : MemoryPool, optional If not passed, will allocate memory from the default memory pool. Returns ------- result : Array of indices Indices of the bottom-k ordered elements Examples -------- >>> import pyarrow as pa >>> import pyarrow.compute as pc >>> arr = pa.array(["a", "b", "c", None, "e", "f"]) >>> pc.bottom_k_unstable(arr, k=3) <pyarrow.lib.UInt64Array object at ...> [ 0, 1, 2 ] N)r�� ascendingc� �|dfS)Nr�r�r�s rTr�z#bottom_k_unstable.<locals>.<lambda>�s ��(�K�)@�rVr�r�r�s rT�bottom_k_unstabler�`s}��J��� ��&�2�8�R�_�5�6�6�M����/�0�0�0�0��@�@�)�L�L� ��Q� �*�*�G� �,�v�h��� M� M�MrV�system)� initializerr�r�c�J�t|���}tdg|||���S)aB Generate numbers in the range [0, 1). Generated values are uniformly-distributed, double-precision in range [0, 1). Algorithm and seed can be changed via RandomOptions. Parameters ---------- n : int Number of values to generate, must be greater than or equal to 0 initializer : int or str How to initialize the underlying random generator. If an integer is given, it is used as a seed. If "system" is given, the random generator is initialized with a system-specific source of (hopefully true) randomness. Other values are invalid. options : pyarrow.compute.RandomOptions, optional Alternative way of passing options. memory_pool : pyarrow.MemoryPool, optional If not passed, will allocate memory from the default memory pool. )r�random)�length)r(r@)�nrr�r�s rTrr�s-��,� �4�4�4�G� ��2�w� �A� F� F� F�FrVc��t|��}|dkr�t|dttf��rt j|d��St|dt ��rt j|d��Stdt|d�������t j|��S)aReference a column of the dataset. Stores only the field's name. Type and other information is known only when the expression is bound to a dataset having an explicit scheme. Nested references are allowed by passing multiple names or a tuple of names. For example ``('foo', 'bar')`` references the field named "bar" inside the field named "foo". Parameters ---------- *name_or_index : string, multiple strings, tuple or int The name or index of the (possibly nested) field the expression references to. Returns ------- field_expr : Expression Reference to the given field Examples -------- >>> import pyarrow.compute as pc >>> pc.field("a") <pyarrow.compute.Expression a> >>> pc.field(1) <pyarrow.compute.Expression FieldPath(1)> >>> pc.field(("a", "b")) <pyarrow.compute.Expression FieldRef.Nested(FieldRef.Name(a) ... >>> pc.field("a", "b") <pyarrow.compute.Expression FieldRef.Nested(FieldRef.Name(a) ... rdrzCfield reference should be str, multiple str, tuple or integer, got ) r�r��str�intrJ�_field�tuple� _nested_fieldr�rv)� name_or_indexrs rT�fieldr �s���B �M���A��A�v�v� �m�A�&��c� � 3� 3� ��$�]�1�%5�6�6� 6� � �a�(�%� 0� 0� ��+�M�!�,<�=�=� =��9� $�]�1�%5� 6� 6�9�9��� � �'� �6�6�6rVc�*�tj|��S)aBExpression representing a scalar value. Parameters ---------- value : bool, int, float or string Python value of the scalar. Note that only a subset of types are currently supported. Returns ------- scalar_expr : Expression An Expression representing the scalar value )rJ�_scalarr�s rTr�r��s�� � �e� $� $�$rV)NNNN)NNrP)g�pyarrow._computerrrrrrr r r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrErFrGrHrIrJ� collectionsrKr{�textwraprLrx�pyarrowr�rM�pyarrow.vendoredrNrUrWr_r�r�r�r�r�r�r�r�r�r�r�r�r�rr r�r�rVrT�<module>rs���$M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�M�^#�"�"�"�"�"�������������������'�'�'�'�'�'�&�&�&�&�&�&�����:�0�+�>�>��/�/�/�P�P�P�f � � ����*���>%�%�%�. J� J� J� ;�;�;�:�����B>�B>�B>�B>�J/�D�/�/�/�/�/�d(,��)H�)H�)H�)H�)H�X8;�8;�8;�v,N�T�,N�,N�,N�,N�,N�^,N��,N�,N�,N�,N�,N�^&�t��G�G�G�G�G�4.7�.7�.7�b%�%�%�%�%rV
Memory