Open ruiyang2015 opened 2 months ago
It looks like we're not handling the single partition case here. Can you try putting the partition expression in a list
, like ["DATE_TRUNC(c1, MONTH)"]
?
Long term, we'll continue to support strings here, so the current implementation probably doesn't need to be adjusted except to handle the single-string input case.
We could perhaps discuss supporting deferreds here.
It looks like we're not handling the single partition case here. Can you try putting the partition expression in a
list
, like["DATE_TRUNC(c1, MONTH)"]
?Long term, we'll continue to support strings here, so the current implementation probably doesn't need to be adjusted except to handle the single-string input case.
We could perhaps discuss supporting deferreds here.
i tried to pass in as a list, also getting error, looks like this feature is not working.
Ok, yeah, this looks like something isn't getting formatted properly (I think) -- because this works to create an empty table:
[nav] In [6]: con.raw_sql(f"""CREATE TABLE
...: {con.dataset}.newtable (transaction_id INT64, transaction_date DATE)
...: PARTITION BY
...: DATE_TRUNC(transaction_date, MONTH)""")
Out[6]: <google.cloud.bigquery.table._EmptyRowIterator at 0x78220076a9b0>
Ok, this fails because we call sg.to_identifier
on the inputs to partition_by
which leaves us with this SQL:
CREATE TABLE `ibis-gbq`.`_92ff9aec474dffb9d08ce7a2d670d6e934152e1b`.`hi` (`c1` DATE, `c2` INT64) PARTITION BY (`DATE_TRUNC(c1, MONTH)`)
The above would work if we didn't have the function quoted, but unclear to me how we want to handle denoting which arguments to partition_by
are identifiers and which aren't.
I haven't started working on this yet, but I should be able to get to it for the next release (10.0).
I realized pass in list works indeed. So for example:
conn.create_table("name", table, partition_by=["refresh_date"])
But may not work with function like DATE_TRUNC
in the expression, as shown above.
Yep, the thing that doesn't work (reported in the OP) is passing a more complex expression for partitioning.
What happened?
I am trying to use the BigQuery backend to create a table with a partition by expression, ibis is raising exception. here is a simple code to reproduce the error:
What version of ibis are you using?
9.4.0
What backend(s) are you using, if any?
BigQuery
Relevant log output