Quansight / omnisci

Explorations on using MapD and Jupyter together.
4 stars 1 forks source link

Ibis create_table improvements #123

Open xmnlab opened 4 years ago

xmnlab commented 4 years ago

from MikeH

Thoughts on an Ibis feature… it’s often useful to create a table from a pandas DF, but any inferred schema may not be perfect. But assistance with inferring is useful.

  1. The con.create_table does not support the obj param as a pandas DF
  2. if it did, it executes the SQL rather than return an expression - I’m thinking it would be nice if the return was an expression I could .compile() or .execute().
  3. so create_table doesn’t infer from a DF, and load_table lets the DB infer if the table does not exist
  4. I found a path which can infer the ibis schema from a DF, but it’s a bit convoluted
df = pd.DataFrame({'a': [1,2,3]})
conp = ibis.pandas.connect({'mh_a': df})
a = conp.table('mh_a')
con.create_table('mh_a', schema=a.schema())

To illustrate the problem, that declare the column as a BIGINT (yes, there are other ways around that)

the way we might use such a feature is to call the function to print the inferred schema sql, then copy the sql, manually adjust it, and execute that directly. I know create_table has some parameters for with, but I don't know if it can handle all options that raw create table sql can do, so I tend to revert to raw sql for that.

kcpevey commented 4 years ago

This is from a slack discussion, we haven't begun work on this yet.

xmnlab commented 4 years ago

not started yet.