@@ -478,16 +478,14 @@ def _build_parameters_dict(
478478
479479 # For batched queries, use unique parameter names per batch item.
480480 if batch_size > 1 :
481- # Extract parameter names from the template using regex.
482- # Batching is only used with table-based query configs
481+ # Batching is only used with table-based query configs.
483482 table_query_configs = (TableFieldsQueryConfig , TableFunctionQueryConfig )
484483 assert isinstance (self ._query_config , table_query_configs )
485- param_names = self ._extract_parameter_names (
486- self . _query_config . where_clause_template )
487- for param_name , val in zip ( param_names , current_values ):
484+ batch_param_dict = self ._build_single_param_dict ( current_values )
485+ # Prefix batch parameters to make them globally unique.
486+ for param_name , val in batch_param_dict . items ( ):
488487 param_dict [f'batch_{ i } _{ param_name } ' ] = val
489488 else :
490- # For single request, use the helper function.
491489 single_param_dict = self ._build_single_param_dict (current_values )
492490 param_dict .update (single_param_dict )
493491
@@ -502,17 +500,15 @@ def _build_single_param_dict(self, values: list[Any]) -> dict[str, Any]:
502500 Returns:
503501 Dictionary mapping parameter names to values
504502 """
505- if isinstance (self ._query_config , TableFieldsQueryConfig ):
506- return {
507- field_name : val
508- for field_name , val in zip (
509- self ._query_config .where_clause_fields , values )
510- }
511- else : # TableFunctionQueryConfig.
512- assert isinstance (self ._query_config , TableFunctionQueryConfig )
513- _ , param_dict = self ._get_unique_template_and_params (
514- self ._query_config .where_clause_template , values )
515- return param_dict
503+ table_query_configs = (TableFieldsQueryConfig , TableFunctionQueryConfig )
504+ if not isinstance (self ._query_config , table_query_configs ):
505+ raise ValueError (
506+ f"Parameter binding not supported for "
507+ f"{ type (self ._query_config ).__name__ } " )
508+
509+ _ , param_dict = self ._get_unique_template_and_params (
510+ self ._query_config .where_clause_template , values )
511+ return param_dict
516512
517513 def _get_unique_template_and_params (
518514 self , template : str , values : list [Any ]) -> tuple [str , dict [str , Any ]]:
0 commit comments