5353 Arg ,
5454 Arguments ,
5555 ArgumentValidationError ,
56+ Attach ,
5657 Auth ,
5758 ConstParam ,
5859 OutputLength ,
@@ -97,8 +98,10 @@ class BindResult(ArrowSerializableDataclass):
9798
9899 Attributes:
99100 output_type: Arrow data type for the output value.
100- opaque_data: Optional serialized data, opaque to the caller,
101- that will be passed to `global_init()` and `process()`.
101+ opaque_data: Optional serialized data, opaque to the caller. It is
102+ passed to `global_init()`; a `process()` override can read it as
103+ ``init_call.bind_opaque_data``. `compute()` does not receive it: use
104+ an [`Attach`][vgi.arguments.Attach] parameter for ATTACH options.
102105
103106 """
104107
@@ -894,6 +897,7 @@ def __getattr__(self, _name: str) -> Any:
894897 _secret_params : dict [str , Secret ] # Secret params: param_name -> Secret instance
895898 _output_length_param : str | None # OutputLength param name (batch row count)
896899 _auth_param : str | None # Auth param name (receives AuthContext)
900+ _attach_param : str | None # Attach param name (receives the ATTACH options)
897901 _returns_output_type : pa .DataType | None # Output type from Returns()
898902
899903 def __init_subclass__ (cls , ** kwargs : Any ) -> None :
@@ -951,6 +955,7 @@ def __getattr__(self, name: str) -> Any:
951955 "Setting" : vgi_args .Setting ,
952956 "Secret" : vgi_args .Secret ,
953957 "Auth" : vgi_args .Auth ,
958+ "Attach" : vgi_args .Attach ,
954959 "OutputLength" : vgi_args .OutputLength ,
955960 "Returns" : vgi_args .Returns ,
956961 "AnyArrow" : vgi_args .AnyArrow ,
@@ -968,6 +973,7 @@ def __getattr__(self, name: str) -> Any:
968973 const_scalar_params : set [str ] = set () # ConstParams annotated as pa.Scalar
969974 output_length_param : str | None = None # param that receives batch row count
970975 auth_param : str | None = None # param that receives AuthContext
976+ attach_param : str | None = None # param that receives the ATTACH options
971977 returns_output_type : pa .DataType | None = None
972978
973979 # Check return type for Returns() annotation
@@ -1069,6 +1075,17 @@ def __getattr__(self, name: str) -> Any:
10691075 # Don't increment overall_position - not a call argument
10701076 break
10711077
1078+ # Attach: receives the ATTACH options as a dict
1079+ if isinstance (meta , Attach ):
1080+ if attach_param is not None :
1081+ raise TypeError (
1082+ f"{ cls .__name__ } .compute() has multiple Attach parameters: "
1083+ f"{ attach_param !r} and { name !r} "
1084+ )
1085+ attach_param = name
1086+ # Don't increment overall_position - not a call argument
1087+ break
1088+
10721089 # Extract Setting/Secret params using shared helper
10731090 setting_params , secret_params = _extract_setting_secret_params (compute_method )
10741091
@@ -1079,6 +1096,7 @@ def __getattr__(self, name: str) -> Any:
10791096 cls ._secret_params = secret_params
10801097 cls ._output_length_param = output_length_param
10811098 cls ._auth_param = auth_param
1099+ cls ._attach_param = attach_param
10821100 cls ._returns_output_type = returns_output_type
10831101
10841102 @final
@@ -1132,6 +1150,7 @@ def _extract_compute_kwargs(
11321150 batch : pa .RecordBatch ,
11331151 bind_call : BindRequest ,
11341152 auth_context : AuthContext ,
1153+ attach_plaintext : bytes | None = None ,
11351154 ) -> dict [str , Any ]:
11361155 """Extract columns/values for `compute()` parameters.
11371156
@@ -1142,6 +1161,8 @@ def _extract_compute_kwargs(
11421161 batch: Input RecordBatch.
11431162 bind_call: The BindCall with arguments, settings, and secrets.
11441163 auth_context: Authentication context for the current request.
1164+ attach_plaintext: The worker-unwrapped attach (``uuid || options ||
1165+ catalog bytes``), for an ``Attach()`` parameter; None outside a catalog.
11451166
11461167 Returns:
11471168 Dict mapping parameter names to their resolved values.
@@ -1200,6 +1221,14 @@ def _extract_compute_kwargs(
12001221 if cls ._auth_param is not None :
12011222 kwargs [cls ._auth_param ] = auth_context
12021223
1224+ # Attach param: the ATTACH options, read from the unwrapped attach exactly
1225+ # as BindParameters.attach_options reads them at bind.
1226+ if cls ._attach_param is not None :
1227+ from vgi .catalog .attach_option import attach_options
1228+ from vgi .function_storage import attach_catalog_bytes
1229+
1230+ kwargs [cls ._attach_param ] = attach_options (attach_catalog_bytes (attach_plaintext ))
1231+
12031232 return kwargs
12041233
12051234 @final
@@ -1333,7 +1362,12 @@ def process(
13331362 output_schema = init_call .output_schema
13341363
13351364 # Extract columns for keyword-only parameters
1336- kwargs = cls ._extract_compute_kwargs (batch , init_call .bind_call , auth_context )
1365+ kwargs = cls ._extract_compute_kwargs (
1366+ batch ,
1367+ init_call .bind_call ,
1368+ auth_context ,
1369+ getattr (storage , "_attach_plaintext" , None ),
1370+ )
13371371
13381372 # Validate input types match declared Param types
13391373 cls ._validate_param_types (kwargs )
0 commit comments