We have a requirement where we need to truncate BQ table from Scala Spark.
The idea behind is that every table column has description attached to it. If we overwrite table, the description no longer persist.
We have explored various option like –
.option("writeDisposition","WRITE_TRUNCATE")
— Unfortunately it didn’t worked 🙁
.mode("overwrite")
— This didn’t preserve the description
import com.google.cloud.spark.bigquery.repackaged.com.google.cloud.bigquery.{BigQueryOptions, TableId}
val bq = BigQueryOptions.getDefaultInstance().getService()
val table = bq.getTable(TableId.of("project_id","dataset","test_write_disposition")
table.delete() -- we have delete option but not truncate
Is there any way to truncate the table in BQ while description or schema properties are preserved ?