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

Fix non-sqlcompat validation in CalciteWindowQueryTest #15086

Merged
merged 39 commits into from
Oct 11, 2023

Conversation

kgyrtkirk
Copy link
Member

  • enable back validation in useDefaultValueForNull=false
  • change validator to accept both null or the default_value in case the expectation is null
  • juggle around some stuff in CalciteWindowQueryTest
  • updated the resultsets to align with useDefaultValueForNull=true
  • change the no_grouping testcase ; as it was triggering some independent bug with the original query

This PR has:

  • been self-reviewed.

@kgyrtkirk kgyrtkirk marked this pull request as ready for review October 5, 2023 12:36
@@ -3,7 +3,7 @@ type: "operatorValidation"
sql: |
SELECT
m1,
COUNT(m1) OVER () cc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a separate test if we are changing from COUNT to SUM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...actually retaining the COUNT here was leading to a difference in the plans (and/or possibly to a bug) ; the goal in this patch was to enable the checks back - from the standpoint of this test the important thing is to run a query with at least 1 window function without any group by clauses

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add that with a failingTest annotation instead of the regular operatorValidation. That way we'll have the failing test in there so that once that bug gets address we can update it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep; that makes sense:

  • added the new test as no_grouping2.sqlTest
  • changed no_grouping.sqlTest to be failingTest

verifier.verifyResults(queryResults);
}
catch (Exception e) {
throw new RuntimeException("Exception during verification!", e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use a druid exception here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was looking around what else to use - but since this is part of the test framework and DruidException wants "Persona" and "Category" which is clearly unrelated as an Exception here means that the test most likely have crashed...

            throw DruidException.forPersona(Persona.DEVELOPER)
                .ofCategory(Category.UNCATEGORIZED)
                .build(e, "Exception during verification!");

I could probably use Assert.fail here - but the junit4 Assert.fail does not accept an Exception so it would not retain the stacktrace... junit5 has a method like that - but we don't yet have that here (...and since the test most likely crashed; and not failed using that would kinda miss its usecase)

Letting out the Exception at this point kinda leads to a shotgun surgery (although I do thing that every test method should be allowed to just let checked Exception-s out)

I was looking around what other exceptions are out there...but didn't found a better match than retaining to wrap the checked Exception into a plain RuntimeException ; to let it out.

Copy link
Member

@rohangarg rohangarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes @kgyrtkirk - mostly looks good. Left a few comments!

@soumyava
Copy link
Contributor

There is a difference in the wee bits after the decimal in the tests. Can you please take a look at it. So far things looks good to me

mismatchMessage(row, column),
(Float) expectedCell,
(Float) resultCell,
1e-5);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should make this a static variable and set it to 1e-5. Also is there any rationale behind chosing this value ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two tests were overriding the assertResultsEquals method - and they had this constant in them; to set the absolute error bound to 1e-5

I think they were making assertions on approximation results - which may be a little bit different based on the jvm or other external reasons.

I've extracted it into a constant

mismatchMessage(row, column),
(Double) expectedCell,
(Double) resultCell,
1e-5);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

