Skip to content

Commit

Permalink
change LogicalType.toString for nested types (#3209)
Browse files Browse the repository at this point in the history
* change LogicalType.toString for nested types

tests are also updated

* change pytest
  • Loading branch information
mxwli committed Apr 8, 2024
1 parent c6e62e9 commit 9135eda
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 51 deletions.
8 changes: 4 additions & 4 deletions src/common/types/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ std::string LogicalType::toString() const {
auto structType =
ku_dynamic_cast<ExtraTypeInfo*, ListTypeInfo*>(extraTypeInfo.get())->getChildType();
auto fieldTypes = StructType::getFieldTypes(structType);
return "MAP(" + fieldTypes[0]->toString() + ": " + fieldTypes[1]->toString() + ")";
return "MAP(" + fieldTypes[0]->toString() + ", " + fieldTypes[1]->toString() + ")";
}
case LogicalTypeID::LIST: {
auto listTypeInfo = ku_dynamic_cast<ExtraTypeInfo*, ListTypeInfo*>(extraTypeInfo.get());
Expand All @@ -329,7 +329,7 @@ std::string LogicalType::toString() const {
auto numFields = unionTypeInfo->getChildrenTypes().size();
auto fieldNames = unionTypeInfo->getChildrenNames();
for (auto i = 1u; i < numFields; i++) {
dataTypeStr += fieldNames[i] + ":";
dataTypeStr += fieldNames[i] + " ";
dataTypeStr += unionTypeInfo->getChildType(i)->toString();
dataTypeStr += (i == numFields - 1 ? ")" : ", ");
}
Expand All @@ -341,11 +341,11 @@ std::string LogicalType::toString() const {
auto numFields = structTypeInfo->getChildrenTypes().size();
auto fieldNames = structTypeInfo->getChildrenNames();
for (auto i = 0u; i < numFields - 1; i++) {
dataTypeStr += fieldNames[i] + ":";
dataTypeStr += fieldNames[i] + " ";
dataTypeStr += structTypeInfo->getChildType(i)->toString();
dataTypeStr += ", ";
}
dataTypeStr += fieldNames[numFields - 1] + ":";
dataTypeStr += fieldNames[numFields - 1] + " ";
dataTypeStr += structTypeInfo->getChildType(numFields - 1)->toString();
return dataTypeStr + ")";
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_files/csv/errors.test
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Copy exception: Error in file ${KUZU_ROOT_DIRECTORY}/dataset/csv-error-tests/too

-STATEMENT LOAD FROM "${KUZU_ROOT_DIRECTORY}/dataset/csv-error-tests/union-no-conversion.csv" (HEADER=TRUE) RETURN *
---- error
Copy exception: Error in file ${KUZU_ROOT_DIRECTORY}/dataset/csv-error-tests/union-no-conversion.csv on line 2: Conversion exception: Could not convert to union type UNION(u:UINT8, s:INT8): a.
Copy exception: Error in file ${KUZU_ROOT_DIRECTORY}/dataset/csv-error-tests/union-no-conversion.csv on line 2: Conversion exception: Could not convert to union type UNION(u UINT8, s INT8): a.

# Test that errors in serial mode don't hang the database.
# File is large so the window for the race is large enough.
Expand Down
6 changes: 3 additions & 3 deletions test/test_files/tck/expressions/boolean/Boolean1.test
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ Binder exception: Expression LIST_CREATION() has data type STRING[] but expected

-STATEMENT RETURN {x: []} AND true;
---- error
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported.
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x STRING[]) but expected BOOL. Implicit cast is not supported.

-STATEMENT RETURN false AND 123;
---- error
Expand Down Expand Up @@ -237,7 +237,7 @@ Binder exception: Expression LIST_CREATION() has data type STRING[] but expected

-STATEMENT RETURN false AND {x: []};
---- error
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported.
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x STRING[]) but expected BOOL. Implicit cast is not supported.

-STATEMENT RETURN 123 AND 'foo';
---- error
Expand All @@ -257,4 +257,4 @@ Binder exception: Expression LIST_CREATION(True) has data type BOOL[] but expect

-STATEMENT RETURN {x: []} AND [123];
---- error
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported.
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x STRING[]) but expected BOOL. Implicit cast is not supported.
6 changes: 3 additions & 3 deletions test/test_files/tck/expressions/boolean/Boolean2.test
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Binder exception: Expression LIST_CREATION() has data type STRING[] but expected

-STATEMENT RETURN {x: []} OR true;
---- error
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported.
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x STRING[]) but expected BOOL. Implicit cast is not supported.

-STATEMENT RETURN false OR 123;
---- error
Expand Down Expand Up @@ -235,7 +235,7 @@ Binder exception: Expression LIST_CREATION() has data type STRING[] but expected

-STATEMENT RETURN false OR {x: []};
---- error
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported.
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x STRING[]) but expected BOOL. Implicit cast is not supported.

-STATEMENT RETURN 123 OR 'foo';
---- error
Expand All @@ -255,4 +255,4 @@ Binder exception: Expression LIST_CREATION(True) has data type BOOL[] but expect

-STATEMENT RETURN {x: []} OR [123];
---- error
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported.
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x STRING[]) but expected BOOL. Implicit cast is not supported.
6 changes: 3 additions & 3 deletions test/test_files/tck/expressions/boolean/Boolean3.test
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Binder exception: Expression LIST_CREATION() has data type STRING[] but expected

-STATEMENT RETURN {x: []} XOR true;
---- error
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported.
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x STRING[]) but expected BOOL. Implicit cast is not supported.

