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

feat: Make Table a Mapping #8672

Open
1 task done
NickCrews opened this issue Mar 15, 2024 · 0 comments
Open
1 task done

feat: Make Table a Mapping #8672

NickCrews opened this issue Mar 15, 2024 · 0 comments
Labels
feature Features or general enhancements

Comments

@NickCrews
Copy link
Contributor

NickCrews commented Mar 15, 2024

Is your feature request related to a problem?

Specifically, I want to be able to to s = ibis.struct(my_table), or {"col1": "default_that_might_be_overwritten", **table, "col2": "always_this_val"}

Describe the solution you'd like

Per #8671 (comment), all that needs to be present is .keys(self) and __getitem__(self, key). So the only thing that is missing is .keys().

This is similar to #8671. See that PR for a few downsides of this approach. Specifically addressing them here:

  • this pollutes the namespace, so now if you have a column called "keys" (which honestly seems pretty likely), then if you try to access that column via table.keys you now get an error. You would need to do table["keys"]. This is the reason I didn't add .values() and .items() methods as well.
  • To fully follow the collections.abc.Mapping, we would also need to implement __len__(), which I think we all have decided is a footgun and not a good idea.
  • That PR suffered from the problem that **StructValue implied that **MapValue and *ArrayValue might work (but they never could). On a Table, we don't suffer from this possible point of confusion.

IDK, maybe these downsides are not worth it, **{c: table[c] for c in table.columns} is not that painful.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@NickCrews NickCrews added the feature Features or general enhancements label Mar 15, 2024
NickCrews added a commit to NickCrews/ibis that referenced this issue Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Features or general enhancements
Projects
Status: backlog
Development

Successfully merging a pull request may close this issue.

1 participant