if (colIndex > 0) {
sb.append(", ");
}
if (col == null) {

Check notice

Code scanning / CodeQL

Chain of 'instanceof' tests Note test

This if block performs a chain of 6 type tests - consider alternatives, e.g. polymorphism or the visitor pattern.
@soumyava
Copy link
Contributor

Once the CI is all greens I'll merge this

Copy link
Member

@rohangarg rohangarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@soumyava soumyava merged commit ae88f2c into apache:master Oct 11, 2023
81 checks passed
pranavbhole pushed a commit to pranavbhole/druid that referenced this pull request Oct 12, 2023
* fixes

* check for latest rewrite place

* Revert "check for latest rewrite place"

This reverts commit 5cf1e2c.

* some stuff

(cherry picked from commit ab346d4373ea888eb8ef6115e018e7fb0d27407f)

* update test output

* updates to test ouptuts

* some stuff

* move validator

* cleanup

* fix

* change test slightly

* add apidoc cleanup warnings

* cleanup/etc

* instead of telling the story; add a fail with some reason whats the issue

* lead-lag fix

* add test

* remove unnecessary throw

* druidexception-trial

* Revert "druidexception-trial"

This reverts commit 8fa0664.

* undo changes to no_grouping; add no_grouping2

* add missing assert on resultcount

* rename method; update

* introduce enum/etc

* make resultmatchmode accessible from TestBuilder#expectedResults

* fix dump results to use log

* fix

* handle null correctly

* disable feature type based things for MSQ

* fix varianssqlaggtest

* use eps in other test

* fix intellij error

* add final

* addrss review

* update test/string/etc

* write concat in 3 lines :D
@pranavbhole pranavbhole mentioned this pull request Oct 12, 2023
10 tasks
LakshSingla pushed a commit to LakshSingla/druid that referenced this pull request Oct 14, 2023
* fixes

* check for latest rewrite place

* Revert "check for latest rewrite place"

This reverts commit 5cf1e2c.

* some stuff

(cherry picked from commit ab346d4373ea888eb8ef6115e018e7fb0d27407f)

* update test output

* updates to test ouptuts

* some stuff

* move validator

* cleanup

* fix

* change test slightly

* add apidoc cleanup warnings

* cleanup/etc

* instead of telling the story; add a fail with some reason whats the issue

* lead-lag fix

* add test

* remove unnecessary throw

* druidexception-trial

* Revert "druidexception-trial"

This reverts commit 8fa0664.

* undo changes to no_grouping; add no_grouping2

* add missing assert on resultcount

* rename method; update

* introduce enum/etc

* make resultmatchmode accessible from TestBuilder#expectedResults

* fix dump results to use log

* fix

* handle null correctly

* disable feature type based things for MSQ

* fix varianssqlaggtest

* use eps in other test

* fix intellij error

* add final

* addrss review

* update test/string/etc

* write concat in 3 lines :D
cryptoe pushed a commit that referenced this pull request Oct 16, 2023
ektravel pushed a commit to ektravel/druid that referenced this pull request Oct 16, 2023
* fixes

* check for latest rewrite place

* Revert "check for latest rewrite place"

This reverts commit 5cf1e2c.

* some stuff

(cherry picked from commit ab346d4373ea888eb8ef6115e018e7fb0d27407f)

* update test output

* updates to test ouptuts

* some stuff

* move validator

* cleanup

* fix

* change test slightly

* add apidoc cleanup warnings

* cleanup/etc

* instead of telling the story; add a fail with some reason whats the issue

* lead-lag fix

* add test

* remove unnecessary throw

* druidexception-trial

* Revert "druidexception-trial"

This reverts commit 8fa0664.

* undo changes to no_grouping; add no_grouping2

* add missing assert on resultcount

* rename method; update

* introduce enum/etc

* make resultmatchmode accessible from TestBuilder#expectedResults

* fix dump results to use log

* fix

* handle null correctly

* disable feature type based things for MSQ

* fix varianssqlaggtest

* use eps in other test

* fix intellij error

* add final

* addrss review

* update test/string/etc

* write concat in 3 lines :D
CaseyPan pushed a commit to CaseyPan/druid that referenced this pull request Nov 17, 2023
* fixes

* check for latest rewrite place

* Revert "check for latest rewrite place"

This reverts commit 5cf1e2c.

* some stuff

(cherry picked from commit ab346d4373ea888eb8ef6115e018e7fb0d27407f)

* update test output

* updates to test ouptuts

* some stuff

* move validator

* cleanup

* fix

* change test slightly

* add apidoc cleanup warnings

* cleanup/etc

* instead of telling the story; add a fail with some reason whats the issue

* lead-lag fix

* add test

* remove unnecessary throw

* druidexception-trial

* Revert "druidexception-trial"

This reverts commit 8fa0664.

* undo changes to no_grouping; add no_grouping2

* add missing assert on resultcount

* rename method; update

* introduce enum/etc

* make resultmatchmode accessible from TestBuilder#expectedResults

* fix dump results to use log

* fix

* handle null correctly

* disable feature type based things for MSQ

* fix varianssqlaggtest

* use eps in other test

* fix intellij error

* add final

* addrss review

* update test/string/etc

* write concat in 3 lines :D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants