2

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"

Elliott Brossard
  • 32,095
  • 2
  • 67
  • 99
DzouSi
  • 361
  • 3
  • 7
  • 21

1 Answers1

5

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);
}
Elliott Brossard
  • 32,095
  • 2
  • 67
  • 99
  • If this solved the problem for you, can you please also [accept the answer](https://stackoverflow.com/help/someone-answers)? Thanks! – Elliott Brossard May 23 '17 at 23:38