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

[BUG]While I was using cnosdb, I found a problem with SQL execution failing #1033

Closed
lutengda opened this issue Mar 20, 2023 · 1 comment · Fixed by #1036
Closed

[BUG]While I was using cnosdb, I found a problem with SQL execution failing #1033

lutengda opened this issue Mar 20, 2023 · 1 comment · Fixed by #1036
Assignees
Labels
type/bug Something isn't working

Comments

@lutengda
Copy link
Collaborator

Describe the bug
I tried to execute some SQL using cnosdb.When I execute the following sql, the execution fails, I don't find the syntax error, the error message is sum(...) ... Not a "field name". Here's the sql I executed:
select driver, date_trunc('day',time) as c_date, time, load_capacity, fuel_capacity, sum(case when elevation<50 then elevation else 0 end) over (partition by driver) /sum(elevation) over (partition by driver)/2 from readings where driver in ('Seth','Albert') and time>='2017-01-01T00:00:00' and time<='2017-01-02T00:00:00';
version:4e7cfef
This is the error message about the sql:
422 Unprocessable Entity, details: {\"error_code\":\"010001\",\"error_message\":\"Datafusion: type_coercion\\ncaused by\\nInternal error: Optimizer rule 'type_coercion' failed due to unexpected error: Schema error: No field named 'SUM(CASE WHEN readings.elevation < Int64(50) THEN readings.elevation ELSE Int64(0) END) PARTITION BY [readings.driver] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING'. Valid fields are 'readings'.'time', 'readings'.'driver', 'readings'.'elevation', 'readings'.'load_capacity', 'readings'.'fuel_capacity', 'SUM(readings.elevation) PARTITION BY [readings.driver] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING'.. This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker\"}

To Reproduce

Expected behavior
The above SQL should execute normally

Additional context

@ZuoTiJia
Copy link
Contributor

It seems that during the expression conversion process, the expression changes and there is no alias, so the projection cannot find the corresponding column name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants