user_1357
user_1357

Reputation: 7940

BigQuery: DDL statement not executing via client API

I am executing CREATE TABLE IF NOT EXIST via client API using following JobConfigurationQuery:

queryConfig.setUseLegacySql(false)
queryConfig.setFlattenResults(false)
queryConfig.setQuery(query)

As I am executing CREATE TABLE DDL, I cannot specify destination table, write dispositions, etc. In my Query History section of Web UI, I see job being executed successfully without any exceptions, and with no writes happening. Is DDL statement not supported via client API?

I am using following client: "com.google.apis" % "google-api-services-bigquery" % "v2-rev397-1.23.0"

Upvotes: 1

Views: 690

Answers (1)

rtbf
rtbf

Reputation: 1587

From BigQuery docs which says it seems that no error is returned when table exists:

The CREATE TABLE IF NOT EXISTS DDL statement creates a table with the specified options only if the table name does not exist in the dataset. If the table name exists in the dataset, no error is returned, and no action is taken.

Answering your question, DDL is supported from API which is also stated in doc, to do this:

Call the jobs.query method and supply the DDL statement in the request body's query property.

Upvotes: 2

Related Questions