Skip to content

Corrected Strict NON NULL return type checks#16279

Merged
kgyrtkirk merged 5 commits intoapache:masterfrom
sreemanamala:time-parse
Apr 18, 2024
Merged

Corrected Strict NON NULL return type checks#16279
kgyrtkirk merged 5 commits intoapache:masterfrom
sreemanamala:time-parse

Conversation

@sreemanamala
Copy link
Copy Markdown
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
Comment thread processing/src/main/java/org/apache/druid/math/expr/Function.java
.operandTypes(SqlTypeFamily.CHARACTER, SqlTypeFamily.INTEGER, SqlTypeFamily.INTEGER)
.functionCategory(SqlFunctionCategory.STRING)
.returnTypeInference(ReturnTypes.ARG0)
.returnTypeInference(ReturnTypes.ARG0.andThen(SqlTypeTransforms.FORCE_NULLABLE))
Copy link
Copy Markdown
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?

makeExpression("substring(\"spacey\", (\"p\" - 1), \"p\")"),
"hey"
);
testHelper.testExpressionString(
Copy link
Copy Markdown
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
Copy Markdown
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

Comment thread sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java Outdated
Comment thread sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java Outdated
Comment thread sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java Outdated
Copy link
Copy Markdown
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
@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.

4 participants