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

SQL: be lenient for tests involving comparison to H2 but strict for csv spec tests #36498

Merged
merged 5 commits into from Dec 13, 2018

Conversation

astefan
Copy link
Contributor

@astefan astefan commented Dec 11, 2018

This PR addresses #36483 by adding a new boolean lenient parameter for tests to round or not the floating point numbers in tests. Relates to https://github.com/elastic/elasticsearch/pull/36431/files#r240219710.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@astefan
Copy link
Contributor Author

astefan commented Dec 11, 2018

run the gradle build tests 2

* For example in a non-lenient, strict case a comparison between an int and a tinyint would fail, with lenientDataType it will succeed
* as long as the actual value is the same.
* Also, has the option of treating the numeric results for floating point numbers in a leninent way, if chosen to. Usually,
* we would want lening treatment for floating point numbers in sql-spec tests where the comparison is being made with H2.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: lening

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Should be lenient. Thanks.

Copy link
Contributor

@matriv matriv left a comment

Choose a reason for hiding this comment

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

LGTM. Left 2 wording comments.

protected void assertResults(ResultSet expected, ResultSet elastic) throws SQLException {
/*
* Asserts the numeric results for floating point numbers in a leninent way, if chosen to. Usually,
* we would want lening treatment for floating point numbers in sql-spec tests where the comparison is being made with H2.
Copy link
Contributor

Choose a reason for hiding this comment

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

is lening a correct word?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should be lenient :-). Will change.

Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

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

LGTM however the previous assertion method signature should have been kept to use as a default - that would simplify its usage and eliminate some of the changes to tests.

*/
public static void assertResultSets(ResultSet expected, ResultSet actual, Logger logger, boolean lenient) throws SQLException {
public static void assertResultSets(ResultSet expected, ResultSet actual, Logger logger, boolean lenientDataType,
Copy link
Member

Choose a reason for hiding this comment

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

Keep the previous method with reduced parameters and delegate to the new one with a default value. This would minimize the amount of changes since the leniency needs to be disabled/enabled just in some cases .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @costin. I agree with the fact that there will be more changes to test methods, but this approach is intentional, so that the user of this method becomes aware of the leniency regarding floating point numbers, something that wasn't obvious before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

@@ -31,7 +31,7 @@ public void testGetProcedures() throws Exception {
assertResultSets(expected, es.getMetaData().getProcedures(
randomBoolean() ? null : randomAlphaOfLength(5),
randomBoolean() ? null : randomAlphaOfLength(5),
randomBoolean() ? null : randomAlphaOfLength(5)));
randomBoolean() ? null : randomAlphaOfLength(5)), true);
Copy link
Member

Choose a reason for hiding this comment

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

See the comment below - the short assertResultSets signature should be kept so then test would only have to specify when they don't want to be lenient as oppose to all the time.

@astefan astefan merged commit 1270d85 into elastic:master Dec 13, 2018
astefan added a commit to astefan/elasticsearch that referenced this pull request Dec 13, 2018
…sv spec tests (elastic#36498)

* Add a lenient parameter for floating point numbers and mark csv-spec
tests as not lenient vs. sql-spec tests to be lenient.

(cherry picked from commit 1270d85)
astefan added a commit that referenced this pull request Dec 13, 2018
…sv spec tests (#36498)

* Add a lenient parameter for floating point numbers and mark csv-spec
tests as not lenient vs. sql-spec tests to be lenient.

(cherry picked from commit 1270d85)
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.

None yet

5 participants