Skip to content

Commit

Permalink
chore: unify create_view signature
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Mar 14, 2023
1 parent 16d3f9d commit 21ce5af
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
11 changes: 8 additions & 3 deletions ibis/backends/impala/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,16 @@ def set_compression_codec(self, codec):
self.set_options({'COMPRESSION_CODEC': codec})

def create_view(
self, name: str, expr: ir.Table, database: str | None = None
self,
name: str,
obj: ir.Table,
*,
database: str | None = None,
overwrite: bool = False,
) -> ir.Table:
ast = self.compiler.to_ast(expr)
ast = self.compiler.to_ast(obj)
select = ast.queries[0]
statement = CreateView(name, select, database=database)
statement = CreateView(name, select, database=database, can_exist=overwrite)
self.raw_sql(statement)
return self.table(name, database=database)

Expand Down
12 changes: 4 additions & 8 deletions ibis/backends/pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,12 @@ def create_view(
name: str,
obj: ir.Table,
*,
temp: bool | None = None,
database: str | None = None,
overwrite: bool = False,
) -> ir.Table:
if temp:
raise com.IbisInputError(
"Passing `temp=True` to the Pandas backend create_view method has no "
"effect: all tables are in memory and temporary. Avoid passing the "
"`temp` argument."
)
return self.create_table(name, obj=obj, temp=None, overwrite=overwrite)
return self.create_table(
name, obj=obj, temp=None, database=database, overwrite=overwrite
)

def drop_view(self, name: str, *, force: bool = False) -> None:
self.drop_table(name, force=force)
Expand Down
9 changes: 1 addition & 8 deletions ibis/backends/pyspark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ def create_view(
obj: ir.Table,
*,
database: str | None = None,
temp: bool | None = None,
overwrite: bool = False,
) -> ir.Table:
"""Create a Spark view from a table expression.
Expand All @@ -431,8 +430,6 @@ def create_view(
Expression to use for the view
database
Database name
temp
Whether the view is temporary
overwrite
Replace an existing view of the same name if it exists
Expand All @@ -444,11 +441,7 @@ def create_view(
ast = self.compiler.to_ast(obj)
select = ast.queries[0]
statement = ddl.CreateView(
name,
select,
database=database,
can_exist=overwrite,
temporary=True if temp is None else temp,
name, select, database=database, can_exist=overwrite, temporary=True
)
self.raw_sql(statement.compile())
return self.table(name, database=database)
Expand Down

0 comments on commit 21ce5af

Please sign in to comment.