Use standard SQL queries in java bigquery API

孤街浪徒 提交于 2019-12-02 06:24:57

问题


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 Bad Request "message" : "11.3 - 11.56: Unrecognized type FLOAT64"


回答1:


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;

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);
}


来源:https://stackoverflow.com/questions/44146438/use-standard-sql-queries-in-java-bigquery-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!