pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/apache/calcite/pull/4837

om/assets/global-52276e82f63bb403.css" /> [CALCITE-7438] Do not rewrite NULLIF to a CASE expression by cjj2010 · Pull Request #4837 · apache/calcite · GitHub
Skip to content

[CALCITE-7438] Do not rewrite NULLIF to a CASE expression#4837

Open
cjj2010 wants to merge 5 commits intoapache:mainfrom
cjj2010:CALCITE-7438
Open

[CALCITE-7438] Do not rewrite NULLIF to a CASE expression#4837
cjj2010 wants to merge 5 commits intoapache:mainfrom
cjj2010:CALCITE-7438

Conversation

@cjj2010
Copy link

@cjj2010 cjj2010 commented Mar 15, 2026

Copy link
Member

@xiedeyantu xiedeyantu left a comment

Choose a reason for hiding this comment

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

LGTM!
I only left some comments on coding style.

.ok(expected2);
}

@Test void testNullIfAgg() {
Copy link
Member

Choose a reason for hiding this comment

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

Could these cases be combined into one? Just like:

SELECT NULLIF(COUNT(brand_name),1), NULLIF(COUNT(brand_name) + 1,1), NULLIF(cases_per_pallet + 1,1) FROM product;

Also you need to add a jira link in javadoc.

Copy link
Author

Choose a reason for hiding this comment

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

done

/**
* The <code>NULLIF</code> function.
*/
public class SqlNullifFunction extends SqlFunction {
Copy link
Member

Choose a reason for hiding this comment

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

This Function should to be marked as deprecated using @deprecated.

Copy link
Author

Choose a reason for hiding this comment

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

done, thanks

Copy link
Contributor

Choose a reason for hiding this comment

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

@cjj2010 the PR was veto-ed by @julianhyde
You have to make an argument about why this is needed.
Perhaps the JIRA case is the right place for this discussion.

Copy link
Member

@xiedeyantu xiedeyantu Mar 16, 2026

Choose a reason for hiding this comment

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

Yes, we need to back to JIRA to continue the discussion. Perhaps you need to answer Julian's question first.

Copy link
Author

Choose a reason for hiding this comment

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

Okay, I have already replied to Jira. From the current situation, Calcite will directly convert nullif to casewhen by default. I think there are two solutions at present: 1. If there is an aggregation function, it will not be converted to casewhen; 2. Keep nullif in all cases and add optimization rules, such as NULLIF(x + 1, 5), we use common subexpression elimination so that the argument "x + 1" is only evaluated once @mihaibudiu @xiedeyantu


defineMethod(AGE, BuiltInMethod.AGE.method, NullPolicy.STRICT);

define(NULLIF, new NullifImplementor());
Copy link
Member

Choose a reason for hiding this comment

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

Please move this definition below IS_DISTINCT_FROM?

Copy link
Author

Choose a reason for hiding this comment

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

done, thanks

@xiedeyantu
Copy link
Member

Some ideas, but not related to this PR. Perhaps we can consider simplifying NULLIF in some specific cases. Because currently NULLIF can be simplified to CASE WHEN, I'm not sure whether it can be simplified or not.

@julianhyde
Copy link
Contributor

-1

The commits look fine, but per the Jira discussion, the current behavior is fine and there’s no need to fix it.

@sonarqubecloud
Copy link

Copy link
Member

@xiedeyantu xiedeyantu left a comment

Choose a reason for hiding this comment

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

I feel that you didn't seem to directly answer Julian's question; he likely hasn't approved your changes yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy