在java bigquery API中使用标准的SQL查询 [英] Use standard SQL queries in java bigquery API

查看:679
本文介绍了在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

com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request "message" : "11.3 - 11.56: Unrecognized type FLOAT64"


推荐答案

<有两种使用BigQuery Java API的标准SQL的方法。第一个是用 #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查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