Skip to content

Commit 95dc46e

Browse files
authored
feat(cubesql): Add support for current_catalog function for postgresql protocol (#9839)
1 parent aaa90f0 commit 95dc46e

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

rust/cubesql/cubesql/src/compile/engine/udf/common.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4346,13 +4346,6 @@ pub fn register_fun_stubs(mut ctx: SessionContext) -> SessionContext {
43464346
register_fun_stub!(udf, "cosh", tsig = [Float64], rettyp = Float64);
43474347
register_fun_stub!(udf, "cot", tsig = [Float64], rettyp = Float64);
43484348
register_fun_stub!(udf, "cotd", tsig = [Float64], rettyp = Float64);
4349-
register_fun_stub!(
4350-
udf,
4351-
"current_catalog",
4352-
argc = 0,
4353-
rettyp = Utf8,
4354-
vol = Stable
4355-
);
43564349
register_fun_stub!(udf, "current_query", argc = 0, rettyp = Utf8, vol = Stable);
43574350
register_fun_stub!(udf, "current_role", argc = 0, rettyp = Utf8, vol = Stable);
43584351
register_fun_stub!(

rust/cubesql/cubesql/src/compile/query_engine.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ impl QueryEngine for SqlQueryEngine {
436436
"PostgreSQL 14.2 on x86_64-cubesql".to_string(),
437437
));
438438
ctx.register_udf(create_db_udf("current_database".to_string(), state.clone()));
439+
ctx.register_udf(create_db_udf("current_catalog".to_string(), state.clone()));
439440
ctx.register_udf(create_db_udf("current_schema".to_string(), state.clone()));
440441
ctx.register_udf(create_current_user_udf(
441442
state.clone(),
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
source: cubesql/src/compile/test/test_introspection.rs
3-
expression: "execute_query(\"select current_database(), current_schema(), current_user;\".to_string(),\nDatabaseProtocol::PostgreSQL).await?"
3+
expression: "execute_query(\"select current_database(), current_catalog, current_schema(), current_user;\".to_string(),\nDatabaseProtocol::PostgreSQL).await?"
44
---
5-
+------------------+----------------+--------------+
6-
| current_database | current_schema | current_user |
7-
+------------------+----------------+--------------+
8-
| cubedb | public | ovr |
9-
+------------------+----------------+--------------+
5+
+------------------+-----------------+----------------+--------------+
6+
| current_database | current_catalog | current_schema | current_user |
7+
+------------------+-----------------+----------------+--------------+
8+
| cubedb | cubedb | public | ovr |
9+
+------------------+-----------------+----------------+--------------+

rust/cubesql/cubesql/src/compile/test/test_introspection.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,8 @@ async fn datagrip_introspection() -> Result<(), CubeError> {
842842
insta::assert_snapshot!(
843843
"datagrip_introspection",
844844
execute_query(
845-
"select current_database(), current_schema(), current_user;".to_string(),
845+
"select current_database(), current_catalog, current_schema(), current_user;"
846+
.to_string(),
846847
DatabaseProtocol::PostgreSQL
847848
)
848849
.await?

0 commit comments

Comments
 (0)