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

Fix the comparisions involving EMPTY. #5433

Merged
merged 7 commits into from
Mar 27, 2023

Conversation

xtcyclist
Copy link
Contributor

@xtcyclist xtcyclist commented Mar 23, 2023

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

Fix #5432

Description:

EMPTY == EMPTY shall not return true.

How do you solve it?

EMPTY == (x), return value: 
==      EMPTY		NULL		Others
EMPTY	NULL		FALSE		FALSE

EMPTY < (x), return value:
<	EMPTY		NULL		Others
EMPTY	NULL		NULL		NULL

Tried to return null in all cases if an EMPTY value is involved in comparisions. But some cases have relied on it to return FALSE. Thus, I applied the above truth table for == and <.

Special notes for your reviewer, ex. impact of this fix, design document, etc:

I think we currently haven't explained any truth table involving EMTPY or EMTPY-like values in our documents. Right? Not sure.

Simlar to NULL (https://docs.nebula-graph.com.cn/3.4.0/3.ngql-guide/3.data-types/5.null/), we may need to explain the behaviours involving EMTPY or EMTPY-like values.

For example, queries like

MATCH (v:player)-[]-(v2) WHERE v.player.nnnnnnnnnnnnnn == v2.player.nnnnnnnnnnnnnn RETURN *

would return nothing, as the property nnnnnnnnnnnnnn does not exist (EMPTY) and EMTPY == EMPTY = NULL.

Checklist:

Tests:

  • Unit test(positive and negative cases)
  • Function test
  • Performance test
  • TCK

Affects:

  • Documentation affected (Please add the label if documentation needs to be modified.)
  • Incompatibility (If it breaks the compatibility, please describe it and add the label.)
  • If it's needed to cherry-pick (If cherry-pick to some branches is required, please label the destination version(s).)
  • Performance impacted: Consumes more CPU/Memory

Release notes:

Please confirm whether to be reflected in release notes and how to describe:

ex. Fixed the bug .....

@xtcyclist xtcyclist added ready-for-testing PR: ready for the CI test ready for review labels Mar 23, 2023
@xtcyclist xtcyclist changed the title Fix empty equal Fix the comparisions involving EMPTY. Mar 24, 2023
Comment on lines 1874 to 1880
if (empty() || v.empty()) {
if (!empty() || !v.empty()) {
return false;
} else {
return Value::kNullValue;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This writing style is a bit strange. Could you replace it with the following?

if (empty() && v.empty()) return Value::kNullValue;
if (empty() || v.empty()) return false;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would leave two extra conditions for normal non-empty cases. Changed to another form instead.

@@ -20,6 +20,9 @@ folly::Future<Status> LoopExecutor::execute() {
QueryExpressionContext ctx(ectx_);

auto value = expr->eval(ctx);
if (value.isNull()) {
value = Value(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

it seems that u should assign false to the value. maybe you need not to check the result of value, just delete the following DCHECK.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

Copy link
Contributor Author

@xtcyclist xtcyclist Mar 27, 2023

Choose a reason for hiding this comment

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

It won't pass the tck. Reverted for now.

It is an expression containing at least one EMPTY here. This place is expecting a TRUE value, if nothing more is introduced to change this part.

@Sophie-Xie Sophie-Xie added the doc affected PR: improvements or additions to documentation label Mar 27, 2023
@Sophie-Xie Sophie-Xie merged commit f4d5b42 into vesoft-inc:master Mar 27, 2023
@abby-cyber
Copy link
Contributor

abby-cyber commented Apr 11, 2023

vesoft-inc/nebula-docs-cn#2716
After discussion, it has been decided not to add the relevant description to the documentation, as the comparison logic for "empty" still requires further consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc affected PR: improvements or additions to documentation ready for review ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Graph return incorrect query result on null value filter
5 participants