mmcdermott commented on issue #43626: URL: https://github.com/apache/arrow/issues/43626#issuecomment-2286707680
Either of those options sounds great to me and like they would be very useful generally, thanks! On Tue, Aug 13, 2024, 11:10 AM Joris Van den Bossche < ***@***.***> wrote: > The Schema object is very much tied to actual data (i.e. a RecordBatch or > Table having a schema), and in that context pyarrow doesn't really support > such notion of optional column (in an actual table, the columns are either > present or are not). > > So I think adding that concept to just a Schema seems unlikely that we > would want to do that. But, we can maybe look at ways to make your use case > easier to do, as it is definitely a valid and logical thing to do. > > One idea could be to add an option to Table.cast(schema) to ignore > columns in the target schema that are not present in the calling object > (i.e. essentially take the calling table's set of columns as the ground > truth for the columns of the result, and only use the passed schema to > lookup the type for each column). > > Another idea could be to make it easier to select a subset of columns in > the schema. For example, assume that a Schema had a select method to > select a subset of the fields of the schema, one could do something like > (in two steps): > > arrow_table = df.to_arrow()arrow_table = arrow_table.cast(label_schema.select(arrow_table.schema.names) > > — > Reply to this email directly, view it on GitHub > <https://github.com/apache/arrow/issues/43626#issuecomment-2286493827>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AADS5XYCFDVE6CBAQW4IPDTZRIOVZAVCNFSM6AAAAABMIMQQC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBWGQ4TGOBSG4> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> > -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
