google-bigqueryapache-beamapache-beam-iobeam-sql

Delete Big query table using Apache Beam java


Is it possible to delete a table available in bigQuery using Apache beam using Java?

p.apply("Delete Table name", BigQueryIO.readTableRows().fromQuery("DELETE FROM Table_name where condition"));

Solution

  • I resolved this using BQ API.

    BigQuery bigquery = BigQueryOptions.newBuilder().setCredentials(credential).setProjectId(ProjectName).build().getService(); QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(Query).setUseLegacySql(false).build(); JobId jobId = JobId.of(UUID.randomUUID().toString()); Job queryJob = bigquery.create(JobInfo.newBuilder(queryConfig).setJobId(jobId).build());