Skip to content

Commit

Permalink
refactor(duckdb): remove lit
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Oct 11, 2023
1 parent 221b630 commit 6f77df9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions ibis/backends/duckdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from ibis import util
from ibis.backends.base import CanCreateSchema
from ibis.backends.base.sql.alchemy import BaseAlchemyBackend
from ibis.backends.base.sqlglot import C, F, lit
from ibis.backends.base.sqlglot import C, F
from ibis.backends.duckdb.compiler import DuckDBSQLCompiler
from ibis.backends.duckdb.datatypes import DuckDBType
from ibis.expr.operations.relations import PandasDataFrameProxy
Expand Down Expand Up @@ -731,15 +731,19 @@ def list_tables(
>>> con.list_tables(schema="my_schema")
['baz']
"""
database = F.current_database() if database is None else lit(database)
schema = F.current_schema() if schema is None else lit(schema)
database = (
F.current_database() if database is None else sg.exp.convert(database)
)
schema = F.current_schema() if schema is None else sg.exp.convert(schema)

sql = (
sg.select(C.table_name)
.from_(sg.table("tables", db="information_schema"))
.distinct()
.where(
C.table_catalog.eq(database).or_(C.table_catalog.eq(lit("temp"))),
C.table_catalog.eq(database).or_(
C.table_catalog.eq(sg.exp.convert("temp"))
),
C.table_schema.eq(schema),
)
.sql(self.name, pretty=True)
Expand Down

0 comments on commit 6f77df9

Please sign in to comment.