-
Notifications
You must be signed in to change notification settings - Fork 25.7k
SQL: Fix querying of indices without columns #74312
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
Changes from all commits
f78559b
0e85eae
1928df4
86c43c9
868edd7
46f77b9
19c54f5
4d1f92c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
|
|
||
| // the following queries all return no rows in H2 | ||
|
|
||
| selectConstAggregationWithGroupBy | ||
| SELECT 1 a, COUNT(*) b, MAX(1) c FROM empty_mapping GROUP BY a; | ||
|
|
||
| a:i | b:l | c:i | ||
| ---------------+---------------+--------------- | ||
| 1 |2 |1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this COUNT 2?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's two empty docs in the index.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, missed that.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also initially split the request body in two lines to make it more explicit like this: but spotless didn't like it and I had to squash it into one line... |
||
| ; | ||
|
|
||
| subselectWithConst | ||
| SELECT 1, * FROM (SELECT * FROM empty_mapping) s; | ||
|
|
||
| 1:i | ||
| --------------- | ||
| 1 | ||
| 1 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Second |
||
| ; | ||
|
|
||
| subselectWithInnerConst | ||
| SELECT * FROM (SELECT 1, * FROM empty_mapping) s; | ||
|
|
||
| 1:i | ||
| --------------- | ||
| 1 | ||
| 1 | ||
| ; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| selectStar | ||
| SELECT * FROM empty_mapping; | ||
| selectStarWithFilter | ||
| SELECT * FROM empty_mapping WHERE 2 > 1; | ||
| selectStarWithFilterAndLimit | ||
| SELECT * FROM empty_mapping WHERE 1 > 2 LIMIT 10; | ||
|
|
||
| selectCount | ||
| SELECT COUNT(*) FROM empty_mapping; | ||
| // awaits fix: https://github.com/elastic/elasticsearch/issues/74311 | ||
| // selectCountWithWhere | ||
| // SELECT COUNT(*) FROM empty_mapping WHERE 1 + 1 = 3; | ||
|
|
||
| selectConst | ||
| SELECT 1, 2, 3 FROM empty_mapping; | ||
| selectConstAggregation | ||
| SELECT MAX(1), SUM(2) FROM empty_mapping; | ||
|
|
||
| // fails in H2 with a syntax error but cannot be tested in CSV spec because datasets without columns cannot be parsed | ||
| // awaits fix: https://github.com/elastic/elasticsearch/issues/39895 (latest H2 version can run the query) | ||
| // subselect | ||
| // SELECT * FROM (SELECT * FROM empty_mapping) s; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| DROP TABLE IF EXISTS "empty_mapping"; | ||
| CREATE TABLE "empty_mapping" (); | ||
|
|
||
| INSERT INTO "empty_mapping" DEFAULT VALUES; | ||
| INSERT INTO "empty_mapping" DEFAULT VALUES; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Creating an empty index is not enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's helpful to also check whether the behavior is correct with documents in an index with an empty mapping. That's why I'm indexing two empty documents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Thanks.