code: def test_scalar_aggregate_udf_basic(varargs_agg_func_fixture):
      test_table = pa.Table.from_pydict(
          {
              "k": [1, 1, 2, 2],
              "v1": [1, 2, 3, 4],
              "v2": [1.0, 1.0, 1.0, 1.0],
          }
      )
  
      def table_provider(names, _):
          return test_table
  
      substrait_query = b"""
  {
    "extensionUris": [
      {
        "extensionUriAnchor": 1,
        "uri": "urn:arrow:substrait_simple_extension_function"
      },
    ],
    "extensions": [
      {
        "extensionFunction": {
          "extensionUriReference": 1,
          "functionAnchor": 1,
          "name": "sum_mean"
        }
      }
    ],
    "relations": [
      {
        "root": {
          "input": {
            "extensionSingle": {
              "common": {
                "emit": {
                  "outputMapping": [
                    0,
                    1
                  ]
                }
              },
              "input": {
                "read": {
                  "baseSchema": {
                    "names": [
                      "k",
                      "v1",
                      "v2",
                    ],
                    "struct": {
                      "types": [
                        {
                          "i64": {
                            "nullability": "NULLABILITY_REQUIRED"
                          }
                        },
                        {
                          "i64": {
                            "nullability": "NULLABILITY_NULLABLE"
                          }
                        },
                        {
                          "fp64": {
                            "nullability": "NULLABILITY_NULLABLE"
                          }
                        }
                      ],
                      "nullability": "NULLABILITY_REQUIRED"
                    }
                  },
                  "namedTable": {
                    "names": ["t1"]
                  }
                }
              },
              "detail": {
                "@type": "/arrow.substrait_ext.SegmentedAggregateRel",
                "segmentKeys": [
                  {
                    "directReference": {
                      "structField": {}
                    },
                    "rootReference": {}
                  }
                ],
                "measures": [
                  {
                    "measure": {
                      "functionReference": 1,
                      "phase": "AGGREGATION_PHASE_INITIAL_TO_RESULT",
                      "outputType": {
                        "fp64": {
                          "nullability": "NULLABILITY_NULLABLE"
                        }
                      },
                      "arguments": [
                        {
                          "value": {
                            "selection": {
                              "directReference": {
                                "structField": {
                                  "field": 1
                                }
                              },
                              "rootReference": {}
                            }
                          }
                        },
                        {
                          "value": {
                            "selection": {
                              "directReference": {
                                "structField": {
                                  "field": 2
                                }
                              },
                              "rootReference": {}
                            }
                          }
                        }
                      ]
                    }
                  }
                ]
              }
            }
          },
          "names": [
            "k",
            "v_avg"
          ]
        }
      }
    ],
  }
  """
      buf = pa._substrait._parse_json_plan(substrait_query)
      reader = pa.substrait.run_query(
          buf, table_provider=table_provider, use_threads=False
      )
      res_tb = reader.read_all()
  
      expected_tb = pa.Table.from_pydict(
          {"k": [1, 2], "v_avg": [2.5, 4.5]}
      )
  
      assert res_tb == expected_tb
  
imports: import os
  import pathlib
  import pytest
  import pyarrow
  import pyarrow.compute
  from pyarrow.lib import tobytes
  from pyarrow.lib import ArrowInvalid, ArrowNotImplementedError
label_desc: Use image node_id 15 for calling a global function with example usage: test_scalar_aggregate_udf_basic(varargs_agg_func_fixture) and returns: test_table