+
    nDj}              
       b   ^ RI t ^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RIH
t
Ht  ^ RIHt ]P                  P                  tR&R ltR t]P                  P'                  RRR.4      R	 4       t]P                  P'                  R
]P*                  ! R4      R^34      R 4       tR t]P                  P'                  RRR.4      R 4       tR tR t]P                  P'                  RRR.4      R 4       tR tR t]P                  P'                  RRR.4      R 4       tR t]P                  P'                  RRR.4      R 4       t ]P                  PB                  R 4       t"]P                  PB                  R 4       t#]P                  P'                  R]PH                  ! ]PJ                  ! R4      ^4      ]PH                  ! ]PJ                  ! R4      ]PJ                  ! R4      4      ]PJ                  ! R4      ^28  .4      R 4       t&R t'R t(R  t)R! t*R" t+R# t,R$ t-R% t.R#   ] d    Rt ELi ; i)'    N)tobytes)ArrowInvalidArrowNotImplementedErrorc                 F    ^ RI Hp V! \        P                  ! 4       V 4      # )r   )_get_udf_context)pyarrow._computer   padefault_memory_pool)batch_lengthr   s   & V/data/cameron/venvs/s3viz/lib/python3.14/site-packages/pyarrow/tests/test_substrait.pymock_udf_contextr   &   s    1B224lCC    c                    \         P                  P                  \        V 4      V4      p\        P
                  P                  W2P                  R 7      ;_uu_ 4       pVP                  V4       RRR4       V#   + '       g   i     T# ; i))schemaN)	ospathjoinstrr	   ipcRecordBatchFileWriterr   write_table)tmpdir	file_nametabler   writers   &&&  r   _write_dummy_data_to_diskr   +   s`    77<<FY/D		%	%d<<	%	@	@F5! 
AK 
A	@Ks   A88B		use_threadsTFc                    R pRp\         P                  ! . RO.R.R7      p\        WV4      p\        VP	                  R\
        P                  ! V4      P                  4       4      4      p\         P                  P                  V4      p\        P                  ! WqR7      pVP                  4       p	VP                  R.4      V	P                  R.4      8X  g   Q hR# )ax  
    {
        "version": { "major": 9999 },
        "relations": [
        {"rel": {
            "read": {
            "base_schema": {
                "struct": {
                "types": [
                            {"i64": {}}
                        ]
                },
                "names": [
                        "foo"
                        ]
            },
            "local_files": {
                "items": [
                {
                    "uri_file": "FILENAME_PLACEHOLDER",
                    "arrow": {}
                }
                ]
            }
            }
        }}
        ]
    }
    zread_data.arrowfoonamesFILENAME_PLACEHOLDERr   N               r	   r   r   r   replacepathlibPathas_uri
_substrait_parse_json_plan	substrait	run_queryread_allselect
r   r   substrait_queryr   r   r   querybufreaderres_tbs
   &&        r   test_run_serialized_queryr;   2   s    O< "IHHo&ug6E$V>DO++T 2 9 9 ;= >E --
