Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add as_arrow() to Schema class #532

Merged
merged 2 commits into from
Mar 19, 2024
Merged

Add as_arrow() to Schema class #532

merged 2 commits into from
Mar 19, 2024

Conversation

ndrluis
Copy link
Collaborator

@ndrluis ndrluis commented Mar 18, 2024

Use case

import pyarrow as pa
import pandas as pd

table = catalog.load_table('some_schema.table_name')
schema = table.schema().as_arrow()

data = {
    'id_job': [1, 2, 3, 4],
    'description': ['some text', 'some text', 'some text', 'some text']
}

df = pd.DataFrame(data)

pa_df = pa.Table.from_pandas(df, schema=schema)

table.append(pa_df)

Copy link
Contributor

@Fokko Fokko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for raising this! This makes sense to me. Could you add this to the docs as well?

pyiceberg/schema.py Outdated Show resolved Hide resolved
@ndrluis ndrluis requested a review from Fokko March 18, 2024 20:59
@kevinjqliu
Copy link
Contributor

(reposting from slack)
This is great. Exposing the Iceberg Table's schema as pyarrow schema will also solve the problem I was having here

#520 (comment)

@Fokko Fokko merged commit d3db840 into apache:main Mar 19, 2024
7 checks passed
@Fokko
Copy link
Contributor

Fokko commented Mar 19, 2024

Thanks @ndrluis for adding this, and @kevinjqliu for joining the conversation 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants