-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(sql): only return tables in current_database
#9748
Changes from all commits
19ac32a
0ec2503
b14ee2e
af48c66
4cb3300
86fd26f
5e84fcf
7dce011
83c422a
0ebb7ae
f7b4bd4
6e1cf4a
cef5969
a348460
6773416
d9627b4
607682b
3c1296d
7046a2e
56f6f46
936873b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
CREATE USER 'ibis'@'localhost' IDENTIFIED BY 'ibis'; | ||
CREATE SCHEMA IF NOT EXISTS test_schema; | ||
GRANT CREATE, DROP ON *.* TO 'ibis'@'%'; | ||
GRANT CREATE,SELECT,DROP ON `test_schema`.* TO 'ibis'@'%'; | ||
GRANT CREATE,SELECT,DROP ON *.* TO 'ibis'@'%'; | ||
FLUSH PRIVILEGES; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,41 +337,29 @@ def get_schema( | |
------- | ||
sch.Schema | ||
Ibis schema | ||
|
||
""" | ||
conditions = [sg.column("table_name").eq(sge.convert(table_name))] | ||
|
||
if catalog is not None: | ||
conditions.append(sg.column("table_catalog").eq(sge.convert(catalog))) | ||
|
||
if database is not None: | ||
conditions.append(sg.column("table_schema").eq(sge.convert(database))) | ||
|
||
query = ( | ||
sg.select( | ||
"column_name", | ||
"data_type", | ||
sg.column("is_nullable").eq(sge.convert("YES")).as_("nullable"), | ||
query = sge.Describe( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
this=sg.table( | ||
table_name, db=database, catalog=catalog, quoted=self.compiler.quoted | ||
) | ||
.from_(sg.table("columns", db="information_schema")) | ||
.where(sg.and_(*conditions)) | ||
.order_by("ordinal_position") | ||
) | ||
).sql(self.dialect) | ||
|
||
with self._safe_raw_sql(query) as cur: | ||
meta = cur.fetch_arrow_table() | ||
|
||
if not meta: | ||
try: | ||
result = self.con.sql(query) | ||
except duckdb.CatalogException: | ||
raise exc.IbisError(f"Table not found: {table_name!r}") | ||
else: | ||
meta = result.fetch_arrow_table() | ||
|
||
names = meta["column_name"].to_pylist() | ||
types = meta["data_type"].to_pylist() | ||
nullables = meta["nullable"].to_pylist() | ||
types = meta["column_type"].to_pylist() | ||
nullables = meta["null"].to_pylist() | ||
|
||
type_mapper = self.compiler.type_mapper | ||
return sch.Schema( | ||
{ | ||
name: self.compiler.type_mapper.from_string(typ, nullable=nullable) | ||
for name, typ, nullable in zip(names, types, nullables) | ||
name: type_mapper.from_string(typ, nullable=null == "YES") | ||
for name, typ, null in zip(names, types, nullables) | ||
} | ||
) | ||
|
||
|
@@ -512,7 +500,7 @@ def _load_extensions( | |
query = ( | ||
sg.select(f.anon.unnest(f.list_append(C.aliases, C.extension_name))) | ||
.from_(f.duckdb_extensions()) | ||
.where(sg.and_(C.installed, C.loaded)) | ||
.where(C.installed, C.loaded) | ||
) | ||
with self._safe_raw_sql(query) as cur: | ||
installed = map(itemgetter(0), cur.fetchall()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -586,3 +586,9 @@ def drop_sink( | |
) | ||
with self._safe_raw_sql(src): | ||
pass | ||
|
||
@property | ||
def _session_temp_db(self) -> str | None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was actually enough to make tests pass, since otherwise |
||
# Return `None`, because RisingWave does not implement temp tables like | ||
# Postgres | ||
return None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Necessary to allow the ibis user to operate on newly created databases.