1

The Python SDK for BigQuery components shows an option for passing query_parameters to the BigqueryCreateModelJobOp PipelineTask. This task shows that it expects a list. I can't find any example of how to specify parameters as a list here. For a specific example:

BigqueryCreateModelJobOp(
                    project="silly-demo-project",
                    location="country-region1",
                    query="SELECT * FROM {{ params.table }}",
                    query_parameters=["table=silly-demo-project.dataset.cooltable"]
                )

The above doesn't work - so what should query_parameters look like here?

Paco
  • 443
  • 3
  • 10
  • What error are you catching? Also I looked in to a bit to Google's documentation this line of code might be a good reference: https://github.com/googleapis/python-bigquery/blob/35627d145a41d57768f19d4392ef235928e00f72/samples/client_query_w_named_params.py#L32C1-L32C1 – Nestor Ceniza Jr Aug 22 '23 at 21:26
  • I'm getting a JSON decode error. Looking at the `google-cloud-pipeline-components` that defines the Task, it's expecting a string that embeds into another JSON string. That link is what I think may be expected, but considering the task is defined in a Kubeflow Pipeline, and so the query parameters may some from output of preceeding tasks, it doesn't seem correct. – Paco Aug 23 '23 at 14:22

1 Answers1

1

As I know, there is no standard BigQueryCreateModelJobOp class or method format in the standard Python libraries or Google Cloud Vertex libraries. The query\_parameters parameter should be a list of dictionaries, with each dictionary containing details about the query parameter, such as its name, type, and value.

query_parameters = [
    {
        "name": "table",
        "parameterType": {"type": "STRING"},
        "parameterValue": {"value": "silly-demo-project.dataset.cooltable"}
    }
]

bigquery_task = BigqueryCreateModelJobOp(
    project="silly-demo-project",
    location="country-region1",
    query="SELECT * FROM {{ params.table }}",
    query_parameters=query_parameters
)

Remember, the specific structure of the query_parameters dictionary may vary based on the requirements of the library you're using.

Poala Astrid
  • 1,028
  • 2
  • 10