Skip to content

Commit fe12d4f

Browse files
authored
Fix json null (#5202)
1 parent 31c789b commit fe12d4f

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

dataset/json-misc/null_in_struct.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"accountContacts": [
3+
{
4+
"objectType": "contact",
5+
"schemaVersion": null,
6+
"contactIdentifier": "320864",
7+
"contactNamespace": "56127",
8+
"contactDetail": {
9+
"fullname": "Renee Luke",
10+
"email": "[email protected]",
11+
"phone": "(678) 252-4828 - Direct"
12+
}
13+
}
14+
]
15+
}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"accountContacts": [
3+
{
4+
"objectType": "contact",
5+
"schemaVersion": "135",
6+
"contactIdentifier": "320864",
7+
"contactNamespace": null,
8+
"contactDetail": {
9+
"fullname": "Renee Luke",
10+
"email": "[email protected]",
11+
"phone": "(678) 252-4828 - Direct"
12+
}
13+
}
14+
]
15+
}

extension/json/src/functions/table_functions/json_scan.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ static JsonScanFormat autoDetect(main::ClientContext* context, const std::string
778778
}
779779

780780
for (auto& type : types) {
781-
LogicalTypeUtils::purgeAny(type, LogicalType::STRING());
781+
type = LogicalTypeUtils::purgeAny(type, LogicalType::STRING());
782782
}
783783
return sharedState.jsonReader->getFormat();
784784
}

extension/json/test/scan_json.test

+6
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ Unable to find primary key value 6.|${KUZU_ROOT_DIRECTORY}/dataset/json-error/in
157157
8246337208329|2012-07-20 23:08:15.828|31.13.184.200|Firefox|About George Frideric Handel, ful with hisAbout Erwin Rommel, mandy. As onAbout|79
158158
8246337208330|2012-07-20 06:31:37.85|62.100.246.118|Internet Explorer|good|4
159159
8246337208331|2012-07-21 03:07:22.319|46.30.7.107|Firefox|no|2
160+
-STATEMENT LOAD FROM '${KUZU_ROOT_DIRECTORY}/dataset/json-misc/null_in_struct.json' RETURN *;
161+
---- 1
162+
[{objectType: contact, schemaVersion: , contactIdentifier: 320864, contactNamespace: 56127, contactDetail: {fullname: Renee Luke, email: [email protected], phone: (678) 252-4828 - Direct}}]
163+
-STATEMENT LOAD FROM '${KUZU_ROOT_DIRECTORY}/dataset/json-misc/null_in_struct2.json' RETURN *;
164+
---- 1
165+
[{objectType: contact, schemaVersion: 135, contactIdentifier: 320864, contactNamespace: , contactDetail: {fullname: Renee Luke, email: [email protected], phone: (678) 252-4828 - Direct}}]
160166

161167
-CASE InstallOfficialExtension
162168
-STATEMENT INSTALL json FROM 'http://localhost/extension/repo/'

0 commit comments

Comments
 (0)