(
(
/C  >F__F<< FMM5'$::::r   r7   s   buffers   bytesc                    \        V\        P                  \        34      '       gU   R \	        V4       R2p\
        P                  ! \        VR7      ;_uu_ 4        \        P                  ! V4       RRR4       R# Rp\
        P                  ! \        VR7      ;_uu_ 4        \        P                  ! V4       RRR4       R#   + '       g   i     R# ; i  + '       g   i     R# ; i)z)Expected 'pyarrow.Buffer' or bytes, got ''matchNz1ParseFromZeroCopyStream failed for substrait.Plan)
isinstancer	   Bufferbytestypepytestraises	TypeErrorr1   r2   r   )r   r7   msgs   && r   test_run_query_input_typesrH   `   s     ebii/009$u+aH]]9C00& 1 >C	|3	/	/E" 
0	/ 10 
0	/	/s   C!CC	C'	c                     R p \         P                  P                  \        V 4      4      pRp\        P
                  ! \        VR7      ;_uu_ 4        \        P                  ! V4       RRR4       R#   + '       g   i     R# ; i)z2
    {
        "relations": [
        ]
    }
    zPlan has no relationsr>   N)	r	   r/   r0   r   rD   rE   r   r1   r2   )r7   r8   exec_messages      r   test_invalid_planrK   p   sV    E --
(
(
8C*L	|<	8	8C  
9	8	8	8s   A22B	c                    R pRp\         P                  ! . RO.R.R7      p\        WV4      p\        VP	                  R\
        P                  ! V4      P                  4       4      4      p\         P                  P                  \        V4      4      p\        P                  ! WqR7      pVP                  4       p	VP                  R.4      V	P                  R.4      8X  g   Q hR# )a  
    {
        "version": { "major": 9999 },
        "relations": [
        {"rel": {
            "read": {
            "base_schema": {
                "struct": {
                "types": [
                            {"i64": {}}
                        ]
                },
                "names": [
                        "bar"
                        ]
            },
            "local_files": {
                "items": [
                {
                    "uri_file": "FILENAME_PLACEHOLDER",
                    "arrow": {},
                    "metadata" : {
                      "created_by" : {},
                    }
                }
                ]
            }
            }
        }}
        ]
    }
    zbinary_json_data.arrowbarr    r"   r#   Nr$   r*   r5   s
   &&        r   (test_binary_conversion_with_json_optionsrN   }   s    OB )IHHo&ug6E$V>DO++T 2 9 9 ;= >E
--
(
(
8C  >F__F<< FMM5'$::::r   c                 Z    V R V 2pV  F  pVP                  V4      '       g   K   R# 	  R# )#TF)endswith)fnsext_filefn_namesuffixfns   &&&  r   has_functionrW      s3    z7)$F;;v  r   c                      \         P                  P                  4       p \        V R R4      '       g   Q h\        V R R4      '       g   Q hR# )zfunctions_arithmetic.yamladdsumN)r	   r/   get_supported_functionsrW   )supported_functionss    r   test_get_supported_functionsr]      sU    --??A +3U< < < <+3U< < < <r   c                   aaa \         P                  P                  R . RO/4      o\         P                  P                  R . RO/4      o\         P                  ! \         P                  ! R \         P
                  ! 4       4      .4      oVVV3R lpRp\         P                  P                  \        V4      4      p\         P                  P                  W1V R7      pVP                  4       pVS8X  g   Q hR# )xc                    < V '       g   \        R 4      hV ^ ,          R8X  d   VS8X  g   Q hS# V ^,          R8X  d   S# \        R4      h)No names providedt1t2Unrecognized table name	Exception)r!   r   schema_1test_table_1test_table_2s   &&r   table_provider(test_named_table.<locals>.table_provider   sP    /001XX%%%1X566r   a  
    {
        "version": { "major": 9999 },
        "relations": [
        {"rel": {
            "read": {
            "base_schema": {
                "struct": {
                "types": [
                            {"i64": {}}
                        ]
                },
                "names": [
                        "x"
                        ]
            },
            "namedTable": {
                    "names": ["t1"]
            }
            }
        }}
        ]
    }
    rj   r   Nr%   r&   r'   )r(   r)      )r	   Tablefrom_pydictr   fieldint64r/   r0   r   r1   r2   r3   )	r   rj   r6   r8   r9   r:   rg   rh   ri   s	   &     @@@r   test_named_tablers      s    88''i(89L88''i(89Lyy"((3
345H	7O2 --
(
()A
BC\\## $ EF__F\!!!r   c                  b  a \         P                  P                  R . RO/4      oV3R lp Rp\         P                  P	                  \        V4      4      pRp\        P                  ! \        VR7      ;_uu_ 4        \        P                  ! W R7       RRR4       R#   + '       g   i     R# ; i)r_   c                 `   < V '       g   \        R 4      hV ^ ,          R8X  d   S# \        R4      hra   rb   rd   re   r!   _rh   s   &&r   rj   ;test_named_table_invalid_table_name.<locals>.table_provider   0    /001X566r   a  
    {
        "version": { "major": 9999 },
        "relations": [
        {"rel": {
            "read": {
            "base_schema": {
                "struct": {
                "types": [
                            {"i64": {}}
                        ]
                },
                "names": [
                        "x"
                        ]
            },
            "namedTable": {
                    "names": ["t3"]
            }
            }
        }}
        ]
    }
    zInvalid NamedTable Sourcer>   rj   Nrm   )r	   ro   rp   r/   r0   r   rD   rE   r   r1   r2   )rj   r6   r8   rJ   rh   s       @r   #test_named_table_invalid_table_namer|      sv    88''i(89L7O2 --
