꽥꽥꽥*_*꽥꽥꽥 4 node.js google-bigquery
在大查询期间,SQL语句中函数的参数我想通过将其作为@变量名插入来更新sql语句的结果。但是,没有方法支持node.js。
对于Python,有类似以下示例的方法。您可以使用函数的参数作为@变量名。
query = "" "
SELECT word, word_count
FROM `bigquery-public-data.samples.shakespeare`
WHERE corpus = @ corpus
AND word_count> = @min_word_count
ORDER BY word_count DESC;"" "
query_params = [
bigquery.ScalarQueryParameter ('corpus', 'STRING', 'romeoandjuliet'),
bigquery.ScalarQueryParameter ('min_word_count', 'INT64', 250)]
job_config = bigquery.QueryJobConfig ()
job_config.query_parameters = query_params
Run Code Online (Sandbox Code Playgroud)
相关文档: https://cloud.google.com/bigquery/docs/parameterized-queries#bigquery-query-params-python
我想请教一下。
小智 13
当您使用选项中的 params 键传递参数化查询时,BigQuery node.js 客户端支持参数化查询。刚刚更新了文档以显示这一点。希望这可以帮助!
例子:
const sqlQuery = `SELECT word, word_count
FROM \`bigquery-public-data.samples.shakespeare\`
WHERE corpus = @corpus
AND word_count >= @min_word_count
ORDER BY word_count DESC`;
const options = {
query: sqlQuery,
// Location must match that of the dataset(s) referenced in the query.
location: 'US',
params: {corpus: 'romeoandjuliet', min_word_count: 250},
};
// Run the query
const [rows] = await bigquery.query(options);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7750 次 |
| 最近记录: |