-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Closed
Copy link
Labels
api:sqlIssues related to SQL APIIssues related to SQL APIbugLEGACY. Use the Bug issue type insteadLEGACY. Use the Bug issue type instead
Description
Describe the bug
SQL API is unable to handle where clauses including the condition column in (null). Instead it throws an "Unexpected panic" error.
To Reproduce
Using SQL API, query a column from any Cube using where (<column> is null or <column> in (null) and (1<>1)) as a filter. Should see an error (details below).
Alternatively, a minimal reprex with a fresh installation of Postgres and Cube:
- Create a fresh Postgres and Cube setup with Docker
- Add a table to Postgres and insert some data
CREATE TABLE tbl (
id serial PRIMARY KEY,
label text
);
INSERT INTO tbl(label) VALUES ('one'), ('two'), (NULL), ('four');- Query the database directly:
select * from tbl where (label is null or label in (null) and (1<>1)). Should get row 3 returned without error. - Create a Cube data model for
tbl(schema below) - Query the cube using the same SQL syntax
- See error
Error during rewrite: Unexpected panic. Reason: Unsupported filter scalar: NULL. Please check logs for additional information.
- Logs show
thread 'tokio-runtime-worker' panicked at /__w/cube/cube/rust/cubesql/cubesql/src/compile/rewrite/rules/filters.rs:3573:18:
Unsupported filter scalar: NULL
SQL API Error: c4df0a8c-46b8-470c-a92f-9c78328ebeca-span-1 (6ms)
--
{
"sql": "select * from tbl where (label is null or label in (null) and (1<>1))"
}
--
{
"securityContext": {},
"appName": "NULL",
"protocol": "postgres",
"apiType": "sql"
}
Error during rewrite: Unexpected panic. Reason: Unsupported filter scalar: NULL. Please check logs for additional information.
Cube SQL Error: undefined
--
"SELECT * FROM tbl WHERE (label IS NULL OR label IN (NULL) AND (1 <> 1))"
--
{
"protocol": "postgres",
"apiType": "sql",
"appName": "NULL",
"sanitizedQuery": "SELECT * FROM tbl WHERE (label IS NULL OR label IN (NULL) AND (1 <> 1))"
}
Error during rewrite: Unexpected panic. Reason: Unsupported filter scalar: NULL. Please check logs for additional information.
Expected behavior
Cube SQL API query should return the same result as direct query to Postgres
Minimally reproducible Cube Schema
cubes:
- name: tbl
sql_table: public.tbl
data_source: default
dimensions:
- name: id
sql: id
type: number
primary_key: true
- name: label
sql: label
type: stringVersion:
Cube: 1.1.18
Postgres: 16
Additional Context
- Superset native filters generate this SQL when attempting to filter for a null value
- As it's generated I'm not able to use
where label is nullwithout theor label in (null) and (1<>1)as a workaround
Metadata
Metadata
Assignees
Labels
api:sqlIssues related to SQL APIIssues related to SQL APIbugLEGACY. Use the Bug issue type insteadLEGACY. Use the Bug issue type instead