Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
NULLIF
standard SQL function (exists in Postgres, MySQL, SQL Server, Calcite etc.)NULLIF
expressions are rewritten to the equivalentCASE WHEN
expressions by Calcite by default (https://github.com/apache/calcite/blob/7ce986fbc635722f3390b81dcdfe24bbd82ddb3d/core/src/main/java/org/apache/calcite/sql/fun/SqlNullifFunction.java#L56-L72). So, for the multi-stage engine, simply adding theSqlStdOperatorTable.NULLIF
entry to Pinot's operator table would be enough to get this functionality. However, we're also adding the scalar function implementation here so that the same function can be used in the single-stage engine as well.Edit: this is actually fixing a regression for the multi-stage query engine. Prior to #13573, the
NULLIF
function worked fine (only on the multi-stage engine, and not on the single-stage engine). Before that refactor, Pinot's operator table extended Calcite'sSqlStdOperatorTable
which has theSqlNullifFunction
defined. Since it automatically rewrites calls to equivalent calls toCASE WHEN
, this worked fine even though Pinot didn't have an actual implementation forNULLIF
. However, the above linked PR updated Pinot's operator table to no longer extend Calcite'sSqlStdOperatorTable
, and instead manually register all the operators that Pinot actually has support for. Since Pinot didn't have an actual implementation forNULLIF
, it was probably missed. This PR fixes the regression and also adds support for the function in the single-stage engine.