Skip to content

Commit 11cbc43

Browse files
kevyangmeta-codesync[bot]
authored andcommitted
upgrade simdjson third party to 4.1.0 (facebookincubator#15306)
Summary: Pull Request resolved: facebookincubator#15306 allow-large-files This commit was generated using `mgt import`. pristine code for third-party libraries: third-party/simdjson uuid_cc2796e6e0604da2800cc1275df8ef85 update simdjson requested as we were running into ubsan errors in aarch64. i have validated that they go away with this change. Reviewed By: kgpai Differential Revision: D85209914 fbshipit-source-id: c2972c81a57452f71e98d79d86466b809a160c61
1 parent 3cd3aa4 commit 11cbc43

File tree

9 files changed

+31
-9
lines changed

9 files changed

+31
-9
lines changed

CMake/resolve_dependency_modules/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ by Velox. See details on bundling below.
3030
| xsimd | 10.0.0 | Yes ||
3131
| re2 | 2024-07-02 | Yes ||
3232
| fmt | 11.2.0 | Yes | Used API must be fmt 9 compatible |
33-
| simdjson | 3.13.0 | Yes ||
33+
| simdjson | 4.1.0 | Yes ||
3434
| faiss | 1.11.0 | Yes ||
3535
| folly | v2025.04.28.00 | Yes ||
3636
| fizz | v2025.04.28.00 | No ||

CMake/resolve_dependency_modules/simdjson.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
# limitations under the License.
1414
include_guard(GLOBAL)
1515

16-
set(VELOX_SIMDJSON_VERSION 3.13.0)
16+
set(VELOX_SIMDJSON_VERSION 4.1.0)
1717
set(
1818
VELOX_SIMDJSON_BUILD_SHA256_CHECKSUM
19-
07a1bb3587aac18fd6a10a83fe4ab09f1100ab39f0cb73baea1317826b9f9e0d
19+
78115e37b2e88ec63e6ae20bb148063a9112c55bcd71404c8572078fd8a6ac3e
2020
)
2121
set(
2222
VELOX_SIMDJSON_SOURCE_URL

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ if(${VELOX_BUILD_MINIMAL_WITH_DWIO} OR ${VELOX_ENABLE_HIVE_CONNECTOR} OR VELOX_E
616616
endif()
617617

618618
velox_set_source(simdjson)
619-
velox_resolve_dependency(simdjson 3.13.0)
619+
velox_resolve_dependency(simdjson 4.1.0)
620620

621621
velox_set_source(FastFloat)
622622
velox_resolve_dependency(FastFloat)

scripts/setup-versions.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ARROW_VERSION="15.0.0"
2626
DUCKDB_VERSION="v0.8.1"
2727
PROTOBUF_VERSION="21.8"
2828
XSIMD_VERSION="10.0.0"
29-
SIMDJSON_VERSION="3.13.0"
29+
SIMDJSON_VERSION="4.1.0"
3030
CPR_VERSION="1.10.5"
3131
DOUBLE_CONVERSION_VERSION="v3.1.5"
3232
RANGE_V3_VERSION="0.12.0"

velox/functions/prestosql/JsonFunctions.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ template <typename T>
3333
static simdjson::error_code validate(T value) {
3434
SIMDJSON_ASSIGN_OR_RAISE(auto type, value.type());
3535
switch (type) {
36+
case simdjson::ondemand::json_type::unknown: {
37+
// In simdjson 4.0.7+, unknown type is returned for invalid JSON values
38+
// like NaN, Infinity, etc. Return INCORRECT_TYPE to indicate invalid
39+
// JSON.
40+
return simdjson::INCORRECT_TYPE;
41+
}
3642
case simdjson::ondemand::json_type::array: {
3743
SIMDJSON_ASSIGN_OR_RAISE(auto array, value.get_array());
3844
for (auto elementOrError : array) {
@@ -389,6 +395,12 @@ class JsonParseImpl {
389395
simdjson::error_code generateViews(T value) const {
390396
SIMDJSON_ASSIGN_OR_RAISE(auto type, value.type());
391397
switch (type) {
398+
case simdjson::ondemand::json_type::unknown: {
399+
// In simdjson 4.0.7+, unknown type is returned for invalid JSON values
400+
// like NaN, Infinity, etc. Return INCORRECT_TYPE to indicate invalid
401+
// JSON.
402+
return simdjson::INCORRECT_TYPE;
403+
}
392404
case simdjson::ondemand::json_type::array: {
393405
SIMDJSON_ASSIGN_OR_RAISE(auto array, value.get_array());
394406
return generateViewsFromArray<kNeedNormalize>(array);
@@ -761,6 +773,12 @@ struct JsonExtractImpl {
761773
// contents directly) and we might miss invalid JSON.
762774
SIMDJSON_ASSIGN_OR_RAISE(auto vtype, v.type());
763775
switch (vtype) {
776+
case simdjson::ondemand::json_type::unknown: {
777+
// In simdjson 4.0.7+, unknown type is returned for invalid JSON
778+
// values like NaN, Infinity, etc. Return INCORRECT_TYPE to indicate
779+
// invalid JSON.
780+
return simdjson::INCORRECT_TYPE;
781+
}
764782
case simdjson::ondemand::json_type::object: {
765783
SIMDJSON_ASSIGN_OR_RAISE(
766784
auto jsonStr, simdjson::to_json_string(v.get_object()));

velox/functions/prestosql/JsonFunctions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ struct JsonSizeFunction {
303303
case simdjson::ondemand::json_type::null:
304304
singleResultSize = 0;
305305
break;
306+
case simdjson::ondemand::json_type::unknown: {
307+
return simdjson::INCORRECT_TYPE;
308+
}
306309
}
307310
}
308311
return simdjson::SUCCESS;

velox/functions/prestosql/benchmarks/JsonExprBenchmark.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ struct SimdjsonParseFunction {
243243
} else {
244244
SIMDJSON_ASSIGN_OR_RAISE(auto doc, simdjsonParse(paddedJson));
245245
// Parse paddedJson again.
246-
simdjsonParse(paddedJson).get(jsonDoc);
246+
std::ignore = simdjsonParse(paddedJson).get(jsonDoc);
247247
}
248248
result = true;
249249
return simdjson::SUCCESS;

velox/functions/prestosql/tests/JsonCastTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,12 +1122,12 @@ TEST_F(JsonCastTest, toDouble) {
11221122
JSON(),
11231123
DOUBLE(),
11241124
{"Infinity"_sv},
1125-
"The JSON document has an improper structure");
1125+
"The JSON element does not have the requested type");
11261126
testThrow<JsonNativeType>(
11271127
JSON(),
11281128
DOUBLE(),
11291129
{"NaN"_sv},
1130-
"The JSON document has an improper structure");
1130+
"The JSON element does not have the requested type");
11311131

11321132
testThrow<JsonNativeType>(
11331133
JSON(),

velox/functions/prestosql/tests/JsonFunctionsTest.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ TEST_F(JsonFunctionsTest, jsonParse) {
310310
R"([{"response":"[\"fusil a peinture\",\"�uD83E\\uDE2Dau bois\"]"}])");
311311

312312
VELOX_ASSERT_THROW(
313-
jsonParse(R"({"k1":})"), "The JSON document has an improper structure");
313+
jsonParse(R"({"k1":})"),
314+
"The JSON element does not have the requested type");
314315
VELOX_ASSERT_THROW(
315316
jsonParse(R"({:"k1"})"), "The JSON document has an improper structure");
316317
// The exact exception message can change based on the simdjson version used.

0 commit comments

Comments
 (0)