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

SOLR-16646: New function query operator isnan to verify if value is NaN #1331

Merged
merged 9 commits into from Feb 6, 2023

Conversation

gabrielmagno
Copy link
Contributor

@gabrielmagno gabrielmagno commented Feb 3, 2023

https://issues.apache.org/jira/browse/SOLR-16646

Description

We created a new function query operator called isnan, that checks rather a value is a float NaN (not a number).

Solution

A new Value Source parser called isnan was added. It will get the input value, treat it as a float and use the Java builtin function Float.isNaN to verify if the value is NaN.

Tests

We added a new assert in the testBooleanFunctions test that verifies four cases of NaN values:
 - isnan(12.3456) should be false;
 - isnan(0) should be false;
 - isnan(div(0,0)) should be true;
 - isnan(sqrt(-1)) should be true.

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

@gabrielmagno
Copy link
Contributor Author

I tried running ./gradlew check, but I got an error that I'm not sure if it is related to my changes or is a bug from upstream master:

* What went wrong:
Execution failed for task ':solr:core:validateSourcePatterns'.
> Found source pattern violations (skip with -Pvalidation.sourcePatterns.failOnError=false):
  UTF-8 byte order mark
  tabs instead spaces\

@risdenk
Copy link
Contributor

risdenk commented Feb 3, 2023

@gabrielmagno looks like its related to your change. ./gradlew tidy may fix it. I see in [solr/core/src/java/org/apache/solr/search/ValueSourceParser.java](https://github.com/apache/solr/pull/1331/files#diff-d13890bf504c239f648ea33d439b4e5d489594683190fd5ab2fc6ce68313dd0c) that indentation is off compared to the other examples above and below. I'm guessing your editor has tabs instead of spaces.

@gabrielmagno
Copy link
Contributor Author

@gabrielmagno looks like its related to your change. ./gradlew tidy may fix it. I see in [solr/core/src/java/org/apache/solr/search/ValueSourceParser.java](https://github.com/apache/solr/pull/1331/files#diff-d13890bf504c239f648ea33d439b4e5d489594683190fd5ab2fc6ce68313dd0c) that indentation is off compared to the other examples above and below. I'm guessing your editor has tabs instead of spaces.

Thank you @risdenk , I ran ./gradlew tidy and it is fixed.

There is now a problem on QueryEqualityTest. I will work on that.

@gabrielmagno
Copy link
Contributor Author

Fixed. gradlew check seems to be running fine now!

Copy link
Contributor

@risdenk risdenk left a comment

Choose a reason for hiding this comment

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

Looks good - only thing needed is solr/CHANGES.txt entry

@risdenk risdenk changed the title SOLR-16646: New function query operator to verify if value is NaN (isnan) SOLR-16646: New function query operator isnan to verify if value is NaN Feb 6, 2023
@risdenk risdenk merged commit 04ea6df into apache:main Feb 6, 2023
@risdenk
Copy link
Contributor

risdenk commented Feb 6, 2023

Thanks @gabrielmagno

risdenk pushed a commit that referenced this pull request Feb 6, 2023
…aN (#1331)

Co-authored-by: Mikhail Khludnev <mkhludnev@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants