Skip to content

Commit 0fb183a

Browse files
authored
fix(cubesql): Allow repeated aliases (auto-realias) (#9863)
Signed-off-by: Alex Qyoun-ae <[email protected]>
1 parent 9d5794e commit 0fb183a

11 files changed

+143
-169
lines changed

packages/cubejs-backend-native/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cubenativeutils/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cubesql/Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cubesql/cubesql/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ homepage = "https://cube.dev"
1010

1111
[dependencies]
1212
arc-swap = "1"
13-
datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "016c22f74b82f241fc01abd205020cb52b6c911e", default-features = false, features = [
13+
datafusion = { git = 'https://github.com/cube-js/arrow-datafusion.git', rev = "4f8f7de0617b0580beb5d4140b5f9ce58ef18efc", default-features = false, features = [
1414
"regex_expressions",
1515
"unicode_expressions",
1616
] }

rust/cubesql/cubesql/src/compile/parser.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,6 @@ pub fn parse_sql_to_statements(
6161
let query = query.replace("UNSIGNED INTEGER", "bigint");
6262

6363
// DBeaver
64-
let query = query.replace(
65-
"SELECT db.oid,db.* FROM pg_catalog.pg_database db",
66-
"SELECT db.oid as _oid,db.* FROM pg_catalog.pg_database db",
67-
);
68-
let query = query.replace(
69-
"SELECT t.oid,t.*,c.relkind",
70-
"SELECT t.oid as _oid,t.*,c.relkind",
71-
);
72-
let query = query.replace(
73-
"SELECT n.oid,n.*,d.description FROM",
74-
"SELECT n.oid as _oid,n.*,d.description FROM",
75-
);
76-
let query = query.replace("SELECT c.oid,c.*,", "SELECT c.oid as _oid,c.*,");
77-
let query = query.replace("SELECT a.oid,a.*,", "SELECT a.oid as _oid,a.*,");
7864
let query = query.replace(
7965
"LEFT OUTER JOIN pg_depend dep on dep.refobjid = a.attrelid AND dep.deptype = 'i' and dep.refobjsubid = a.attnum and dep.classid = dep.refclassid",
8066
"LEFT OUTER JOIN pg_depend dep on dep.refobjid = a.attrelid AND dep.deptype = 'i' and dep.refobjsubid = a.attnum",
@@ -187,12 +173,6 @@ pub fn parse_sql_to_statements(
187173
"WHERE quote_ident(table_schema) IN (current_user, current_schema())",
188174
);
189175

190-
// psqlODBC
191-
let query = query.replace(
192-
"select NULL, NULL, NULL",
193-
"select NULL, NULL AS NULL2, NULL AS NULL3",
194-
);
195-
196176
// Work around an issue with lowercase table name when queried as uppercase,
197177
// an uncommon way of casting literals, and skip a few funcs along the way
198178
let query = query.replace(
@@ -212,12 +192,6 @@ pub fn parse_sql_to_statements(
212192
"c.relname AS partition_name,",
213193
);
214194

215-
// Work around an issue with NULL, NULL, NULL in SELECT
216-
let query = query.replace(
217-
"p.proname AS PROCEDURE_NAME, NULL, NULL, NULL, ",
218-
"p.proname AS PROCEDURE_NAME, NULL AS NULL, NULL AS NULL2, NULL AS NULL3, ",
219-
);
220-
221195
// Quicksight workarounds
222196
// subquery must have an alias
223197
let query = query.replace(
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
source: cubesql/src/compile/mod.rs
3-
expression: "execute_query(\"select NULL, NULL, NULL\".to_string(),\n DatabaseProtocol::PostgreSQL).await?"
3+
expression: "execute_query(\"select NULL, NULL, NULL\".to_string(),\nDatabaseProtocol::PostgreSQL,).await?"
44
---
5-
+------+-------+-------+
6-
| NULL | NULL2 | NULL3 |
7-
+------+-------+-------+
8-
| NULL | NULL | NULL |
9-
+------+-------+-------+
5+
+------+---------+---------+
6+
| NULL | NULL__1 | NULL__2 |
7+
+------+---------+---------+
8+
| NULL | NULL | NULL |
9+
+------+---------+---------+

rust/cubesql/cubesql/src/compile/test/snapshots/cubesql__compile__test__test_introspection__dbeaver_introspection_databases.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
source: cubesql/src/compile/test/test_introspection.rs
33
expression: "execute_query(\"SELECT db.oid,db.* FROM pg_catalog.pg_database db WHERE datname = 'cubedb'\".to_string(),\nDatabaseProtocol::PostgreSQL).await?"
44
---
5-
+-------+-------+---------+--------+----------+------------+------------+---------------+--------------+--------------+---------------+--------------+------------+---------------+--------+
6-
| _oid | oid | datname | datdba | encoding | datcollate | datctype | datistemplate | datallowconn | datconnlimit | datlastsysoid | datfrozenxid | datminmxid | dattablespace | datacl |
7-
+-------+-------+---------+--------+----------+------------+------------+---------------+--------------+--------------+---------------+--------------+------------+---------------+--------+
8-
| 13757 | 13757 | cubedb | 10 | 6 | en_US.utf8 | en_US.utf8 | false | true | -1 | 13756 | 727 | 1 | 1663 | NULL |
9-
+-------+-------+---------+--------+----------+------------+------------+---------------+--------------+--------------+---------------+--------------+------------+---------------+--------+
5+
+-------+--------+---------+--------+----------+------------+------------+---------------+--------------+--------------+---------------+--------------+------------+---------------+--------+
6+
| oid | oid__1 | datname | datdba | encoding | datcollate | datctype | datistemplate | datallowconn | datconnlimit | datlastsysoid | datfrozenxid | datminmxid | dattablespace | datacl |
7+
+-------+--------+---------+--------+----------+------------+------------+---------------+--------------+--------------+---------------+--------------+------------+---------------+--------+
8+
| 13757 | 13757 | cubedb | 10 | 6 | en_US.utf8 | en_US.utf8 | false | true | -1 | 13756 | 727 | 1 | 1663 | NULL |
9+
+-------+--------+---------+--------+----------+------------+------------+---------------+--------------+--------------+---------------+--------------+------------+---------------+--------+

rust/cubesql/cubesql/src/compile/test/snapshots/cubesql__compile__test__test_introspection__dbeaver_introspection_namespaces.snap

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
source: cubesql/src/compile/test/test_introspection.rs
33
expression: "execute_query(\"SELECT n.oid,n.*,d.description FROM pg_catalog.pg_namespace n\n LEFT OUTER JOIN pg_catalog.pg_description d ON d.objoid=n.oid AND d.objsubid=0 AND d.classoid='pg_namespace'::regclass\n ORDER BY nspname\".to_string(),\nDatabaseProtocol::PostgreSQL).await?"
44
---
5-
+-------+-------+--------------------+----------+--------+------+-------------+
6-
| _oid | oid | nspname | nspowner | nspacl | xmin | description |
7-
+-------+-------+--------------------+----------+--------+------+-------------+
8-
| 13000 | 13000 | information_schema | 10 | NULL | 1 | NULL |
9-
| 11 | 11 | pg_catalog | 10 | NULL | 1 | NULL |
10-
| 2200 | 2200 | public | 10 | NULL | 1 | NULL |
11-
+-------+-------+--------------------+----------+--------+------+-------------+
5+
+-------+--------+--------------------+----------+--------+------+-------------+
6+
| oid | oid__1 | nspname | nspowner | nspacl | xmin | description |
7+
+-------+--------+--------------------+----------+--------+------+-------------+
8+
| 13000 | 13000 | information_schema | 10 | NULL | 1 | NULL |
9+
| 11 | 11 | pg_catalog | 10 | NULL | 1 | NULL |
10+
| 2200 | 2200 | public | 10 | NULL | 1 | NULL |
11+
+-------+--------+--------------------+----------+--------+------+-------------+

0 commit comments

Comments
 (0)