Joyce
Joyce

Reputation: 1451

how to use legacySQL to query table with partition column

Currently I am getting a Querying tables partitioned on a field is not supported in Legacy SQL What can I do to use Legacy Sql to query a partitioned table?

Upvotes: 2

Views: 3530

Answers (2)

Ruben Portz
Ruben Portz

Reputation: 334

In the apps script editor you have to state LegacySql to false, for example:

var projectId = 'xxxxxxx';
    
var request = {
  query: 'select * from project.database.table',
  useLegacySql: false
};
var queryResults = BigQuery.Jobs.query(request, projectId);

Upvotes: 0

Elliott Brossard
Elliott Brossard

Reputation: 33745

What can I do to use Legacy Sql to query a partitioned table?

You can't use legacy SQL to query a partitioned table, as the error message says.

I'm using legacy SQL, because this is what our version of composer airflow is on now. airflow 1.9-composer

In most tools that don't provide an explicit option for the query dialect, you can use the #standardSQL shebang, e.g.

#standardSQL
SELECT COUNT(*)
FROM dataset.partitioned_table

Upvotes: 2

Related Questions