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

fix(api): ensure memtable schema and columns match #10617

Merged
merged 2 commits into from
Dec 27, 2024

Conversation

deepyaman
Copy link
Contributor

@deepyaman deepyaman commented Dec 26, 2024

Description of changes

Before this change, if you pass a SchemaLike that isn't actually a Schema, it won't automatically rename the auto-generated pandas column names. For example:

import pandas as pd

df = pd.DataFrame([[1, 2], [3, 4]])
schema = {"a": "int64", "b": "int64"}
t = ibis.memtable(df, schema=schema)
t.a.execute()  # Raises a KeyError

This PR goes ahead and constructs the Schema, if passed—work that was going to be done anyway. That way, getattr(schema, "names") finds the passed names, and the rename is performed.

@github-actions github-actions bot added the tests Issues or PRs related to tests label Dec 26, 2024
Copy link
Member

@cpcloud cpcloud left a comment

Choose a reason for hiding this comment

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

You need to monkey patch the default backend setting

ibis/expr/tests/test_api.py Outdated Show resolved Hide resolved
@deepyaman
Copy link
Contributor Author

deepyaman commented Dec 26, 2024

You need to monkey patch the default backend setting

Where?

(Also, why? Did I cause the nix failure; doesnt seem related to my change, even though its related to the default backend?)

@cpcloud
Copy link
Member

cpcloud commented Dec 26, 2024

You need to monkey patch the default backend setting

Where?

(Also, why? Did I cause the nix failure; doesnt seem related to my change, even though its related to the default backend?)

The default backend attribute is global state, and tests run in a random order. This means that any of our suites could have failed in the way, you just got lucky 😄

@cpcloud cpcloud added this to the 10.0 milestone Dec 26, 2024
@cpcloud cpcloud added the datatypes Issues relating to ibis's datatypes (under `ibis.expr.datatypes`) label Dec 26, 2024
@deepyaman deepyaman marked this pull request as ready for review December 26, 2024 22:40
@deepyaman deepyaman requested a review from cpcloud December 26, 2024 22:40
@cpcloud cpcloud merged commit f1837b7 into ibis-project:main Dec 27, 2024
88 checks passed
@deepyaman deepyaman deleted the fix/api/schema-mismatch branch December 27, 2024 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datatypes Issues relating to ibis's datatypes (under `ibis.expr.datatypes`) tests Issues or PRs related to tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants