Skip to content

Commit

Permalink
revert null printing
Browse files Browse the repository at this point in the history
  • Loading branch information
andyfengHKU committed Jan 16, 2023
1 parent 4f70f1f commit c700b5e
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 109 deletions.
2 changes: 1 addition & 1 deletion src/common/types/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ Value Value::createValue(const char* value) {

string Value::toString() const {
if (isNull_) {
return "NULL";
return "";
}
switch (dataType.typeID) {
case BOOL:
Expand Down
4 changes: 2 additions & 2 deletions test/demo_db/demo_db_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ TEST_F(DemoDBTest, CreateAvgNullTest) {
auto result =
conn->query("MATCH (a:User) WITH a, avg(a.age) AS b, SUM(a.age) AS c, COUNT(a.age) AS d, "
"COUNT(*) AS e RETURN a, b, c,d, e ORDER BY c DESC");
auto groundTruth = vector<string>{"(0:4:User {name:Alice, age:NULL})|NULL|NULL|0|1",
auto groundTruth = vector<string>{"(0:4:User {name:Alice, age:})|||0|1",
"(0:2:User {name:Zhang, age:50})|50.000000|50|1|1",
"(0:1:User {name:Karissa, age:40})|40.000000|40|1|1",
"(0:0:User {name:Adam, age:30})|30.000000|30|1|1",
Expand Down Expand Up @@ -63,6 +63,6 @@ TEST_F(DemoDBTest, SetNodeTest) {
ASSERT_EQ(TestHelper::convertResultToString(*result, true /* check order */), groundTruth);
ASSERT_TRUE(conn->query("MATCH (u:User) WHERE u.name = 'Adam' SET u.age = NULL")->isSuccess());
result = conn->query("MATCH (u:User) WHERE u.name='Adam' RETURN u.age");
groundTruth = vector<string>{"NULL"};
groundTruth = vector<string>{""};
ASSERT_EQ(TestHelper::convertResultToString(*result, true /* check order */), groundTruth);
}
2 changes: 1 addition & 1 deletion test/runner/e2e_delete_create_transaction_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ static void validateInsertedRel(
auto length = to_string(param);
auto place = to_string(param);
if (testNullAndLongString) {
length = "NULL";
length = "";
place = CreateRelTrxTest::getLongStr(place);
}
auto groundTruth = length + "|" + place + "|[" + to_string(param) + "]";
Expand Down
4 changes: 2 additions & 2 deletions test/runner/e2e_set_transaction_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ TEST_F(SetNodeStructuredPropTransactionTest,
conn->beginWriteTransaction();
readAndAssertNodeProperty(conn.get(), 0 /* node offset */, "age", vector<string>{"35"});
conn->query("MATCH (a:person) WHERE a.ID = 0 SET a.age = null;");
readAndAssertNodeProperty(conn.get(), 0 /* node offset */, "age", vector<string>{"NULL"});
readAndAssertNodeProperty(conn.get(), 0 /* node offset */, "age", vector<string>{""});
}

TEST_F(SetNodeStructuredPropTransactionTest,
SingleTransactionReadWriteToStringStructuredNodePropertyNullTest) {
conn->beginWriteTransaction();
readAndAssertNodeProperty(conn.get(), 0 /* node offset */, "fName", vector<string>{"Alice"});
auto result = conn->query("MATCH (a:person) WHERE a.ID = 0 SET a.fName = null;");
readAndAssertNodeProperty(conn.get(), 0 /* node offset */, "fName", vector<string>{"NULL"});
readAndAssertNodeProperty(conn.get(), 0 /* node offset */, "fName", vector<string>{""});
}

TEST_F(SetNodeStructuredPropTransactionTest,
Expand Down
26 changes: 12 additions & 14 deletions test/runner/e2e_update_node_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ TEST_F(TinySnbUpdateTest, SetNodeIntervalPropTest) {
TEST_F(TinySnbUpdateTest, SetNodePropNullTest) {
conn->query("MATCH (a:person) SET a.age=null");
auto result = conn->query("MATCH (a:person) RETURN a.age");
auto groundTruth =
vector<string>{"NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL", "NULL"};
auto groundTruth = vector<string>{"", "", "", "", "", "", "", ""};
ASSERT_EQ(TestHelper::convertResultToString(*result), groundTruth);
}

Expand Down Expand Up @@ -155,8 +154,7 @@ TEST_F(TinySnbUpdateTest, SetTwoHopTest) {
TEST_F(TinySnbUpdateTest, SetTwoHopNullTest) {
conn->query("MATCH (a:person)-[:knows]->(b:person)-[:knows]->(c:person) SET a.age=null");
auto result = conn->query("MATCH (a:person) RETURN a.ID, a.age");
auto groundTruth =
vector<string>{"0|NULL", "10|83", "2|NULL", "3|NULL", "5|NULL", "7|20", "8|25", "9|40"};
auto groundTruth = vector<string>{"0|", "10|83", "2|", "3|", "5|", "7|20", "8|25", "9|40"};
ASSERT_EQ(TestHelper::convertResultToString(*result), groundTruth);
}

Expand All @@ -166,8 +164,8 @@ TEST_F(TinySnbUpdateTest, InsertNodeWithBoolIntDoubleTest) {
conn->query("CREATE (:person {ID:80, isWorker:true,age:22,eyeSight:1.1});");
auto result = conn->query("MATCH (a:person) WHERE a.ID > 8 "
"RETURN a.ID, a.gender,a.isStudent, a.isWorker, a.age, a.eyeSight");
auto groundTruth = vector<string>{"10|2|False|True|83|4.900000",
"80|NULL|NULL|True|22|1.100000", "9|2|False|False|40|4.900000"};
auto groundTruth = vector<string>{
"10|2|False|True|83|4.900000", "80|||True|22|1.100000", "9|2|False|False|40|4.900000"};
ASSERT_EQ(TestHelper::convertResultToString(*result), groundTruth);
}

Expand Down Expand Up @@ -218,10 +216,10 @@ TEST_F(TinySnbUpdateTest, InsertNodeWithMixedLabelTest) {
TEST_F(TinySnbUpdateTest, InsertNodeAfterMatchListTest) {
conn->query("MATCH (a:person) CREATE (:person {ID:a.ID+11, age:a.age*2});");
auto result = conn->query("MATCH (a:person) RETURN a.ID, a.fName,a.age");
auto groundTruth = vector<string>{"0|Alice|35",
"10|Hubert Blaine Wolfeschlegelsteinhausenbergerdorff|83", "11|NULL|70", "13|NULL|60",
"14|NULL|90", "16|NULL|40", "18|NULL|40", "19|NULL|50", "20|NULL|80", "21|NULL|166",
"2|Bob|30", "3|Carol|45", "5|Dan|20", "7|Elizabeth|20", "8|Farooq|25", "9|Greg|40"};
auto groundTruth =
vector<string>{"0|Alice|35", "10|Hubert Blaine Wolfeschlegelsteinhausenbergerdorff|83",
"11||70", "13||60", "14||90", "16||40", "18||40", "19||50", "20||80", "21||166",
"2|Bob|30", "3|Carol|45", "5|Dan|20", "7|Elizabeth|20", "8|Farooq|25", "9|Greg|40"};
ASSERT_EQ(TestHelper::convertResultToString(*result), groundTruth);
}

Expand All @@ -244,7 +242,7 @@ TEST_F(TinySnbUpdateTest, InsertSingleNTo1RelTest) {
"CREATE (a)-[:studyAt {year:2022}]->(b);");
auto groundTruth = vector<string>{
"8|325|(0:5)-[{_id:16, year:2020, places:[awndsnjwejwen,isuhuwennjnuhuhuwewe]}]->(1:0)|16",
"9|934|(0:6)-[{_id:40, year:2022, places:NULL}]->(1:1)|40"};
"9|934|(0:6)-[{_id:40, year:2022, places:}]->(1:1)|40"};
auto result = conn->query("MATCH (a:person)-[e:studyAt]->(b:organisation) WHERE a.ID > 5 "
"RETURN a.ID, b.orgCode, e, ID(e)");
ASSERT_EQ(TestHelper::convertResultToString(*result), groundTruth);
Expand Down Expand Up @@ -304,21 +302,21 @@ TEST_F(TinySnbUpdateTest, DeleteNodeAfterInsertTest) { // test reset of property
conn->query("MATCH (a:person) WHERE a.ID = 100 DELETE a;");
conn->query("CREATE (a:person {ID:101})");
auto result = conn->query("MATCH (a:person) WHERE a.ID = 101 RETURN a.ID, a.fName, a.age");
auto groundTruth = vector<string>{"101|NULL|NULL"};
auto groundTruth = vector<string>{"101||"};
ASSERT_EQ(TestHelper::convertResultToString(*result), groundTruth);
}

TEST_F(TinySnbUpdateTest, MixedDeleteInsertTest) {
conn->query("CREATE (a:organisation {ID:30, mark:3.3})");
auto result = conn->query("MATCH (a:organisation) WHERE a.ID = 30 RETURN a.orgCode, a.mark");
auto groundTruth = vector<string>{"NULL|3.300000"};
auto groundTruth = vector<string>{"|3.300000"};
ASSERT_EQ(TestHelper::convertResultToString(*result), groundTruth);
conn->query("MATCH (a:organisation) WHERE a.ID = 30 DELETE a");
result = conn->query("MATCH (a:organisation) WHERE a.ID = 30 RETURN a.orgCode, a.mark");
groundTruth = vector<string>{};
ASSERT_EQ(TestHelper::convertResultToString(*result), groundTruth);
conn->query("CREATE (a:organisation {ID:30, orgCode:33})");
result = conn->query("MATCH (a:organisation) WHERE a.ID = 30 RETURN a.orgCode, a.mark");
groundTruth = vector<string>{"33|NULL"};
groundTruth = vector<string>{"33|"};
ASSERT_EQ(TestHelper::convertResultToString(*result), groundTruth);
}
20 changes: 10 additions & 10 deletions test/runner/e2e_update_rel_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class UpdateRelTest : public DBTest {
auto result = conn->query("MATCH (a:animal)-[e:knows]->(:person) where a.ID >= 20 and a.ID "
"<= 30 return e.length");
auto actualResult = TestHelper::convertResultToString(*result);
vector<string> expectedResult = isCommit ? vector<string>{"NULL", "21", "22", "23", "24",
"210", "26", "27", "28", "29", "300"} :
vector<string>{"20", "21", "22", "23", "24",
"25", "26", "27", "28", "29", "30"};
vector<string> expectedResult =
isCommit ?
vector<string>{"", "21", "22", "23", "24", "210", "26", "27", "28", "29", "300"} :
vector<string>{"20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30"};
sortAndCheckTestResults(actualResult, expectedResult);
}

Expand All @@ -70,7 +70,7 @@ class UpdateRelTest : public DBTest {
auto actualResult = TestHelper::convertResultToString(*result);
auto expectedResult =
isCommit ? vector<string>{"990990990", "989", "988988988", "987", "986986986",
"waterloo", "kitchener", "983", "982982982", "NULL", "980980980"} :
"waterloo", "kitchener", "983", "982982982", "", "980980980"} :
vector<string>{"990990990", "989", "988988988", "987", "986986986", "985",
"984984984", "983", "982982982", "981", "980980980"};
sortAndCheckTestResults(actualResult, expectedResult);
Expand All @@ -96,7 +96,7 @@ class UpdateRelTest : public DBTest {
auto actualResult = TestHelper::convertResultToString(*result);
auto expectedResult =
isCommit ? vector<string>{"[960960960]", "[959]", "[958958958]",
"[updated property1,50]", "[956956956]", "[955]", "[954954954]", "NULL",
"[updated property1,50]", "[956956956]", "[955]", "[954954954]", "",
"[952952952]", "[updated property3,54]", "[950950950]"} :
vector<string>{"[960960960]", "[959]", "[958958958]", "[957]", "[956956956]",
"[955]", "[954954954]", "[953]", "[952952952]", "[951]", "[950950950]"};
Expand Down Expand Up @@ -155,7 +155,7 @@ class UpdateRelTest : public DBTest {
auto result =
conn->query("MATCH (p:person)-[e:knows]->(:person) where p.ID > 4 return e.length");
auto actualResult = TestHelper::convertResultToString(*result);
auto expectedResult = isCommit ? vector<string>{"NULL", "55", "201"} : vector<string>{};
auto expectedResult = isCommit ? vector<string>{"", "55", "201"} : vector<string>{};
sortAndCheckTestResults(actualResult, expectedResult);
}

Expand All @@ -169,7 +169,7 @@ class UpdateRelTest : public DBTest {
conn->query("MATCH (a:animal)-[e1:knows]->(p:person)-[e2:knows]->(p1:person) WHERE "
"p1.ID = 2500 AND a.ID = 5 RETURN e1.length, e2.length");
auto actualResult = TestHelper::convertResultToString(*result);
auto expectedResult = isCommit ? vector<string>{"300|NULL"} : vector<string>{"5|7497"};
auto expectedResult = isCommit ? vector<string>{"300|"} : vector<string>{"5|7497"};
sortAndCheckTestResults(actualResult, expectedResult);
}

Expand Down Expand Up @@ -252,7 +252,7 @@ class UpdateRelTest : public DBTest {
ASSERT_TRUE(conn->query(getUpdateRelQuery("person" /* srcTable */, "person" /* relation */,
"teaches" /* relation */, 33 /* srcID */, 3 /* dstID */, "SET e.length = 312")));
commitOrRollbackConnectionAndInitDBIfNecessary(isCommit, transactionTestType);
auto expectedResult = isCommit ? vector<string>{"11", "NULL", "22", "31", "512", "312"} :
auto expectedResult = isCommit ? vector<string>{"11", "", "22", "31", "512", "312"} :
vector<string>{"11", "21", "22", "31", "32", "33"};
auto result = conn->query("MATCH (p:person)-[e:teaches]->(:person) RETURN e.length");
auto actualResult = TestHelper::convertResultToString(*result);
Expand All @@ -270,7 +270,7 @@ class UpdateRelTest : public DBTest {
commitOrRollbackConnectionAndInitDBIfNecessary(isCommit, transactionTestType);
auto expectedResult =
isCommit ? vector<string>{"1999", "kuzu", "1997", "db", "1995", "199419941994", "1993",
"NULL", "1991", "1989"} :
"", "1991", "1989"} :
vector<string>{"1999", "199819981998", "1997", "199619961996", "1995",
"199419941994", "1993", "199219921992", "1991", "1989"};
auto result = conn->query("MATCH (:animal)-[e:hasOwner]->(:person) RETURN e.place");
Expand Down
2 changes: 1 addition & 1 deletion test/test_files/copy/copy_node.test
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
-NAME EmptyStringTest
-QUERY MATCH (row:tableOfTypes) WHERE row.id = 49992 RETURN *;
---- 1
(0:49992:tableOfTypes {id:49992, int64Column:50, doubleColumn:31.582059, booleanColumn:False, dateColumn:1551-07-19, timestampColumn:1551-07-19 16:28:31, stringColumn:NULL})
(0:49992:tableOfTypes {id:49992, int64Column:50, doubleColumn:31.582059, booleanColumn:False, dateColumn:1551-07-19, timestampColumn:1551-07-19 16:28:31, stringColumn:})

-NAME FloatTest
-QUERY MATCH (row:tableOfTypes) WHERE row.doubleColumn = 68.73718401556897 RETURN row.dateColumn;
Expand Down
2 changes: 1 addition & 1 deletion test/test_files/demo_db/demo_db.test
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Adam|Karissa
Adam|Zhang
Karissa|Zhang
Zhang|Noura
Noura|NULL
Noura|

-NAME OrderBy1
-QUERY MATCH (u:User) RETURN u.name, u.age ORDER BY u.age;
Expand Down
4 changes: 2 additions & 2 deletions test/test_files/tinysnb/agg/multi_label.test
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
-NAME MultiLabelAggTest3
-QUERY MATCH (a:person)-[e1:marries|:mixed|studyAt]->(b:person) RETURN e1.year, COUNT(*)
---- 8
NULL|3
|3
1930|1
1945|1
2088|1
Expand All @@ -29,5 +29,5 @@ NULL|3
20|2
30|2
45|3
NULL|3
|3

2 changes: 1 addition & 1 deletion test/test_files/tinysnb/filter/multi_label.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
-QUERY MATCH (a:person)-[e:mixed|:studyAt|:knows]->(b:person:organisation) WHERE e.year = 2088 RETURN a.ID, b.fName, b.orgCode
-ENUMERATE
---- 1
3|Elizabeth|NULL
3|Elizabeth|

-NAME MultiLabelTwoHopTest1
-QUERY MATCH (a:person)<-[e:knows|:mixed|:meets]-(b:person)-[:knows|:mixed|:meets]->(c:person) WHERE b.ID = 7 AND a.ID = c.ID RETURN COUNT(*)
Expand Down
4 changes: 2 additions & 2 deletions test/test_files/tinysnb/function/case.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Hubert Blaine Wolfeschlegelsteinhausenbergerdorff
-NAME CaseListTest
-QUERY MATCH (a:person) WHERE a.ID > 6 RETURN CASE WHEN len(a.workedHours) = 1 THEN a.courseScoresPerTerm END
---- 4
NULL
NULL


[[10]]
[[6],[7],[8]]

Expand Down
20 changes: 10 additions & 10 deletions test/test_files/tinysnb/match/multi_label.test
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@
-QUERY MATCH (a:person)-[e:mixed|:marries]->(b:person) RETURN a.ID, ID(e), e.note, e.year, b.ID
-ENUMERATE
---- 10
0|27|NULL|1930|2
2|28|NULL|1945|5
3|29|NULL|2088|7
7|30|NULL|2066|3
8|31|NULL|2120|3
9|32|NULL|2022|3
10|33|NULL|2020|2
0|37|NULL|NULL|2
3|38|long long long string|NULL|5
7|39|short str|NULL|8
0|27||1930|2
2|28||1945|5
3|29||2088|7
7|30||2066|3
8|31||2120|3
9|32||2022|3
10|33||2020|2
0|37|||2
3|38|long long long string||5
7|39|short str||8

-NAME MultiLabelOneHopTest5
-QUERY MATCH (a:person)-[e:mixed|:studyAt|:knows]->(b:person:organisation) RETURN COUNT(*)
Expand Down
30 changes: 15 additions & 15 deletions test/test_files/tinysnb/optional_match/optional_match.test
Original file line number Diff line number Diff line change
Expand Up @@ -65,41 +65,41 @@
---- 3
Elizabeth|Farooq
Elizabeth|Greg
Hubert Blaine Wolfeschlegelsteinhausenbergerdorff|NULL
Hubert Blaine Wolfeschlegelsteinhausenbergerdorff|

-NAME OptionalReturnTest
-QUERY MATCH (a:person)-[:knows]->(b:person) WHERE a.fName='Alice' OPTIONAL MATCH (b)-[:studyAt]->(c:organisation) RETURN c.orgCode
-ENUMERATE
---- 3
NULL
NULL


325

-NAME OptionalReturnTest2
-QUERY MATCH (a:person) OPTIONAL MATCH (a)-[:knows]->(b:person) WHERE b.fName='Farooq' RETURN a.fName, b.fName
-ENUMERATE
---- 8
Alice|NULL
Bob|NULL
Carol|NULL
Dan|NULL
Alice|
Bob|
Carol|
Dan|
Elizabeth|Farooq
Farooq|NULL
Greg|NULL
Hubert Blaine Wolfeschlegelsteinhausenbergerdorff|NULL
Farooq|
Greg|
Hubert Blaine Wolfeschlegelsteinhausenbergerdorff|

-NAME OptionalListExtendCountTest
-QUERY MATCH (a:person) OPTIONAL MATCH (a)-[:studyAt]->(b:organisation) RETURN a.fName, b.name
-ENUMERATE
---- 8
Alice|ABFsUni
Bob|ABFsUni
Carol|NULL
Dan|NULL
Elizabeth|NULL
Carol|
Dan|
Elizabeth|
Farooq|ABFsUni
Greg|NULL
Hubert Blaine Wolfeschlegelsteinhausenbergerdorff|NULL
Greg|
Hubert Blaine Wolfeschlegelsteinhausenbergerdorff|

-NAME OptionalListExtendTest2
-QUERY MATCH (a:person) OPTIONAL MATCH (a)-[:knows]->(b:person)-[:knows]->(c:person) RETURN COUNT(*)
Expand Down
20 changes: 10 additions & 10 deletions test/test_files/tinysnb/order_by/multi_label.test
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
-QUERY MATCH (a:person:organisation)-[:mixed]->(b:person:organisation) return b.name, b.fName ORDER BY b.ID
-ENUMERATE
---- 10
NULL|Bob
NULL|Bob
NULL|Carol
NULL|Carol
NULL|Carol
CsWork|NULL
NULL|Dan
DEsWork|NULL
DEsWork|NULL
NULL|Elizabeth
|Bob
|Bob
|Carol
|Carol
|Carol
CsWork|
|Dan
DEsWork|
DEsWork|
|Elizabeth
Loading

0 comments on commit c700b5e

Please sign in to comment.