Repository: ClickHouse/ClickHouse
File: src/Functions/FunctionsJSON.cpp (C++)

Code before:
                for (size_t i = 0; i < input_rows_count; ++i)
                {
                    if (!literal_subcolumn->isDefaultAt(i))
                        result_col->insertFrom(*literal_subcolumn, i);
                    else if (!sub_object_subcolumn->isDefaultAt(i))
                        result_col->insertFrom(*casted_sub_object, i);
                    else
                        result_col->insertDefault();
                }
                merged = std::move(result_col);
                merged_type = literal_type;
            }

            /// For JSONExtractRaw: serialize each value as a JSON string
            /// using ISerialization::serializeTextJSON.
            constexpr bool is_extract_raw = std::string_view(TName::name) == std::string_view("JSONExtractRaw")
                        || std::string_view(TName::name) == std::string_view("JSONExtractRawCaseInsensitive");

            if constexpr (is_extract_raw)
            {
                auto result_col = ColumnString::create();
                auto serialization = merged_type->getDefaultSerialization();
                for (size_t i = 0; i < input_rows_count; ++i)
                {
                    if (merged->isDefaultAt(i))
                        result_col->insertDefault();
                    else
                    {
                        WriteBufferFromOwnString buf;
                        serialization->serializeTextJSON(*merged, i, buf, format_settings);
                        result_col->insert(buf.str());
                    }
                }
                return result_col;
            }
            else
            {
                /// Cast merged column to the function's return type.
                /// Use accurateCastOrNull to get NULL for failed casts then
                /// replace NULLs with defaults (JSONExtract functions return non-nullable types).
                auto nullable_type = makeNullable(result_type);
                auto casted = castColumnAccurateOrNull({merged, merged_type, ""}, nullable_type);

                if (const auto * nullable_col = typeid_cast<const ColumnNullable *>(casted.get()))
                {
                    const auto & null_map = nullable_col->getNullMapData();
                    const auto & nested = nullable_col->getNestedColumn();
                    auto result_col = result_type->createColumn();
                    for (size_t i = 0; i < input_rows_count; ++i)
                    {
                        if (null_map[i])

Review comment (suggestion):
```suggestion
                    if (merged->isDefaultAt(i))
                    {
                        result_col->insertDefault();
                    }
```

We ususally either use brackets in all branches or in none for better code readability.

Code after:
            }

            /// For JSONExtractRaw: serialize each value as a JSON string
            constexpr bool is_extract_raw = std::string_view(TName::name) == std::string_view("JSONExtractRaw")
                        || std::string_view(TName::name) == std::string_view("JSONExtractRawCaseInsensitive");

            if constexpr (is_extract_raw)
            {
                auto raw_col = ColumnString::create();
                auto serialization = merged_type->getDefaultSerialization();
                for (size_t i = 0; i < input_rows_count; ++i)
                {
                    if (merged->isDefaultAt(i))
                    {
                        raw_col->insertDefault();
                    }
                    else
                    {
                        WriteBufferFromOwnString buf;
                        serialization->serializeTextJSON(*merged, i, buf, format_settings);
                        raw_col->insert(buf.str());
                    }
                }
                return raw_col;
            }
            else
            {
                auto casted = castColumnAccurateOrNull({merged, merged_type, ""}, result_type);
                return result_type->isNullable() ? casted : removeNullable(casted);
            }
        }
    };

private:
    /// Represents a move of a JSON iterator described by a single argument passed to a JSON function.
    /// For example, the call JSONExtractInt('{"a": "hello", "b": [-100, 200.0, 300]}', 'b', 1)
    /// contains two moves: {MoveType::ConstKey, "b"} and {MoveType::ConstIndex, 1}.
    /// Keys and indices can be nonconst, in this case they are calculated for each row.
    enum class MoveType : uint8_t
    {
        Key,
        Index,
        ConstKey,
        ConstIndex,
    };

    struct Move
    {
        explicit Move(MoveType type_, size_t index_ = 0) : type(type_), index(index_) {}
        Move(MoveType type_, const String & key_) : type(type_), key(key_) {}
        MoveType type;