[ 
https://issues.apache.org/jira/browse/ARROW-15765?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17497696#comment-17497696
 ] 

Joris Van den Bossche commented on ARROW-15765:
-----------------------------------------------

In context of a full query plan, I think it is important to know the output 
types given the input types, to be able to resolve the types in your full query?

I am wondering if we could make use of some of the newer typing features, which 
would allow to do something like

{code:python}
def simple_function(arrow_array: pa.Array[pa.int32()]) -> pa.Array[pa.int32()]: 
    return call_function("add", [arrow_array, 1])  
{code}

I think such an object with which you can use [] is called a "generic" in 
typing terminology (https://docs.python.org/3.11/library/typing.html#generics), 
and it would allow to more easily get the type of the values in the container. 
On the other hand it creates a bit a separate typing syntax ({{pa.Array}} is 
not actually itself a useful class, it's always subclasses you get in practice).

> [Python] Extracting Type information from Python Objects
> --------------------------------------------------------
>
>                 Key: ARROW-15765
>                 URL: https://issues.apache.org/jira/browse/ARROW-15765
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: C++, Python
>            Reporter: Vibhatha Lakmal Abeykoon
>            Assignee: Vibhatha Lakmal Abeykoon
>            Priority: Major
>
> When creating user defined functions or similar exercises where we want to 
> extract the Arrow data types from the type hints, the existing Python API 
> have some limitations. 
> An example case is as follows;
> {code:java}
> def function(array1: pa.Int64Array, arrya2: pa.Int64Array) -> pa.Int64Array:
>     return pc.call_function("add", [array1, array2])
>   {code}
> We want to extract the fact that array1 is an `pa.Array` of `pa.Int32Type`. 
> At the moment there doesn't exist a straightforward manner to get this done. 
> So the idea is to expose this feature to Python. 



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to