-STATEMENT RETURN false XOR 123;
---- error
Expand Down Expand Up @@ -234,7 +234,7 @@ Binder exception: Expression LIST_CREATION() has data type STRING[] but expected

-STATEMENT RETURN false XOR {x: []};
---- error
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported.
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x STRING[]) but expected BOOL. Implicit cast is not supported.

-STATEMENT RETURN 123 XOR 'foo';
---- error
Expand All @@ -254,4 +254,4 @@ Binder exception: Expression LIST_CREATION(True) has data type BOOL[] but expect

-STATEMENT RETURN {x: []} XOR [123];
---- error
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x:STRING[]) but expected BOOL. Implicit cast is not supported.
Binder exception: Expression STRUCT_PACK(x) has data type STRUCT(x STRING[]) but expected BOOL. Implicit cast is not supported.
2 changes: 1 addition & 1 deletion test/test_files/tck/expressions/list/List1.test
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Binder exception: Cannot match a built-in function for given function LIST_EXTRA
-STATEMENT WITH [1, 2, 3, 4, 5] AS list, {x: 3} AS idx
RETURN list[idx];
---- error
Binder exception: Cannot match a built-in function for given function LIST_EXTRACT(INT64[],STRUCT(x:INT64)). Supported inputs are
Binder exception: Cannot match a built-in function for given function LIST_EXTRACT(INT64[],STRUCT(x INT64)). Supported inputs are
(LIST,INT64) -> ANY
(STRING,INT64) -> STRING
(ARRAY,INT64) -> ANY
4 changes: 2 additions & 2 deletions test/test_files/tck/expressions/list/List11.test
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ Binder exception: Cannot match a built-in function for given function RANGE(INT6

-STATEMENT RETURN range({start: 0}, 1, 1);
---- error
Binder exception: Cannot match a built-in function for given function RANGE(STRUCT(start:INT64),INT64,INT64). Supported inputs are
Binder exception: Cannot match a built-in function for given function RANGE(STRUCT(start INT64),INT64,INT64). Supported inputs are
(INT64,INT64) -> LIST
(INT64,INT64,INT64) -> LIST
(INT32,INT32) -> LIST
Expand All @@ -480,7 +480,7 @@ Binder exception: Cannot match a built-in function for given function RANGE(STRU

-STATEMENT RETURN range(0, 1, {step: 1});
---- error
Binder exception: Cannot match a built-in function for given function RANGE(INT64,INT64,STRUCT(step:INT64)). Supported inputs are
Binder exception: Cannot match a built-in function for given function RANGE(INT64,INT64,STRUCT(step INT64)). Supported inputs are
(INT64,INT64) -> LIST
(INT64,INT64,INT64) -> LIST
(INT32,INT32) -> LIST
Expand Down
24 changes: 12 additions & 12 deletions test/test_files/tinysnb/call/call.test
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ Can't execute a write query inside a read-only transaction.
2|meetTime|TIMESTAMP
3|validInterval|INTERVAL
4|comments|STRING[]
5|summary|STRUCT(locations:STRING[], transfer:STRUCT(day:DATE, amount:INT64[]))
6|notes|UNION(firstmet:DATE, type:INT16, comment:STRING)
7|someMap|MAP(STRING: STRING)
5|summary|STRUCT(locations STRING[], transfer STRUCT(day DATE, amount INT64[]))
6|notes|UNION(firstmet DATE, type INT16, comment STRING)
7|someMap|MAP(STRING, STRING)

-LOG ReturnNodeName
-STATEMENT CALL table_info('person') WHERE name <> 'ID' RETURN name
Expand All @@ -142,25 +142,25 @@ height
---- 21
2:0|DATE
2:0|INTERVAL
2:0|MAP(STRING: STRING)
2:0|MAP(STRING, STRING)
2:0|STRING[]
2:0|TIMESTAMP
2:0|STRUCT(locations:STRING[], transfer:STRUCT(day:DATE, amount:INT64[]))
2:0|UNION(firstmet:DATE, type:INT16, comment:STRING)
2:0|STRUCT(locations STRING[], transfer STRUCT(day DATE, amount INT64[]))
2:0|UNION(firstmet DATE, type INT16, comment STRING)
2:1|DATE
2:1|INTERVAL
2:1|MAP(STRING: STRING)
2:1|MAP(STRING, STRING)
2:1|STRING[]
2:1|TIMESTAMP
2:1|STRUCT(locations:STRING[], transfer:STRUCT(day:DATE, amount:INT64[]))
2:1|UNION(firstmet:DATE, type:INT16, comment:STRING)
2:1|STRUCT(locations STRING[], transfer STRUCT(day DATE, amount INT64[]))
2:1|UNION(firstmet DATE, type INT16, comment STRING)
2:2|DATE
2:2|INTERVAL
2:2|MAP(STRING: STRING)
2:2|MAP(STRING, STRING)
2:2|STRING[]
2:2|TIMESTAMP
2:2|STRUCT(locations:STRING[], transfer:STRUCT(day:DATE, amount:INT64[]))
2:2|UNION(firstmet:DATE, type:INT16, comment:STRING)
2:2|STRUCT(locations STRING[], transfer STRUCT(day DATE, amount INT64[]))
2:2|UNION(firstmet DATE, type INT16, comment STRING)

-CASE CallNodeTableWith300ColumnsInfo
-DEFINE COLS REPEAT 2400 "col${count} INT64,"
Expand Down
Loading

0 comments on commit 9135eda

Please sign in to comment.