Repository: risingwavelabs/risingwave
File: src/expr/macro/src/lib.rs (Rust)

Code before:
/// ## Optimization
///
/// When all input and output types of the function are *primitive type* (refer to the [type
/// matrix]) and do not contain any Option or Result, the `#[function]` macro will automatically
/// generate SIMD vectorized execution code.
///
/// Therefore, try to avoid returning `Option` and `Result` whenever possible.
///
/// ## Variadic Function
///
/// Variadic functions accept a `impl Row` input to represent tailing arguments.
/// For example:
///
/// ```ignore
/// #[function("concat_ws(varchar, ...) -> varchar")]
/// fn concat_ws(sep: &str, vals: impl Row) -> Option<Box<str>> {
///     let mut string_iter = vals.iter().flatten();
///     // ...
/// }
/// ```
///
/// See `risingwave_common::row::Row` for more details.
///
/// ## Writer Style Function
///
/// For functions returning [`varchar`, `bytea`, `jsonb`], you can use a writer-style function signature to
/// avoid extra memory allocations and copying.
///
/// ```ignore
/// #[function("trim(varchar) -> varchar")]
/// fn trim(s: &str, writer: &mut impl std::fmt::Write) {
///     writer.write_str(s.trim()).unwrap();
/// }
/// ```
///
/// If the function may return an error, use `Result<()>`:
///
/// ```ignore
/// #[function("trim(varchar) -> varchar")]
/// fn trim(s: &str, writer: &mut impl std::fmt::Write) -> Result<()> {
///     writer.write_str(s.trim()).unwrap();
///     Ok(())
/// }
/// ```
///
/// If the function may return NULL, use `Option<()>`:
///
/// ```ignore
/// #[function("trim(varchar) -> varchar")]
/// fn trim(s: &str, writer: &mut impl std::fmt::Write) -> Option<()> {
///     if s.is_empty() {

Review comment (suggestion):
[nitpick] The documentation uses backticks inconsistently. The original format used backticks around each type name separately (e.g., "`varchar` or `bytea`"), but the update uses a single set of backticks around a comma-separated list. For consistency with the rest of the documentation and better readability, consider using: "For functions returning `varchar`, `bytea`, or `jsonb`, you can use..."
```suggestion
/// For functions returning `varchar`, `bytea`, or `jsonb`, you can use a writer-style function signature to
```

Code after:
/// ## Optimization
///
/// When all input and output types of the function are *primitive type* (refer to the [type
/// matrix]) and do not contain any Option or Result, the `#[function]` macro will automatically
/// generate SIMD vectorized execution code.
///
/// Therefore, try to avoid returning `Option` and `Result` whenever possible.
///
/// ## Variadic Function
///
/// Variadic functions accept a `impl Row` input to represent tailing arguments.
/// For example:
///
/// ```ignore
/// #[function("concat_ws(varchar, ...) -> varchar")]
/// fn concat_ws(sep: &str, vals: impl Row) -> Option<Box<str>> {
///     let mut string_iter = vals.iter().flatten();
///     // ...
/// }
/// ```
///
/// See `risingwave_common::row::Row` for more details.
///
/// ## Writer Style Function
///
/// For functions returning `varchar`, `bytea` or `jsonb`, you can use a writer-style function signature to
/// avoid extra memory allocations and copying.
///
/// ```ignore
/// #[function("trim(varchar) -> varchar")]
/// fn trim(s: &str, writer: &mut impl std::fmt::Write) {
///     writer.write_str(s.trim()).unwrap();
/// }
/// ```
///
/// If the function may return an error, use `Result<()>`:
///
/// ```ignore
/// #[function("trim(varchar) -> varchar")]
/// fn trim(s: &str, writer: &mut impl std::fmt::Write) -> Result<()> {
///     writer.write_str(s.trim()).unwrap();
///     Ok(())
/// }
/// ```
///
/// If the function may return NULL, use `Option<()>`:
///
/// ```ignore
/// #[function("trim(varchar) -> varchar")]
/// fn trim(s: &str, writer: &mut impl std::fmt::Write) -> Option<()> {
///     if s.is_empty() {