3232 ),
3333 )
3434
35- For ``StartQueryExecution`` fields that ``AthenaQueryConfig `` does not cover,
36- pass the full request as a dict through ``arguments `` instead; it is emitted
37- unchanged.
35+ Prefer ``AthenaQueryConfig``. For ``StartQueryExecution `` fields it does not
36+ cover, pass the full request as a dict to ``query_config `` instead; the dict
37+ is emitted unchanged.
3838
3939The SageMaker Pipelines service validates the request at ``CreatePipeline``
4040time, not this module:
@@ -178,23 +178,13 @@ def _drop_none(values: Dict[str, Any]) -> Dict[str, Any]:
178178 return {key : value for key , value in values .items () if value is not None }
179179
180180
181- ERR_STR_WITH_BOTH_QUERY_CONFIG_AND_ARGUMENTS = (
182- "AthenaStep {step_name} cannot have both query_config and arguments."
183- )
184-
185- ERR_STR_WITHOUT_QUERY_CONFIG_AND_ARGUMENTS = (
186- "AthenaStep {step_name} must have either query_config or arguments."
187- )
188-
189-
190181class AthenaStep (ConfigurableRetryStep ):
191182 """Runs an Amazon Athena query as part of a SageMaker Pipeline."""
192183
193184 def __init__ (
194185 self ,
195186 name : str ,
196- query_config : Optional [AthenaQueryConfig ] = None ,
197- arguments : Optional [Dict [str , Any ]] = None ,
187+ query_config : Union [AthenaQueryConfig , Dict [str , Any ]],
198188 display_name : Optional [str ] = None ,
199189 description : Optional [str ] = None ,
200190 depends_on : Optional [List [Union [str , Step , StepCollection ]]] = None ,
@@ -203,14 +193,13 @@ def __init__(
203193 ): # pylint: disable=too-many-positional-arguments
204194 """Construct an ``AthenaStep``.
205195
206- Exactly one of ``query_config`` and ``arguments`` must be given.
207-
208196 Args:
209197 name: The name of the step.
210- query_config: The Athena query to run.
211- arguments: The full Athena ``StartQueryExecution`` request as a dict
212- (PascalCase keys), emitted unchanged. Use it for request fields
213- that ``AthenaQueryConfig`` does not cover.
198+ query_config: The Athena query to run. Prefer an
199+ ``AthenaQueryConfig``. Pass the full ``StartQueryExecution``
200+ request as a dict (PascalCase keys) only when you need a field
201+ ``AthenaQueryConfig`` does not cover; the dict is emitted
202+ unchanged.
214203 display_name: Optional display name.
215204 description: Optional description.
216205 depends_on: Optional explicit step dependencies. Wrap an entry in
@@ -228,14 +217,12 @@ def __init__(
228217 retry_policies = retry_policies ,
229218 )
230219
231- if query_config is None and arguments is None :
232- raise ValueError (ERR_STR_WITHOUT_QUERY_CONFIG_AND_ARGUMENTS .format (step_name = name ))
233- if query_config is not None and arguments is not None :
234- raise ValueError (ERR_STR_WITH_BOTH_QUERY_CONFIG_AND_ARGUMENTS .format (step_name = name ))
235-
236220 # Copy so caller-side mutations after construction do not leak into the
237221 # compiled pipeline definition.
238- request = query_config .to_request () if query_config is not None else arguments
222+ if isinstance (query_config , AthenaQueryConfig ):
223+ request = query_config .to_request ()
224+ else :
225+ request = query_config
239226 self .args : Dict [str , Any ] = copy .deepcopy (request )
240227 self .cache_config = cache_config
241228 self ._properties = Properties (
0 commit comments