Skip to content

[BUG] A query with a subquery fails #347

Closed

Description

@Yury-Fridlyand

Describe the bug
In the one of the Power BI usage cases, OS SQL returned an empty response.
image
The generated query was:

select `bool2`,`C1`
from (
	select `bool2`, sum(`int2`) as `C1`
	from (
		select *
		from `calcs`
		where `str1` = "BINDING SUPPLIES"
	) as `ITBL`
	group by `bool2`
) as `ITBL`
where not `C1` is null limit 1000001

Once I simplified it:

select `bool2`,`C1`
from (
	select `bool2`, sum(`int2`) as `C1`
	from `calcs`
	where `str1` = \"BINDING SUPPLIES\"
	group by `bool2`
) as `ITBL`
where not `C1` is null limit 1000001

Once I removed the WHERE clause, it returned a valid response.
No errors were reported in the server log.

To Reproduce
Steps to reproduce the behavior:
curl -k -XPOST http://localhost:9200/_plugins/_sql -H 'Content-Type: application/json' -d '{"query" : "select `bool2`, `C1` from (select `bool2`, sum(`int2`) as `C1` from `calcs` where `str1` = \"BINDING SUPPLIES\" group by `bool2`) as `ITBL` where not `C1` is null limit 1000001"}'

Expected behavior
As a reference, MySQL returns a non-empty result set:

mysql> select `bool2`,`C1`from (select `bool2`,sum(`int2`) as `C1`from (select * from `Calcs`where `str1` = "BINDING SUPPLIES") as `ITBL`group by `bool2`) as `ITBL` where not `C1` is null limit 1000001;
+-------+------+
| bool2 | C1   |
+-------+------+
|     0 |    9 |
+-------+------+
1 row in set (0.00 sec)

A Power BI measure got using Import mode instead of DirectQuery:
image

Host/Environment (please complete the following information):

  • Version: 1.2.0 hosted in a docker image

Additional context
Data set was used from TDVT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugpowerBIv2.5.0

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions