@@ -203,25 +203,57 @@ struct JsonValue {
203203 static JsonValue MakeArray (JsonArray arr);
204204 static JsonValue MakeObject (JsonObject obj);
205205
206- bool IsNull () const { return type == JsonValueType::JSON_NULL ; }
207- bool IsObject () const { return type == JsonValueType::OBJECT_VAL ; }
208- bool IsArray () const { return type == JsonValueType::ARRAY_VAL ; }
209- bool IsString () const { return type == JsonValueType::STRING_VAL ; }
210- bool IsBool () const { return type == JsonValueType::BOOL_VAL ; }
211- bool IsInt64 () const { return type == JsonValueType::INT64_VAL ; }
212- bool IsUint64 () const { return type == JsonValueType::UINT64_VAL ; }
213- bool IsDouble () const { return type == JsonValueType::DOUBLE_VAL ; }
214- bool IsUninitialized () const { return type == JsonValueType::UNINITIALIZED ; }
206+ bool IsNull () const {
207+ return type == JsonValueType::JSON_NULL ;
208+ }
209+ bool IsObject () const {
210+ return type == JsonValueType::OBJECT_VAL ;
211+ }
212+ bool IsArray () const {
213+ return type == JsonValueType::ARRAY_VAL ;
214+ }
215+ bool IsString () const {
216+ return type == JsonValueType::STRING_VAL ;
217+ }
218+ bool IsBool () const {
219+ return type == JsonValueType::BOOL_VAL ;
220+ }
221+ bool IsInt64 () const {
222+ return type == JsonValueType::INT64_VAL ;
223+ }
224+ bool IsUint64 () const {
225+ return type == JsonValueType::UINT64_VAL ;
226+ }
227+ bool IsDouble () const {
228+ return type == JsonValueType::DOUBLE_VAL ;
229+ }
230+ bool IsUninitialized () const {
231+ return type == JsonValueType::UNINITIALIZED ;
232+ }
215233
216234 JsonObject &AsObject ();
217235 const JsonObject &AsObject () const ;
218- JsonArray &AsArray () { return *array_ptr; }
219- const JsonArray &AsArray () const { return *array_ptr; }
220- const std::string &AsString () const { return string_val; }
221- bool AsBool () const { return primitive.bool_val ; }
222- int64_t AsInt64 () const { return primitive.int64_val ; }
223- uint64_t AsUint64 () const { return primitive.uint64_val ; }
224- double AsDouble () const { return primitive.double_val ; }
236+ JsonArray &AsArray () {
237+ return *array_ptr;
238+ }
239+ const JsonArray &AsArray () const {
240+ return *array_ptr;
241+ }
242+ const std::string &AsString () const {
243+ return string_val;
244+ }
245+ bool AsBool () const {
246+ return primitive.bool_val ;
247+ }
248+ int64_t AsInt64 () const {
249+ return primitive.int64_val ;
250+ }
251+ uint64_t AsUint64 () const {
252+ return primitive.uint64_val ;
253+ }
254+ double AsDouble () const {
255+ return primitive.double_val ;
256+ }
225257};
226258
227259// Insertion-order-preserving JSON object with O(1) key lookup
@@ -232,7 +264,8 @@ class JsonObject {
232264 JsonValue value;
233265 bool deleted;
234266
235- Entry (std::string k, JsonValue v) : key(std::move(k)), value(std::move(v)), deleted(false ) {}
267+ Entry (std::string k, JsonValue v) : key(std::move(k)), value(std::move(v)), deleted(false ) {
268+ }
236269 };
237270
238271 JsonObject () = default ;
@@ -242,8 +275,7 @@ class JsonObject {
242275 RebuildIndex ();
243276 }
244277
245- JsonObject (JsonObject &&other) noexcept
246- : entries_(std::move(other.entries_)), index_(std::move(other.index_)) {
278+ JsonObject (JsonObject &&other) noexcept : entries_(std::move(other.entries_)), index_(std::move(other.index_)) {
247279 }
248280
249281 JsonObject &operator =(const JsonObject &other) {
@@ -306,8 +338,12 @@ class JsonObject {
306338 index_.clear ();
307339 }
308340
309- bool Empty () const { return index_.empty (); }
310- idx_t Size () const { return index_.size (); }
341+ bool Empty () const {
342+ return index_.empty ();
343+ }
344+ idx_t Size () const {
345+ return index_.size ();
346+ }
311347
312348 // Iterate over non-deleted entries (preserves insertion order)
313349 class Iterator {
@@ -316,7 +352,9 @@ class JsonObject {
316352 SkipDeleted ();
317353 }
318354
319- bool operator !=(const Iterator &other) const { return pos_ != other.pos_ ; }
355+ bool operator !=(const Iterator &other) const {
356+ return pos_ != other.pos_ ;
357+ }
320358
321359 Iterator &operator ++() {
322360 ++pos_;
@@ -345,7 +383,9 @@ class JsonObject {
345383 SkipDeleted ();
346384 }
347385
348- bool operator !=(const ConstIterator &other) const { return pos_ != other.pos_ ; }
386+ bool operator !=(const ConstIterator &other) const {
387+ return pos_ != other.pos_ ;
388+ }
349389
350390 ConstIterator &operator ++() {
351391 ++pos_;
@@ -368,10 +408,18 @@ class JsonObject {
368408 idx_t pos_;
369409 };
370410
371- Iterator begin () { return Iterator (&entries_, 0 ); }
372- Iterator end () { return Iterator (&entries_, entries_.size ()); }
373- ConstIterator begin () const { return ConstIterator (&entries_, 0 ); }
374- ConstIterator end () const { return ConstIterator (&entries_, entries_.size ()); }
411+ Iterator begin () {
412+ return Iterator (&entries_, 0 );
413+ }
414+ Iterator end () {
415+ return Iterator (&entries_, entries_.size ());
416+ }
417+ ConstIterator begin () const {
418+ return ConstIterator (&entries_, 0 );
419+ }
420+ ConstIterator end () const {
421+ return ConstIterator (&entries_, entries_.size ());
422+ }
375423
376424private:
377425 void RebuildIndex () {
@@ -388,7 +436,9 @@ class JsonObject {
388436};
389437
390438// JsonValue method implementations (after JsonObject is defined)
391- inline JsonValue::JsonValue () : type(JsonValueType::UNINITIALIZED ) { primitive.int64_val = 0 ; }
439+ inline JsonValue::JsonValue () : type(JsonValueType::UNINITIALIZED ) {
440+ primitive.int64_val = 0 ;
441+ }
392442inline JsonValue::~JsonValue () = default ;
393443
394444inline JsonValue::JsonValue (const JsonValue &other)
@@ -493,13 +543,17 @@ inline JsonValue JsonValue::MakeObject(JsonObject obj) {
493543 return v;
494544}
495545
496- inline JsonObject &JsonValue::AsObject () { return *object_ptr; }
497- inline const JsonObject &JsonValue::AsObject () const { return *object_ptr; }
546+ inline JsonObject &JsonValue::AsObject () {
547+ return *object_ptr;
548+ }
549+ inline const JsonObject &JsonValue::AsObject () const {
550+ return *object_ptr;
551+ }
498552
499553struct JsonGroupMergeState {
500554 JsonObject *result_map;
501555 JsonObject *patch_map;
502- JsonValue *scalar_replacement; // Set when a non-object patch replaces the entire result
556+ JsonValue *scalar_replacement; // Set when a non-object patch replaces the entire result
503557 bool result_has_input;
504558 bool patch_has_input;
505559 bool patch_has_nulls;
@@ -676,8 +730,8 @@ static yyjson_mut_val *BuildYyjsonValue(yyjson_mut_doc *doc, const JsonValue &va
676730}
677731
678732// Apply patch to target map (result_map) - implements JSON merge patch semantics
679- static void ApplyPatchToMap (JsonObject &target, yyjson_val *patch, idx_t depth,
680- JsonNullTreatment null_treatment, bool *saw_nulls) {
733+ static void ApplyPatchToMap (JsonObject &target, yyjson_val *patch, idx_t depth, JsonNullTreatment null_treatment,
734+ bool *saw_nulls) {
681735 if (!patch) {
682736 return ;
683737 }
@@ -704,14 +758,14 @@ static void ApplyPatchToMap(JsonObject &target, yyjson_val *patch, idx_t depth,
704758 *saw_nulls = true ;
705759 }
706760 if (null_treatment == JsonNullTreatment::DELETE_NULLS ) {
707- target.Erase (key); // O(1) average
761+ target.Erase (key); // O(1) average
708762 }
709763 continue ;
710764 }
711765
712766 if (duckdb_yyjson::yyjson_is_obj (patch_val)) {
713767 // Recursive merge for nested objects
714- auto existing = target.Find (key); // O(1) average
768+ auto existing = target.Find (key); // O(1) average
715769 if (existing && existing->IsObject ()) {
716770 // Existing value is object - merge into it
717771 ApplyPatchToMap (existing->AsObject (), patch_val, depth + 1 , null_treatment, saw_nulls);
@@ -728,13 +782,12 @@ static void ApplyPatchToMap(JsonObject &target, yyjson_val *patch, idx_t depth,
728782 }
729783
730784 // For all other types, replace directly
731- target[key] = ParseYyjsonValue (patch_val, depth + 1 ); // O(1) average
785+ target[key] = ParseYyjsonValue (patch_val, depth + 1 ); // O(1) average
732786 }
733787}
734788
735789// Compose patch into patch_map (for DELETE_NULLS mode) - preserves null markers
736- static void ComposePatchToMap (JsonObject &target, yyjson_val *patch, idx_t depth,
737- JsonNullTreatment null_treatment) {
790+ static void ComposePatchToMap (JsonObject &target, yyjson_val *patch, idx_t depth, JsonNullTreatment null_treatment) {
738791 if (!patch) {
739792 return ;
740793 }
@@ -780,8 +833,8 @@ static void ComposePatchToMap(JsonObject &target, yyjson_val *patch, idx_t depth
780833}
781834
782835// Apply JsonObject patch to target map (for Combine)
783- static void ApplyMapToMap (JsonObject &target, const JsonObject &source, idx_t depth,
784- JsonNullTreatment null_treatment, bool *saw_nulls) {
836+ static void ApplyMapToMap (JsonObject &target, const JsonObject &source, idx_t depth, JsonNullTreatment null_treatment,
837+ bool *saw_nulls) {
785838 if (depth > MAX_JSON_NESTING_DEPTH ) {
786839 throw InvalidInputException (" json_group_merge: nesting depth exceeds maximum limit of " +
787840 std::to_string (MAX_JSON_NESTING_DEPTH ));
@@ -1011,8 +1064,8 @@ class JsonGroupMergeFunction {
10111064 if (!doc) {
10121065 throw InternalException (" json_group_merge: failed to allocate output document" );
10131066 }
1014- std::unique_ptr<duckdb_yyjson::yyjson_mut_doc, decltype (&duckdb_yyjson::yyjson_mut_doc_free)>
1015- doc_ptr ( doc, duckdb_yyjson::yyjson_mut_doc_free);
1067+ std::unique_ptr<duckdb_yyjson::yyjson_mut_doc, decltype (&duckdb_yyjson::yyjson_mut_doc_free)> doc_ptr (
1068+ doc, duckdb_yyjson::yyjson_mut_doc_free);
10161069
10171070 duckdb_yyjson::yyjson_mut_val *root;
10181071
@@ -1041,8 +1094,8 @@ class JsonGroupMergeFunction {
10411094 duckdb_yyjson::yyjson_mut_doc_set_root (doc, root);
10421095
10431096 size_t output_length = 0 ;
1044- auto output_cstr = duckdb_yyjson::yyjson_mut_write_opts (doc, JSONCommon:: WRITE_FLAG , nullptr ,
1045- &output_length, nullptr );
1097+ auto output_cstr =
1098+ duckdb_yyjson::yyjson_mut_write_opts (doc, JSONCommon:: WRITE_FLAG , nullptr , &output_length, nullptr );
10461099 if (!output_cstr) {
10471100 throw InternalException (" json_group_merge: failed to serialize aggregate result" );
10481101 }
@@ -1715,8 +1768,8 @@ static void JsonExtractColumnsFunction(DataChunk &args, ExpressionState &state,
17151768 local_state.match_results .clear ();
17161769 pattern_set.Match (key_piece, &local_state.match_results );
17171770
1718- match_chunks = chunked_cache. TryInsert (chunked_set_idx, key_str, key_len, key_hash,
1719- local_state.match_results );
1771+ match_chunks =
1772+ chunked_cache. TryInsert (chunked_set_idx, key_str, key_len, key_hash, local_state.match_results );
17201773
17211774 // If cache insert failed, process directly from match_results
17221775 if (!match_chunks) {
0 commit comments