Comments (5)
So, as a workaround, I had to figure out every exception and catch specific ones depending on backend.
Welcome to Ibis! 😀
from ibis.
the best way to check table existence is by running table_name in list_tables(like=table_name)
Depending on what you intend to do if it does exist, it might be more efficient to do con.table(table_name)
and branch if that operation fails. In the case it exists though, creating the table will do some work to fetch the schema and construct a ibis.Table
object.
try:
t = con.table(table_name)
except Exception:
# table doesn't exist
...
else:
# table does exist
...
That said, a builtin method on con
just checking for existence could definitely be made more efficient.
Can you comment a little more on your use case here? In what cases are you checking for the existence of tables?
from ibis.
Thank you for your reply @jcrist
The problem with this approach is that Exception
is too broad; what if some sort of connection failure happens? Table existence is not checked in this case. And there is no any specific exception for missing table error: all implementations of backend.table(...)
raise their own exception types. So, as a workaround, I had to figure out every exception and catch specific ones depending on backend.
About the use case: I develop a service that manages tables, I do not work with hardcoded table names, they are supplied by users. User provides a table name and the service needs to check whether the table exists.
from ibis.
I develop a service that manages tables, I do not work with hardcoded table names, they are supplied by users. User provides a table name and the service needs to check whether the table exists.
What actions do you do if the table exists already? What do you do if it doesn't exist?
Not asking to argue against adding table_exists
(or some other equivalent method with a different name), just wondering if there are other methods where we might want to add overwrite
, or exists_ok
kwargs to to improve this usecase.
from ibis.
What actions do you do if the table exists already? What do you do if it doesn't exist?
Mostly 2 cases:
create_table
. In this case, it would be nice to have a syntax that runscreate table if not exists
. In some cases it is helpful to get as a result whether the table was created or existed before (so to make some actions on it, like migration or data cleanup).- some business logic, i.e. there is no immediate calls to Ibis afterwards, or it requires some mode complex custom logic before any further Ibis method is called.
from ibis.
Related Issues (20)
- bug Error when connecting to Trino after upgrading to 9.0.0
- bug: table formatting characters don't render monospace with some fonts HOT 5
- bug: `read_parquet` and similar methods silently overwrite tables HOT 8
- bug: names_sort argument in table.pivot_wider has no effect HOT 1
- bug: `create_table(temp=True)` timing out due to slow table existence check HOT 2
- add support for TIMESTAMPTZ HOT 4
- feat: add a table_exists(table_name) api HOT 1
- bug: `to_sql` always shows DuckDB SQL for a memtable even if there's a default backend set HOT 1
- Polars backend can read only 1 csv HOT 1
- docs: add ops docstrings
- ci: more granular cloud run labels
- feat: allow to connect to a duckdb named in-memory database
- feat(memtable): handle castable inputs from date-like strings to date HOT 3
- feat: better distinguish ibis scalars from evaluated results in interactive repr
- feat: add databricks support HOT 2
- bug: .insert() uses column position, not names, to align HOT 1
- feat(settings): generalize and extend settings passthrough dictionary
- feat: Leverage SQLGlot AST for query parsing HOT 2
- bug: EOFError when running ibis tutorial code with ClickHouse backend HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ibis.