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

added IS NULL and IS NOT NULL unary operators #632

Merged
merged 2 commits into from
Sep 10, 2019
Merged

Conversation

DvirDukhan
Copy link
Collaborator

Added both IS NULL and IS NOT NULL unary operators to the arsenal. They can be used both as an expression the evaluate in RETURN clause, or as a leaf in a filter tree.
Added a test in test_arithmetic_expression.cpp
Enabled some TCK scenarios
Added a flow test for filter testing, since currently no TCK tests are enabled with those tests

char *values[6] = {"1", "1.2", "true", "false", "'string'", "[1,2,3]"};
for (int i = 0; i < 6; i++)
{
char buff[100];
Copy link
Contributor

Choose a reason for hiding this comment

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

buff[1024] just to be aligned.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done. 128

tests/unit/test_arithmetic_expression.cpp Show resolved Hide resolved
tests/unit/test_arithmetic_expression.cpp Show resolved Hide resolved
@@ -182,8 +182,8 @@ static void _buildOperatorsWhitelist(void) {
CYPHER_OP_STARTS_WITH,
CYPHER_OP_ENDS_WITH,
CYPHER_OP_CONTAINS,
// CYPHER_OP_IS_NULL,
// CYPHER_OP_IS_NOT_NULL,
CYPHER_OP_IS_NULL,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@@ -788,36 +788,10 @@ static AST_Validation _Validate_DELETE_Clauses(const AST *ast, char **reason) {
return AST_VALID;
}

// Verify that we handle the projected types. An example of an unsupported projection is:
// RETURN count(a) > 0
static AST_Validation _Validate_ReturnedTypes(const cypher_astnode_t *return_clause,
Copy link
Contributor

Choose a reason for hiding this comment

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

Great!

@@ -121,7 +126,8 @@ static FT_FilterNode *_convertFalseOperator() {
return FilterTree_CreateExpressionFilter(exp);
}

static FT_FilterNode *_convertIntegerOperator(RecordMap *record_map, const cypher_astnode_t *expr) {
static FT_FilterNode *_convertIntegerOperator(RecordMap *record_map,
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a single line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

case OP_IS_NOT_NULL:
return FilterTree_CreateExpressionFilter(AR_EXP_FromExpression(record_map, op_node));
default:
return _CreateFilterSubtree(record_map, op, arg, NULL);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you give an example of Unary operator?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

NOT
This line was the function original execution code before the switch scope

@@ -164,6 +168,14 @@ static AR_ExpNode *_AR_EXP_FromUnaryOpExpression(RecordMap *record_map,
AR_ExpNode *op = AR_EXP_NewOpNodeFromAST(OP_NOT, 1);
op->op.children[0] = _AR_EXP_FromExpression(record_map, arg);
return op;
} else if(operator == CYPHER_OP_IS_NULL) {
AR_ExpNode *op = AR_EXP_NewOpNodeFromAST(OP_IS_NULL, 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Place AR_ExpNode *op at the beginning of the function, such that it is declared once,
AR_ExpNode *op = NULL
have a single else where we assert false.
at the very end simply return op.

@swilly22 swilly22 merged commit 15d2df7 into master Sep 10, 2019
@swilly22 swilly22 deleted the is_unary_operator branch September 10, 2019 06:12
pnxguide pushed a commit to CMU-SPEED/RedisGraph that referenced this pull request Mar 22, 2023
* added IS NULL and IS NOT NULL

* changed according to PR comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants