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

Corrected Strict NON NULL return type checks #16279

Merged
merged 5 commits into from
Apr 18, 2024

Conversation

sreemanamala
Copy link
Contributor

@sreemanamala sreemanamala commented Apr 13, 2024

Description

aims to fix strict type compare issue (Boolean vs Boolean not null) in TIME_IN_INTERVAL


Key changed/added classes in this PR
  • TimeInIntervalConvertletFactory.java
  • ContainsOperatorConversion.java
  • RegexpLikeOperatorConversion.java
  • SubstringOperatorConversion.java

This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@sreemanamala sreemanamala changed the title Corrected Strict BOOLEAN return in TIME_IN_INTERVAL Corrected Strict NON NULL return type checks Apr 15, 2024
@@ -45,7 +46,7 @@ public class SubstringOperatorConversion implements SqlOperatorConversion
.operatorBuilder("SUBSTRING")
.operandTypes(SqlTypeFamily.CHARACTER, SqlTypeFamily.INTEGER, SqlTypeFamily.INTEGER)
.functionCategory(SqlFunctionCategory.STRING)
.returnTypeInference(ReturnTypes.ARG0)
.returnTypeInference(ReturnTypes.ARG0.andThen(SqlTypeTransforms.FORCE_NULLABLE))
Copy link
Member

Choose a reason for hiding this comment

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

afaik these are appied during calcite planning ; I see some tests in ExpressionTest ; aren't those only excercise the native layer?

@@ -270,6 +270,16 @@ public void testSubstring()
makeExpression("substring(\"spacey\", (\"p\" - 1), \"p\")"),
"hey"
);
testHelper.testExpressionString(
Copy link
Member

Choose a reason for hiding this comment

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

I've unpatched all non-test changes - and these cases still pass...did I miss something?

Copy link
Contributor Author

@sreemanamala sreemanamala Apr 17, 2024

Choose a reason for hiding this comment

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

I guess these tests here are only running on the native layer. And the issue which we face is more of coming in the calcite layer. Let me change the tests. Thanks for pointing these.

Moreover
select CONTAINS_STRING(null, 'a') -- gives INVALID use of null
select CONTAINS_STRING(dim3, 'a') from numFoo where dim3 is null -- fails the strict check

Copy link
Member

@kgyrtkirk kgyrtkirk left a comment

Choose a reason for hiding this comment

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

some minor test related notes

@kgyrtkirk kgyrtkirk merged commit 960a674 into apache:master Apr 18, 2024
85 checks passed
@sreemanamala sreemanamala deleted the time-parse branch April 18, 2024 13:33
@adarshsanjeev adarshsanjeev added this to the 30.0.0 milestone May 6, 2024
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.

3 participants