From 88a24bb1fd9c01b10b6eb186871f9ea9a049f300 Mon Sep 17 00:00:00 2001 From: "kyle.cao" <kyle.cao@vesoft.com> Date: Tue, 8 Dec 2020 11:28:23 +0800 Subject: [PATCH] Add BitOp tests (#456) add BIT_AND tests Co-authored-by: cpw <13495049+CPWstatic@users.noreply.github.com> --- tests/query/v1/test_groupby.py | 58 +++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/tests/query/v1/test_groupby.py b/tests/query/v1/test_groupby.py index f4e5abef..c90e6f5d 100644 --- a/tests/query/v1/test_groupby.py +++ b/tests/query/v1/test_groupby.py @@ -5,7 +5,7 @@ # This source code is licensed under Apache 2.0 License, # attached with Common Clause Condition 1.0, found in the LICENSES directory. -from tests.common.nebula_test_suite import NebulaTestSuite +from tests.common.nebula_test_suite import NebulaTestSuite, T_NULL_BAD_TYPE class TestGroupBy(NebulaTestSuite): @@ -218,6 +218,62 @@ class TestGroupBy(NebulaTestSuite): self.check_column_names(resp, expected_data["column_names"]) self.check_out_of_order_result(resp, expected_data["rows"]) + stmt = '''GO FROM 'Tim Duncan' OVER like YIELD like._dst as dst | \ + GO FROM $-.dst over like YIELD $-.dst as dst, like._dst == 'Tim Duncan' as following | \ + GROUP BY $-.dst YIELD $-.dst AS dst, BIT_OR($-.following) AS following''' + resp = self.execute(stmt) + self.check_resp_succeeded(resp) + expected_data = { + "column_names": ["dst", "following"], + "rows": [ + ["Tony Parker" , T_NULL_BAD_TYPE], + ["Manu Ginobili" , T_NULL_BAD_TYPE] + ] + } + self.check_out_of_order_result(resp, expected_data["rows"]) + + stmt = '''GO FROM 'Tim Duncan' OVER like YIELD like._dst as dst | \ + GO FROM $-.dst over like YIELD $-.dst as dst, like._dst == 'Tim Duncan' as following | \ + GROUP BY $-.dst YIELD $-.dst AS dst, BIT_OR(case when $-.following==true then 1 else 0 end) AS following ''' + resp = self.execute(stmt) + self.check_resp_succeeded(resp) + expected_data = { + "column_names": ["dst", "following"], + "rows": [ + ["Tony Parker" , 1], + ["Manu Ginobili" , 1] + ] + } + self.check_out_of_order_result(resp, expected_data["rows"]) + + stmt = '''GO FROM 'Tim Duncan' OVER like YIELD like._dst as dst | \ + GO FROM $-.dst over like YIELD $-.dst as dst, like._dst == 'Tim Duncan' as following | \ + GROUP BY $-.dst YIELD $-.dst AS dst, BIT_AND($-.following) AS following''' + resp = self.execute(stmt) + self.check_resp_succeeded(resp) + expected_data = { + "column_names": ["dst", "following"], + "rows": [ + ["Tony Parker" , T_NULL_BAD_TYPE], + ["Manu Ginobili" , T_NULL_BAD_TYPE] + ] + } + self.check_out_of_order_result(resp, expected_data["rows"]) + + stmt = '''GO FROM 'Tim Duncan' OVER like YIELD like._dst as dst | \ + GO FROM $-.dst over like YIELD $-.dst as dst, like._dst == 'Tim Duncan' as following | \ + GROUP BY $-.dst YIELD $-.dst AS dst, BIT_AND(case when $-.following==true then 1 else 0 end) AS following ''' + resp = self.execute(stmt) + self.check_resp_succeeded(resp) + expected_data = { + "column_names": ["dst", "following"], + "rows": [ + ["Tony Parker" , 0], + ["Manu Ginobili" , 1] + ] + } + self.check_out_of_order_result(resp, expected_data["rows"]) + # group has fun col stmt = '''GO FROM 'Carmelo Anthony', 'Dwyane Wade' OVER like YIELD $$.player.name AS name -- GitLab