If I would like to use a python function which pro...
# general
k
If I would like to use a python function which produces multiple results and could be returned in multiple variables through a collection, what would be the fastest way to put these into one new column per variable in daft without recalculating the function for each new column?
j
Could you return a Struct type?
k
If my python function returns a dict would the daft udf automatically cast the list of python dicts into a column of struct if the return type was set as a struct?
j
I believe so, and if it doesn’t that’s a great feature we should add I think we should support dicts of columns, which is more efficient than lists of dicts
k
I see, thanks!
@jay is there any way around a list of tuples like (string, int)? It seems that structs are for dicts and lists can only contain one dtype?
j
Nope! Python’s typing is extremely permissive but the same doesn’t apply for most other systems. It’s very inefficient. You have two options:
Copy code
list[struct[x: str, y: int]]

list[str], list[int]
I think the second is much easier to reason about! Less nesting 😛
k
Cool, thanks!!