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

[ESQL] Plumb through ranges and warnings for the casting to double tests #99452

Merged
merged 4 commits into from
Sep 12, 2023

Conversation

not-napoleon
Copy link
Member

Add the warnings and range checking parameters to unary and binary casting to double test generators. I also moved the data type to the value supplier, which the binary case needed. That feels more right - that's what I was intending with TypedData to begin with, but our abstractions are still messy here.

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-ql (Team:QL)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/elasticsearch-esql (:Query Languages/ES|QL)

Copy link
Contributor

@alex-spies alex-spies left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -106,7 +106,7 @@ public static List<TestCaseSupplier> forUnaryCastingToDouble(
i -> expected.applyAsDouble(i),
min.intValue(),
max.intValue(),
List.of()
warnings
Copy link
Contributor

Choose a reason for hiding this comment

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

question: what are examples where we expect to have a list of warnings that we assert for all tested data types? In this PR, I only see an empty list of warnings everywhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea is that we would use the min and max bounds settings to define ranges where the function returns a value, and ranges where it returns null with a warning. I haven't added any new warnings in this PR, because I'm just trying to get the shared code part merged quickly to avoid conflicts, but you can see some in the log10 tests

Short term, meaning over the next few PRs, I'm working on #98698, which will require a lot more warnings from functions, and at the moment that's blocked on these test generators being able to accept warnings and defined ranges.

Comment on lines -144 to +160
for (DataType lhsType : EsqlDataTypes.types()) {
if (lhsType.isNumeric() == false || EsqlDataTypes.isRepresentable(lhsType) == false) {
continue;
}
for (Map.Entry<String, Supplier<Object>> lhsSupplier : RANDOM_VALUE_SUPPLIERS.get(lhsType)) {
for (DataType rhsType : EsqlDataTypes.types()) {
if (rhsType.isNumeric() == false || EsqlDataTypes.isRepresentable(rhsType) == false) {
continue;
List<TypedDataSupplier> lhsSuppliers = new ArrayList<>();
List<TypedDataSupplier> rhsSuppliers = new ArrayList<>();

lhsSuppliers.addAll(intCases(lhsMin.intValue(), lhsMax.intValue()));
lhsSuppliers.addAll(longCases(lhsMin.longValue(), lhsMax.longValue()));
lhsSuppliers.addAll(ulongCases(BigInteger.valueOf((long) Math.ceil(lhsMin)), BigInteger.valueOf((long) Math.floor(lhsMax))));
lhsSuppliers.addAll(doubleCases(lhsMin, lhsMax));

rhsSuppliers.addAll(intCases(rhsMin.intValue(), rhsMax.intValue()));
rhsSuppliers.addAll(longCases(rhsMin.longValue(), rhsMax.longValue()));
rhsSuppliers.addAll(ulongCases(BigInteger.valueOf((long) Math.ceil(rhsMin)), BigInteger.valueOf((long) Math.floor(rhsMax))));
rhsSuppliers.addAll(doubleCases(rhsMin, rhsMax));
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: I like the more explicit approach of listing all the test case suppliers, rather than filtering based on some predicates, since this is easier for me to read and quickly understand what is going to be tested.

@not-napoleon not-napoleon merged commit e26dca4 into elastic:main Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >non-issue Team:QL (Deprecated) Meta label for query languages team v8.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants