Skip to content

create_named_query

create_named_query(
    name: NameString,
    database: DatabaseString,
    query_string: QueryString,
    *,
    config_overrides: Optional[AthenaClientConfig] = None,
    description: Optional[DescriptionString] = None,
    client_request_token: Optional[IdempotencyToken] = None,
    work_group: Optional[WorkGroupName] = None,
) -> CreateNamedQueryOutput

Creates a named query in the specified workgroup. Requires that you have access to the workgroup.

Parameters:

  • name (NameString) –

    The query name.

  • description (Optional[DescriptionString], default: None ) –

    The query description.

  • database (DatabaseString) –

    The database to which the query belongs.

  • query_string (QueryString) –

    The contents of the query with all query statements.

  • client_request_token (Optional[IdempotencyToken], default: None ) –

    A unique case-sensitive string used to ensure the request to create the query is idempotent (executes only once). If another CreateNamedQuery request is received, the same response is returned and another query is not created. If a parameter has changed, for example, the QueryString, an error is returned.

    This token is listed as not required because Amazon Web Services SDKs (for example the Amazon Web Services SDK for Java) auto-generate the token for users. If you are not using the Amazon Web Services SDK or the Amazon Web Services CLI, you must provide this token or the action will fail.

  • work_group (Optional[WorkGroupName], default: None ) –

    The name of the workgroup in which the named query is being created.

Raises:

  • InternalServerException –

    Indicates a platform issue, which may be due to a transient condition or outage.

  • InvalidRequestException –

    Indicates that something is wrong with the input to the request. For example, a required parameter may be missing or out of range.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_athena/_services/athena.py
def create_named_query(
    self,
    name: "capo_athena.types.name_string.NameString",
    database: "capo_athena.types.database_string.DatabaseString",
    query_string: "capo_athena.types.query_string.QueryString",
    *,
    config_overrides: Optional[AthenaClientConfig] = None,
    description: Optional[
        "capo_athena.types.description_string.DescriptionString"
    ] = None,
    client_request_token: Optional[
        "capo_athena.types.idempotency_token.IdempotencyToken"
    ] = None,
    work_group: Optional["capo_athena.types.work_group_name.WorkGroupName"] = None,
) -> "capo_athena.types.create_named_query_output.CreateNamedQueryOutput":
    """<p>Creates a named query in the specified workgroup. Requires that you have access to the workgroup.</p>

    Args:
        name: <p>The query name.</p>
        description: <p>The query description.</p>
        database: <p>The database to which the query belongs.</p>
        query_string: <p>The contents of the query with all query statements.</p>
        client_request_token: <p>A unique case-sensitive string used to ensure the request to create the query is idempotent (executes only once). If another <code>CreateNamedQuery</code> request is received, the same response is returned and another query is not created. If a parameter has changed, for example, the <code>QueryString</code>, an error is returned.</p> <important> <p>This token is listed as not required because Amazon Web Services SDKs (for example the Amazon Web Services SDK for Java) auto-generate the token for users. If you are not using the Amazon Web Services SDK or the Amazon Web Services CLI, you must provide this token or the action will fail.</p> </important>
        work_group: <p>The name of the workgroup in which the named query is being created.</p>

    Raises:
        capo_athena.errors.internal_server_exception.InternalServerException: <p>Indicates a platform issue, which may be due to a transient condition or outage.</p>
        capo_athena.errors.invalid_request_exception.InvalidRequestException: <p>Indicates that something is wrong with the input to the request. For example, a required parameter may be missing or out of range.</p>
        capo_athena.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_athena.types.create_named_query_input.CreateNamedQueryInput]",
    ) -> OperationResponse[
        "capo_athena.types.create_named_query_output.CreateNamedQueryOutput"
    ]:
        import capo_athena._operations.amazon_athena.create_named_query

        output, http_response = (
            capo_athena._operations.amazon_athena.create_named_query.create_named_query(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateNamedQuery")
    )
    input_: capo_athena.types.create_named_query_input.CreateNamedQueryInput = {
        "name": name,
        "database": database,
        "query_string": query_string,
    }
    if description is not None:
        input_["description"] = description
    if client_request_token is None:
        client_request_token = str(uuid.uuid4())
    input_["client_request_token"] = client_request_token
    if work_group is not None:
        input_["work_group"] = work_group

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output