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(api): support SchemaLike in Backend.create_table() #9885

Merged
merged 3 commits into from
Aug 24, 2024

Conversation

NickCrews
Copy link
Contributor

@NickCrews NickCrews commented Aug 21, 2024

This requires a test and implementation for other backends, but I wanted to get some feedback before I went for it.

Currently, you have to pass a real ibis.Schema to create_table(). Now it supports dicts and iterables of (name, type) pairs.
This is now consistent with ibis.table().

Example usage:

import ibis
db= ibis.duckdb.connect()
db.create_table(
    "t",
    {"x": []},
    schema={"x": "string"},
)

currently, this errors. With this change, it works.

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.

Seems like a good idea to me!

@cpcloud cpcloud added feature Features or general enhancements ux User experience related issues labels Aug 21, 2024
@NickCrews NickCrews added the docs-preview Add this label to trigger a docs preview label Aug 24, 2024
@ibis-docs-bot ibis-docs-bot bot removed the docs-preview Add this label to trigger a docs preview label Aug 24, 2024
@NickCrews
Copy link
Contributor Author

Ideally in the docs, I would want the type annotations to boil down to the base types, and show that schema can be a Mapping, an ibis Schema, an interable of str,str pairs, etc. But, if we use the nice shorthand SchemaLike typealias, does it show up literally as that in the type hints? I triggered a docs preview to see. If it only shows the alias, I think I would vote for being verbose and writing out the whole thing, I want the documentation to be clear. Others have thoughts here?

@NickCrews NickCrews force-pushed the schema-like-in-create-table branch from 599256a to 12db8cd Compare August 24, 2024 07:04
@NickCrews
Copy link
Contributor Author

I just threw up the test and implemented it for a few backends, let's see which actually fail and need an implementation change

@ibis-docs-bot
Copy link

ibis-docs-bot bot commented Aug 24, 2024

@NickCrews NickCrews force-pushed the schema-like-in-create-table branch 2 times, most recently from e8b429b to ccb001a Compare August 24, 2024 07:15
@NickCrews
Copy link
Contributor Author

NickCrews commented Aug 24, 2024

hmm, darn, yeah the docs render as the opaque "SchemaLike". Any opinions here on what this should look like?

The quartodoc documentation is intimidating for me, I'm not sure if there is some option in there of simplify_type_aliases=True (I doubt it exists). If that indeed doesn't exist, then should I just be verbose and write out the full type? Perhaps could implement our own render_annotation hook in docs/_renderer.py?
image

@NickCrews NickCrews force-pushed the schema-like-in-create-table branch from ccb001a to 6ceb639 Compare August 24, 2024 07:31
@cpcloud
Copy link
Member

cpcloud commented Aug 24, 2024

Let's really try to avoid getting caught up in the docs issue so that the PR can be merged quickly. The rendering of types in docs is separate from this PR.

@cpcloud cpcloud added this to the 9.4 milestone Aug 24, 2024
@cpcloud cpcloud changed the title feat: support SchemaLike in Backend.create_table() feat(api): support SchemaLike in Backend.create_table() Aug 24, 2024
@cpcloud cpcloud added the ci-run-cloud Add this label to trigger a run of BigQuery, Snowflake, and Databricks backends in CI label Aug 24, 2024
@ibis-docs-bot ibis-docs-bot bot removed the ci-run-cloud Add this label to trigger a run of BigQuery, Snowflake, and Databricks backends in CI label Aug 24, 2024
@cpcloud cpcloud force-pushed the schema-like-in-create-table branch from 6ceb639 to 339ec98 Compare August 24, 2024 13:31
@cpcloud cpcloud added the ci-run-cloud Add this label to trigger a run of BigQuery, Snowflake, and Databricks backends in CI label Aug 24, 2024
@ibis-docs-bot ibis-docs-bot bot removed the ci-run-cloud Add this label to trigger a run of BigQuery, Snowflake, and Databricks backends in CI label Aug 24, 2024
@cpcloud cpcloud merged commit 949fbea into ibis-project:main Aug 24, 2024
87 checks passed
@cpcloud cpcloud added the ddl Issues related to creating or altering data definitions label Aug 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ddl Issues related to creating or altering data definitions feature Features or general enhancements ux User experience related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants