Skip to content

Commit

Permalink
feat(bigquery): implement create_view and drop_view method
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztof-kwitt authored and cpcloud committed Jan 30, 2023
1 parent 573d806 commit a586473
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 14 additions & 0 deletions ibis/backends/bigquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,20 @@ def drop_table(
table_id = self._fully_qualified_name(name, database)
self.client.delete_table(table_id, not_found_ok=not force)

def create_view(
self, name: str, expr: ir.Table, database: str | None = None
) -> None:
table_id = self._fully_qualified_name(name, database)
sql_select = self.compile(expr)
table = bq.Table(table_id)
table.view_query = sql_select
self.client.create_table(table)

def drop_view(
self, name: str, database: str | None = None, force: bool = False
) -> None:
self.drop_table(name=name, database=database, force=force)


def compile(expr, params=None, **kwargs):
"""Compile an expression for BigQuery."""
Expand Down
1 change: 0 additions & 1 deletion ibis/backends/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ def test_nullable_input_output(con, temp_table):

@mark.notimpl(
[
"bigquery",
"clickhouse",
"datafusion",
"mysql",
Expand Down

0 comments on commit a586473

Please sign in to comment.