Re: [Python] Casting struct to map

2023-05-03 Thread Weston Pace
No, struct array is not naturally castable to map. It's not something that can be done zero-copy and I don't think anyone has encountered this need before. Let me make sure I understand. The goal is to go from a type of STRUCT, where every key in the struct has the same type, to a MAP, where eac

Re: [Python] Casting struct to map

2023-05-03 Thread Jerald Alex
Hi Alenka, Great! Thank you so much for your inputs. I have indeed tried to use schema when creating a table from a pylist and it worked but in my use case, I wouldn't know the table schema beforehand especially for the other columns - I need to do transformations before I can cast it to the exp

Re: [Python] Casting struct to map

2023-05-03 Thread Alenka Frim
Hi Alex, passing the schema to from_pylist() method on the Table should work for your example (not sure if it solves your initial problem?) import pyarrow as pa table_schema = pa.schema([pa.field("id", pa.int32()), pa.field("names", pa.map_(pa.string(), pa.string()))]) table_data = [{"id": 1,"n

Re: [Python] Casting struct to map

2023-05-03 Thread Jerald Alex
Any inputs on this please? On Tue, May 2, 2023 at 10:03 AM Jerald Alex wrote: > Hi Experts, > > Can anyone please highlight if it is possible to cast struct to map type? > > I tried the following but it seems to be producing an error as below. > > pyarrow.lib.ArrowNotImplementedError: Unsupport