(
()A
BC.L	|<	8	8C? 
9	8	8	8s   ;BB.	c                  x  a \         P                  P                  R . RO/4      oV3R lp Rp\        V4      p\         P                  P                  \        V4      4      pRp\        P                  ! \        VR7      ;_uu_ 4        \        P                  ! W0R7       RRR4       R#   + '       g   i     R# ; i)r_   c                 `   < V '       g   \        R 4      hV ^ ,          R8X  d   S# \        R4      hrv   re   rw   s   &&r   rj   4test_named_table_empty_names.<locals>.table_provider  rz   r   a  
    {
        "version": { "major": 9999 },
        "relations": [
        {"rel": {
            "read": {
            "base_schema": {
                "struct": {
                "types": [
                            {"i64": {}}
                        ]
                },
                "names": [
                        "x"
                        ]
            },
            "namedTable": {
                    "names": []
            }
            }
        }}
        ]
    }
    z!names for NamedTable not providedr>   r{   Nrm   )r	   ro   rp   r   r/   r0   rD   rE   r   r1   r2   )rj   r6   r7   r8   rJ   rh   s        @r   test_named_table_empty_namesr     s    88''i(89L7O0 O$E
--
(
(
8C6L	|<	8	8C? 
9	8	8	8s   B((B9	c           	      j  a
 \         P                  P                  R . RO/4      o
V
3R lpRp\         P                  P	                  V4      p\         P
                  P                  WBVR7      pVP                  4       pV w  rxS
P                  ^RV! \        ^
4      S
R ,          4      4      p	Wi8X  g   Q hR# )r_   c                 `   < V '       g   \        R 4      hV ^ ,          R8X  d   S# \        R4      hrv   re   r!   rx   
test_tables   &&r   rj   .test_udf_via_substrait.<locals>.table_providerJ  0    /001X566r   s	  
    {
  "extensionUris": [
    {
      "extensionUriAnchor": 1
    },
    {
      "extensionUriAnchor": 2,
      "uri": "urn:arrow:substrait_simple_extension_function"
    }
  ],
  "extensions": [
    {
      "extensionFunction": {
        "extensionUriReference": 2,
        "functionAnchor": 1,
        "name": "y=x+1"
      }
    }
  ],
  "relations": [
    {
      "root": {
        "input": {
          "project": {
            "common": {
              "emit": {
                "outputMapping": [
                  1,
                  2,
                ]
              }
            },
            "input": {
              "read": {
                "baseSchema": {
                  "names": [
                    "t",
                  ],
                  "struct": {
                    "types": [
                      {
                        "i64": {
                          "nullability": "NULLABILITY_REQUIRED"
                        }
                      },
                    ],
                    "nullability": "NULLABILITY_REQUIRED"
                  }
                },
                "namedTable": {
                  "names": [
                    "t1"
                  ]
                }
              }
            },
            "expressions": [
              {
                "selection": {
                  "directReference": {
                    "structField": {}
                  },
                  "rootReference": {}
                }
              },
              {
                "scalarFunction": {
                  "functionReference": 1,
                  "outputType": {
                    "i64": {
                      "nullability": "NULLABILITY_NULLABLE"
                    }
                  },
                  "arguments": [
                    {
                      "value": {
                        "selection": {
                          "directReference": {
                            "structField": {}
                          },
                          "rootReference": {}
                        }
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        "names": [
          "x",
          "y",
        ]
      }
    }
  ]
}
    rl   yNrm   )
r	   ro   rp   r/   r0   r1   r2   r3   
add_columnr   )unary_func_fixturer   rj   r6   r8   r9   r:   functionnameexpected_tbr   s   &&        @r   test_udf_via_substraitr   F  s    %%sI&67J7cOJ --
(
(
9C\\## $ EF__F'NH''3jo1/ 0K   r   c                    a \         P                  P                  R . RO/4      oV3R lp Rp\         P                  P	                  V4      p\
        P                  ! \         P                  4      ;_uu_ 4       p\         P                  P                  W R7       RRR4       R\        XP                  4      9   g   Q hR#   + '       g   i     L.; i)r_   c                 `   < V '       g   \        R 4      hV ^ ,          R8X  d   S# \        R4      hrv   re   r   s   &&r   rj   =test_udf_via_substrait_wrong_udf_name.<locals>.table_provider  r   r   s	  
    {
  "extensionUris": [
    {
      "extensionUriAnchor": 1
    },
    {
      "extensionUriAnchor": 2,
      "uri": "urn:arrow:substrait_simple_extension_function"
    }
  ],
  "extensions": [
    {
      "extensionFunction": {
        "extensionUriReference": 2,
        "functionAnchor": 1,
        "name": "wrong_udf_name"
      }
    }
  ],
  "relations": [
    {
      "root": {
        "input": {
          "project": {
            "common": {
              "emit": {
                "outputMapping": [
                  1,
                  2,
                ]
              }
            },
            "input": {
              "read": {
                "baseSchema": {
                  "names": [
                    "t",
                  ],
                  "struct": {
                    "types": [
                      {
                        "i64": {
                          "nullability": "NULLABILITY_REQUIRED"
                        }
                      },
                    ],
                    "nullability": "NULLABILITY_REQUIRED"
                  }
                },
                "namedTable": {
                  "names": [
                    "t1"
                  ]
                }
              }
            },
            "expressions": [
              {
                "selection": {
                  "directReference": {
                    "structField": {}
                  },
                  "rootReference": {}
                }
              },
              {
                "scalarFunction": {
                  "functionReference": 1,
                  "outputType": {
                    "i64": {
                      "nullability": "NULLABILITY_NULLABLE"
                    }
                  },
                  "arguments": [
                    {
                      "value": {
                        "selection": {
                          "directReference": {
                            "structField": {}
                          },
                          "rootReference": {}
                        }
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        "names": [
          "x",
          "y",
        ]
      }
    }
  ]
}
    r{   NzNo function registeredrm   )r	   ro   rp   r/   r0   rD   rE   ArrowKeyErrorr1   r2   r   value)rj   r6   r8   excinfor   s       @r   %test_udf_via_substrait_wrong_udf_namer     s    %%sI&67J7cOJ --
(
(
9C	r''	(	(G
sB 
)#s7=='9999 
)	(s   8!B??C	c                 f  a \         P                  P                  R . RO/4      oV3R lpRp\         P                  P	                  \        V4      4      p\         P                  P                  W1V R7      pVP                  4       p\         P                  P                  R. RO/4      pWV8X  g   Q hR# )r_   c                    < S# N )r!   r   in_tables   &&r   rj   /test_output_field_names.<locals>.table_provider<  s    r   a  
    {
      "version": { "major": 9999 },
      "relations": [
        {
          "root": {
            "input": {
              "read": {
                "base_schema": {
                  "struct": {
                    "types": [{"i64": {}}]
                  },
                  "names": ["x"]
                },
                "namedTable": {
                  "names": ["t1"]
                }
              }
            },
            "names": ["out"]
          }
        }
      ]
    }
    rl   outNrm   )	r	   ro   rp   r/   r0   r   r1   r2   r3   )r   rj   r6   r8   r9   r:   expectedr   s   &      @r   test_output_field_namesr   8  s    xx##S)$45HO4 --
(
()A
BC\\## $ EF__Fxx##UI$67Hr   c           	      l  a \         P                  P                  R . ROR. ROR. RO/4      oV3R lpRp\         P                  P	                  V4      p\         P
                  P                  W1RR7      pVP                  4       p\         P                  P                  R ^^.RRR	./4      pWV8X  g   Q hR
# )kv1v2c                    < S# r   r   r   s   &&r   rj   7test_scalar_aggregate_udf_basic.<locals>.table_providerk  	    r   s  
{
  "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"
        ]
      }
    }
  ],
}
Frl   v_avgg      @g      @Nr%   r%   r&   r&   )r%   r&   r'   r(   )      ?r   r   r   r	   ro   rp   r/   r0   r1   r2   r3   varargs_agg_func_fixturerj   r6   r8   r9   r:   r   r   s   &      @r   test_scalar_aggregate_udf_basicr   c  s     %%	lD,	#	%J
|Oz --
(
(
9C\\## $ ?F__F((&&aV#s( K
    r   c                 |  a \         P                  P                  R . R
OR. ROR. ROR. RO/4      oV3R lpRp\         P                  P	                  V4      p\         P
                  P                  W1RR7      pVP                  4       p\         P                  P                  R . ROR. ROR. RO/4      pWV8X  g   Q hR	# )tr   r   r   c                    < S# r   r   r   s   &&r   rj   5test_hash_aggregate_udf_basic.<locals>.table_provider  r   r   s  
{
  "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,
                  2
                ]
              }
            },
            "input": {
              "read": {
                "baseSchema": {
                  "names": [
                    "t",
                    "k",
                    "v1",
                    "v2",
                  ],
                  "struct": {
                    "types": [
                      {
                        "i64": {
                          "nullability": "NULLABILITY_REQUIRED"
                        }
                      },
                      {
                        "i64": {
                          "nullability": "NULLABILITY_REQUIRED"
                        }
                      },
                      {
                        "i64": {
                          "nullability": "NULLABILITY_NULLABLE"
                        }
                      },
                      {
                        "fp64": {
                          "nullability": "NULLABILITY_NULLABLE"
                        }
                      }
                    ],
                    "nullability": "NULLABILITY_REQUIRED"
                  }
                },
                "namedTable": {
                  "names": ["t1"]
                }
              }
            },
            "detail": {
              "@type": "/arrow.substrait_ext.SegmentedAggregateRel",
              "groupingKeys": [
                {
                  "directReference": {
                    "structField": {
                      "field": 1
                    }
                  },
                  "rootReference": {}
                }
              ],
              "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": 2
                              }
                            },
                            "rootReference": {}
                          }
                        }
                      },
                      {
                        "value": {
                          "selection": {
                            "directReference": {
                              "structField": {
                                "field": 3
                              }
                            },
                            "rootReference": {}
                          }
                        }
                      }
                    ]
                  }
                }
              ]
            }
          }
        },
        "names": [
          "t",
          "k",
          "v_avg"
        ]
      }
    }
  ],
}
Frl   r   N)r%   r%   r%   r%   r&   r&   r&   r&   )r%   r   r   r%   r   r%   r   r%   )r%   r&   r'   r(   r)   rn         )r   r   r   r   g       @g      @g      @g      @r   )r%   r   r   r%   )      @r   g      "@g      &@r   r   s   &      @r   test_hash_aggregate_udf_basicr     s     %%	&	&	'	7	9JNO^ --
(
(
9C\\## $ ?F__F((&&\\&( K    r   exprr_   r   c                    \         P                  ! \         P                  ! R \         P                  ! 4       4      \         P                  ! R\         P                  ! 4       4      .4      p\         P                  P                  V .R.V4      p\         P                  P                  V4      pWP                  8X  g   Q h\        VP                  4      ^8X  g   Q hRVP                  9   g   Q hR# )r_   r   	test_exprN)	r	   r   rq   int32r1   serialize_expressionsdeserialize_expressionslenexpressions)r   r   r8   returneds   &   r   test_serializing_expressionsr     s     YY
bhhj!
bhhj! F
 ,,
,
,dVk]F
KC||33C8H__$$$x##$)))(.....r   c                    a R \         P                  ! R4      ^ 3R\         P                  ! R4      ^ 3R\         P                  ! R4      ^ 3R\         P                  ! 4       ^ 3R\         P                  ! 4       R3R	\         P
                  ! 4       R
3/p \         P                  ! V P                  4        UUUu. uF  w  pw  r#\         P                  ! W4      NK   	  uppp4      oV3R lpV P                  4        F<  w  pw  r%V! \        P                  ! V4      \         P                  ! WRR7      8H  4       K>  	  R# u upppi )time_secondsstime_millisms
time_nanosnsdate_millislarge_stringtest_stringlarge_binarys   test_stringc                    < \         P                  P                  V .R .S4      p\         P                  P                  V4      pSVP                  8X  g   Q hR# r   N)r	   r1   r   r   r   )r   r8   r   r   s   &  r   check_round_trip3test_arrow_specific_types.<locals>.check_round_trip  sE    ll00$+O<<77<(((r   )rC   N)r	   time32time64date64r   r   r   itemsrq   pcscalar)fieldsr   typrx   r   valr   s         @r   test_arrow_specific_typesr     s    3+		$+ryy*		Q'*M:*N;F YY&,,.Q.hs+.QRF)
 #LLNjs$299S+CCD + Rs   5$D:c                    aa \         P                  ! \         P                  ! R \         P                  ! 4       4      \         P                  ! R\         P                  ! 4       4      \         P                  ! R\         P
                  ! \         P                  ! 4       \         P                  ! 4       4      4      \         P                  ! R\         P                  ! \         P                  ! 4       \         P                  ! 4       4      4      .4      o\         P                  ! \         P                  ! R \         P                  ! 4       4      \         P                  ! R\         P                  ! 4       4      \         P                  ! R\         P                  ! 4       4      \         P                  ! R\         P                  ! 4       4      .4      oVV3R lp S F  pV ! V4       K  	  R# )binary_viewstring_view
dictionaryreec                   < \         P                  ! \         P                  ! V P                  4      4      p\        P
                  P                  V.R .S4      p\        P
                  P                  V4      pSVP                  8X  g   Q hR# r   )	r   is_nullrq   r   r	   r1   r   r   r   )rq   r   r8   r   
alt_schemar   s   &   r   check_one_way/test_arrow_one_way_types.<locals>.check_one_way  s`    zz"((5::./ll00$+O<<77<X__,,,r   N)
r	   r   rq   r   r   r   r   stringrun_end_encodedbinary)r   rq   r   r   s     @@r   test_arrow_one_way_typesr     s
   YYHH]BNN$45HH]BNN$45HH\2==RYY[#IJHHUB..rxxz299;GH		
F HH]BIIK0HH]BIIK0HH\299;/HHUBIIK(		
J- e r   c                  r   \         P                  ! \         P                  ! R \         P                  ! 4       4      \         P                  ! R\         P                  ! 4       4      .4      p \        P
                  ! \        P                  ! R 4      ^4      p\        P
                  ! \        P                  ! R4      ^4      p\        P                  ! \        4      ;_uu_ 4       p\         P                  P                  V.. V 4       RRR4       R\        XP                  4      9   g   Q h\        P                  ! \        4      ;_uu_ 4       p\         P                  P                  V.RR.V 4       RRR4       R\        VP                  4      9   g   Q h\        P                  ! \        4      ;_uu_ 4       p\         P                  P                  V.R.V 4       RRR4       R\        VP                  4      9   g   Q hR#   + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     LU; i)	r_   r   zNzneed to have the same lengthr   rM   r   zNo match for FieldRef)r	   r   rq   r   r   equalrD   rE   
ValueErrorr1   r   r   r   )r   r   bad_exprr   s       r   test_invalid_expression_ser_desr     sb   YY
bhhj!
bhhj! F 88BHHSM1%Dxxq)H	z	"	"g
**D62v> 
#)S-????	z	"	"g
**D6E5>6J 
#)S-????	z	"	"g
**H:xH 
#"c'--&8888 
#	"	" 
#	" 
#	"s$   !#G?
%H5$H&?H	H#	&H6	c                  *   \         P                  ! \         P                  ! R \         P                  ! 4       4      \         P                  ! R\         P                  ! 4       4      .4      p \        P
                  ! \        P                  ! R 4      ^4      \        P
                  ! \        P                  ! R 4      \        P                  ! R4      4      .p\         P                  P                  VRR.V 4      p\         P                  P                  V4      pWP                  8X  g   Q h\        VP                  4      ^8X  g   Q h\        P
                  ! \        P                  ! ^ 4      ^4      \        P
                  ! \        P                  ! ^ 4      \        P                  ! ^4      4      .p\        VP                  R,          4      \        V^ ,          4      8X  g   Q h\        VP                  R,          4      \        V^,          4      8X  g   Q hR# )r_   r   firstsecondN)r	   r   rq   r   r   r   r1   r   r   r   r   r   )r   exprsr8   r   
norm_exprss        r   %test_serializing_multiple_expressionsr     sW   YY
bhhj!
bhhj! F XXbhhsmQ'"((3-#)OPE
,,
,
,UWh4G
PC||33C8H__$$$x##$)))((288A;*BHHRXXa["((1+,NOJx##G,-Z]1CCCCx##H-.#jm2DDDDr   c                     \         P                  ! \         P                  ! R \         P                  ! 4       4      \         P                  ! R\         P                  ! 4       4      .4      p \        P
                  ! \        P                  ! R 4      ^4      p\        P
                  ! \        P                  ! ^ 4      ^4      pVP                  V 4      p\         P                  P                  V4      pWP                  8X  g   Q h\        VP                  4      ^8X  g   Q h\        VP                  R,          4      \        V4      8X  g   Q h\         P                  P                  W.RR.V 4      p\        P                  ! \        4      ;_uu_ 4       p\        P                   P#                  V4       RRR4       R\        XP$                  4      9   g   Q h\         P                  P                  V.R.V 4      p\        P                   P#                  V4      p\        V4      \        V4      8X  g   Q hR#   + '       g   i     L; i)r_   r   
expressionr   r   Nzcontained multiple expressions	weirdname)r	   r   rq   r   r   r   to_substraitr1   r   r   r   r   r   rD   rE   r   
Expressionfrom_substraitr   )r   r   	expr_normr8   r   r   expr2s          r   test_serializing_with_computer   	  s   YY
bhhj!
bhhj! F 88BHHSM1%D!a(I


F
#C||33C8H__$$$x##$)))x##L12c)nDDD ,,
,
,d\GX;NPV
WC	z	"	"g
$$S) 
#+s7==/AAAA ,,
,
,dVk]F
KCMM((-Eu:Y''' 
#	"s    H22I	c                     \         P                  ! \         P                  ! R \         P                  ! 4       4      .4      p \        P
                  ! ^
4      p\        P
                  ! ^4      p\        P                  ! W4      .p\        P                  ! \        4      ;_uu_ 4        \         P                  P                  VR.V 4       RRR4       \         P                  P                  VR.V RR7      p\         P                  P                  V4      pWP                  8X  g   Q h\        VP                  4      ^8X  g   Q h\        VP                  R,          4      \        V^ ,          4      8X  g   Q hR#   + '       g   i     L; i)r_   r   NT)allow_arrow_extensions)r	   r   rq   uint32r   r   
shift_leftrD   rE   r   r1   r   r   r   r   r   )r   abr   r8   r   s         r   test_serializing_udfsr   $  s    YY
biik" F 			"A
		!A]]1 !E	/	0	0
**56(FC 
1 ,,
,
,x - >C||33C8H__$$$x##$)))x##F+,E!H=== 
1	0s   %#E66F	c                     R p \         P                  ! \         P                  ! R\         P                  ! 4       4      \         P                  ! R\         P                  ! 4       4      .4      p\         P
                  P                  V 4      pW8X  g   Q h\         P
                  P                  V4      pVP                  V 8X  g   Q h\         P
                  P                  V4      pW8X  g   Q h\         P
                  P                  VP                  4      pW8X  g   Q h\         P
                  P                  VP                  4      pVP                  V8X  g   Q hR# )s   
x
y
*
br_   r   N)
r	   r   rq   r   r   r1   deserialize_schemaserialize_schemar   r   )substrait_schemaexpected_schemar   arrow_substrait_schemas       r   test_serializing_schemar  :  s   Vii
bhhj!
biik"! O ||../?@H&&&\\::8D!((,<<<<||../EFH&&&||../E/L/LMH&&&||334J4U4UVH??o---r   c                       ! R  R4      p Rp\         P                  P                  P                  V ! V4      4      p\	        VP
                  4      ^8X  g   Q hRVP
                  9   g   Q hRVP
                  9   g   Q hR# )c                   ,   a  ] tR tRt o R tR tRtV tR# )7test_bound_expression_from_Message.<locals>.FakeMessageiQ  c                    Wn         R # r   r   )selfr   s   &&r   __init__@test_bound_expression_from_Message.<locals>.FakeMessage.__init__R  s    Ir   c                    V P                   # r   r  )r  s   &r   SerializeToStringItest_bound_expression_from_Message.<locals>.FakeMessage.SerializeToStringU  s    99r   r  N)__name__
__module____qualname____firstlineno__r  r  __static_attributes____classdictcell__)__classdict__s   @r   FakeMessager
  Q  s     		 	r   r  sj   

project_release

 project_version"0
project_version
project_release
:
bproject_releaseproject_versionN)r	   r1   BoundExpressionsr   r   r   )r  messager   s      r   "test_bound_expression_from_Messager  P  sv     AG LL))88W9MNEu  !Q&&& 1 1111 1 1111r   )
   )/r   r,   rD   pyarrowr	   pyarrow.computecomputer   pyarrow.libr   r   r   pyarrow.substraitr1   ImportErrormark
pytestmarkr   r   parametrizer;   	py_bufferrH   rK   rN   rW   r]   rs   r|   r   r   r   r   numpyr   r   r   rq   r   r   r   r   r   r   r   r  r  r   r   r   <module>r,     s_  $ 
      >) [[""
D
 u6*; 7*;Z 2<<	#:Ha"HI# J#
! u6,; 7,;b< u6-" 7-"`'@T'@T u6x! 7x!vs:l u6' 7'T Q! Q!h g! g!T HHRXXc]AHHRXXc]BHHSM*HHSMB" 

/

/E(89(E (6>,.,2e!  Is   H! !	H.-H.