code: def test_struct_name_passed_in_agg_apply() -> None:
      struct_expr = pl.struct(
          [
              pl.col("A").min(),
              pl.col("B").search_sorted(pl.Series([3, 4])),
          ]
      ).alias("index")
  
      assert pl.DataFrame(
          {"A": [1, 2, 3], "B": [4, 5, 6], "C": [1, 2, 2]}
      ).group_by("C").agg(struct_expr).sort(
          "C", descending=True
      ).to_dict(
          as_series=False
      ) == {
          "C": [2, 1],
          "index": [
              [{"A": 2, "B": 0}, {"A": 2, "B": 0}],
              [{"A": 1, "B": 0}, {"A": 1, "B": 0}],
          ],
      }
  
      df = pl.DataFrame({"val": [-3, -2, -1, 0, 1, 2, 3], "k": [0] * 7})
  
      assert df.group_by("k").agg(
          pl.struct(
              pl.col("val")
              .value_counts(sort=True)
              .struct.field("val")
              .alias("val"),
              pl.col("val")
              .value_counts(sort=True)
              .struct.field("count")
              .alias("count"),
          )
      ).to_dict(as_series=False) == {
          "k": [0],
          "val": [
              [
                  {"val": -3, "count": 1},
                  {"val": -2, "count": 1},
                  {"val": -1, "count": 1},
                  {"val": 0, "count": 1},
                  {"val": 1, "count": 1},
                  {"val": 2, "count": 1},
                  {"val": 3, "count": 1},
              ]
          ],
      }
  
imports: from __future__ import annotations
  from dataclasses import dataclass
  from datetime import datetime, time
  from typing import TYPE_CHECKING
  import pandas
  import pyarrow
  import pytest
  import polars
  import polars.selectors
  from polars.testing import assert_frame_equal, assert_series_equal
label_desc: Use image node_id 44 for calling a global function with example usage: test_struct_name_passed_in_agg_apply() without return types