Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
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

CTE not working as expected via SQL-API #8413

Open
ZiggiZagga opened this issue Jul 1, 2024 · 1 comment
Open

CTE not working as expected via SQL-API #8413

ZiggiZagga opened this issue Jul 1, 2024 · 1 comment
Assignees
Labels
api:sql Issues related to SQL API bug Something isn't working

Comments

@ZiggiZagga
Copy link

ZiggiZagga commented Jul 1, 2024

Failed SQL

Config:

cube('orders', {
  sql_table: 'orders',
});

Query via SQL-API

WITH test_filter AS(
SELECT 'order-1' as filter_1
)
SELECT * FROM orders WHERE order_id IN(SELECT filter_1 FROM test_filter)

Error

Error during rewrite: Error during planning: No field named '__subquery-0.filter_1'. Valid fields are '..'.. Please check logs for additional information.

Version:
[e.g. 0.4.5]

Additional context
Somehow using CTEs with the SQL-API, is not working as expected, for example when used in IN Condition or as LEFT JOIN

@paveltiunov paveltiunov added bug Something isn't working api:sql Issues related to SQL API labels Jul 5, 2024
@igorlukanin
Copy link
Member

I was able to reproduce this with the following data model on v0.36.4 and the query pushdown in the SQL API on:

cubes:
  - name: orders
    sql: SELECT 1 AS id

    dimensions:
      - name: id
        sql: id
        type: number

Query:

WITH test_filter AS (
  SELECT 123 as filter_1
)
SELECT *
FROM orders
WHERE id IN (
  SELECT filter_1 FROM test_filter
);

I believe this is because IN (subquery) is still to be implemented in the SQL API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api:sql Issues related to SQL API bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants