Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
210360228
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2021
210360228
Commits
e89c8a28
Commit
e89c8a28
authored
Oct 16, 2019
by
CPWstatic
Committed by
dutor
Oct 16, 2019
Browse files
Options
Downloads
Patches
Plain Diff
udf function is_in() (#1096)
* Support comparison function in(). * Update.
parent
af7d7bf5
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/executor/test/GoTest.cpp
+64
-0
64 additions, 0 deletions
src/executor/test/GoTest.cpp
src/executor/test/YieldTest.cpp
+19
-0
19 additions, 0 deletions
src/executor/test/YieldTest.cpp
with
83 additions
and
0 deletions
src/executor/test/GoTest.cpp
+
64
−
0
View file @
e89c8a28
...
@@ -626,5 +626,69 @@ TEST_F(GoTest, NotExistTagProp) {
...
@@ -626,5 +626,69 @@ TEST_F(GoTest, NotExistTagProp) {
ASSERT_NE
(
cpp2
::
ErrorCode
::
SUCCEEDED
,
code
);
ASSERT_NE
(
cpp2
::
ErrorCode
::
SUCCEEDED
,
code
);
}
}
}
}
TEST_F
(
GoTest
,
is_inCall
)
{
{
cpp2
::
ExecutionResponse
resp
;
auto
&
player
=
players_
[
"Boris Diaw"
];
auto
*
fmt
=
"GO FROM %ld OVER serve "
"WHERE udf_is_in($$.team.name,
\"
Hawks
\"
,
\"
Suns
\"
) "
"YIELD $^.player.name, serve.start_year, serve.end_year, $$.team.name"
;
auto
query
=
folly
::
stringPrintf
(
fmt
,
player
.
vid
());
auto
code
=
client_
->
execute
(
query
,
resp
);
ASSERT_EQ
(
cpp2
::
ErrorCode
::
SUCCEEDED
,
code
)
<<
*
resp
.
get_error_msg
();
std
::
vector
<
std
::
string
>
expectedColNames
{
{
"$^.player.name"
},
{
"serve.start_year"
},
{
"serve.end_year"
},
{
"$$.team.name"
}
};
ASSERT_TRUE
(
verifyColNames
(
resp
,
expectedColNames
));
std
::
vector
<
std
::
tuple
<
std
::
string
,
int64_t
,
int64_t
,
std
::
string
>>
expected
=
{
{
player
.
name
(),
2003
,
2005
,
"Hawks"
},
{
player
.
name
(),
2005
,
2008
,
"Suns"
},
};
ASSERT_TRUE
(
verifyResult
(
resp
,
expected
));
}
{
cpp2
::
ExecutionResponse
resp
;
auto
*
fmt
=
"GO FROM %ld OVER like YIELD like._dst AS id"
"| GO FROM $-.id OVER serve WHERE udf_is_in($-.id, %ld, 123)"
;
auto
query
=
folly
::
stringPrintf
(
fmt
,
players_
[
"Tim Duncan"
].
vid
(),
players_
[
"Tony Parker"
].
vid
());
auto
code
=
client_
->
execute
(
query
,
resp
);
ASSERT_EQ
(
cpp2
::
ErrorCode
::
SUCCEEDED
,
code
);
std
::
vector
<
std
::
string
>
expectedColNames
{
{
"serve._dst"
}
};
ASSERT_TRUE
(
verifyColNames
(
resp
,
expectedColNames
));
std
::
vector
<
std
::
tuple
<
int64_t
>>
expected
=
{
{
teams_
[
"Spurs"
].
vid
()},
{
teams_
[
"Hornets"
].
vid
()},
};
ASSERT_TRUE
(
verifyResult
(
resp
,
expected
));
}
{
cpp2
::
ExecutionResponse
resp
;
auto
*
fmt
=
"GO FROM %ld OVER like YIELD like._dst AS id"
"| GO FROM $-.id OVER serve WHERE udf_is_in($-.id, %ld, 123) && 1 == 1"
;
auto
query
=
folly
::
stringPrintf
(
fmt
,
players_
[
"Tim Duncan"
].
vid
(),
players_
[
"Tony Parker"
].
vid
());
auto
code
=
client_
->
execute
(
query
,
resp
);
ASSERT_EQ
(
cpp2
::
ErrorCode
::
SUCCEEDED
,
code
);
std
::
vector
<
std
::
string
>
expectedColNames
{
{
"serve._dst"
}
};
ASSERT_TRUE
(
verifyColNames
(
resp
,
expectedColNames
));
std
::
vector
<
std
::
tuple
<
int64_t
>>
expected
=
{
{
teams_
[
"Spurs"
].
vid
()},
{
teams_
[
"Hornets"
].
vid
()},
};
ASSERT_TRUE
(
verifyResult
(
resp
,
expected
));
}
}
}
// namespace graph
}
// namespace graph
}
// namespace nebula
}
// namespace nebula
This diff is collapsed.
Click to expand it.
src/executor/test/YieldTest.cpp
+
19
−
0
View file @
e89c8a28
...
@@ -203,5 +203,24 @@ TEST_F(YieldTest, Logic) {
...
@@ -203,5 +203,24 @@ TEST_F(YieldTest, Logic) {
ASSERT_TRUE
(
verifyResult
(
resp
,
expected
));
ASSERT_TRUE
(
verifyResult
(
resp
,
expected
));
}
}
}
}
TEST_F
(
YieldTest
,
inCall
)
{
auto
client
=
gEnv
->
getClient
();
ASSERT_NE
(
nullptr
,
client
);
{
cpp2
::
ExecutionResponse
resp
;
std
::
string
query
=
"YIELD udf_is_in(1,0,1,2), 123"
;
auto
code
=
client
->
execute
(
query
,
resp
);
ASSERT_EQ
(
cpp2
::
ErrorCode
::
SUCCEEDED
,
code
)
<<
*
resp
.
get_error_msg
();
std
::
vector
<
std
::
string
>
expectedColNames
{
{
"udf_is_in(1,0,1,2)"
},
{
"123"
}
};
ASSERT_TRUE
(
verifyColNames
(
resp
,
expectedColNames
));
std
::
vector
<
std
::
tuple
<
bool
,
uint64_t
>>
expected
{
{
true
,
123
}
};
ASSERT_TRUE
(
verifyResult
(
resp
,
expected
));
}
}
}
// namespace graph
}
// namespace graph
}
// namespace nebula
}
// namespace nebula
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment