code: def test_struct_unnesting() -> None:
      df_base = pl.DataFrame({"a": [1, 2]})
      df = df_base.select(
          [
              pl.all().alias("a_original"),
              pl.col("a")
              .map_elements(
                  lambda x: {"a": x, "b": x * 2, "c": x % 2 == 0}
              )
              .struct.rename_fields(["a", "a_squared", "mod2eq0"])
              .alias("foo"),
          ]
      )
      expected = pl.DataFrame(
          {
              "a_original": [1, 2],
              "a": [1, 2],
              "a_squared": [2, 4],
              "mod2eq0": [False, True],
          }
      )
      for cols in ("foo", cs.ends_with("oo")):
          out_eager = df.unnest(cols)  # type: ignore[arg-type]
          assert_frame_equal(out_eager, expected)
  
          out_lazy = df.lazy().unnest(cols)  # type: ignore[arg-type]
          assert_frame_equal(out_lazy, expected.lazy())
  
      out = (
          df_base.lazy()
          .select(
              [
                  pl.all().alias("a_original"),
                  pl.col("a")
                  .map_elements(
                      lambda x: {"a": x, "b": x * 2, "c": x % 2 == 0}
                  )
                  .struct.rename_fields(["a", "a_squared", "mod2eq0"])
                  .alias("foo"),
              ]
          )
          .unnest("foo")
          .collect()
      )
      assert_frame_equal(out, expected)
  
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 6 for calling a global function with example usage: test_struct_unnesting() without return types