本文介绍了在 java bigquery API 中使用标准 SQL 查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 java bigquery API 时是否可以使用标准 SQL 查询?我正在尝试执行查询,但它抛出

Is it possible to use standard SQL queries when using java bigquery API?I am trying to execute query but it throws

com.google.api.client.googleapis.json.GoogleJsonResponseException:400 错误请求"message" : "11.3 - 11.56: 无法识别的类型 FLOAT64"

推荐答案

有两种方法可以将标准 SQL 与 BigQuery Java API 结合使用.第一个是用 #standardSQL 开始你的查询文本,例如:

There are two ways to use standard SQL with the BigQuery Java API. The first is to start your query text with #standardSQL, e.g.:

#standardSQL
SELECT ...
FROM YourTable;

第二种是将 useLegacySql 设置为 false 作为 QueryJobConfiguration 对象的一部分.例如(取自 来自文档):

The second is to set useLegacySql to false as part of the QueryJobConfiguration object. For example (taken from the documentation):

public static void runStandardSqlQuery(String queryString)
    throws TimeoutException, InterruptedException {
  QueryJobConfiguration queryConfig =
      QueryJobConfiguration.newBuilder(queryString)
          // To use standard SQL syntax, set useLegacySql to false.
          // See: https://cloud.google.com/bigquery/sql-reference/
          .setUseLegacySql(false)
          .build();

  runQuery(queryConfig);
}

这篇关于在 java bigquery API 中使用标准 SQL 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 11:45
查看更多