Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/src/main/sphinx/connector/bigquery.rst
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ BigQuery database. In addition to the
the following features:

* :doc:`/sql/insert`
* :doc:`/sql/truncate`
* :doc:`/sql/create-table`
* :doc:`/sql/create-table-as`
* :doc:`/sql/drop-table`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,21 @@ public void dropTable(ConnectorSession session, ConnectorTableHandle tableHandle
client.dropTable(tableId);
}

@Override
public void truncateTable(ConnectorSession session, ConnectorTableHandle tableHandle)
{
BigQueryTableHandle table = (BigQueryTableHandle) tableHandle;
BigQueryClient client = bigQueryClientFactory.createBigQueryClient(session);

RemoteTableName remoteTableName = table.asPlainTable().getRemoteTableName();
String sql = format(
"TRUNCATE TABLE %s.%s.%s",
quote(remoteTableName.getProjectId()),
quote(remoteTableName.getDatasetName()),
quote(remoteTableName.getTableName()));
client.executeUpdate(QueryJobConfiguration.of(sql));
}

@Override
public ConnectorInsertTableHandle beginInsert(ConnectorSession session, ConnectorTableHandle tableHandle, List<ColumnHandle> columns, RetryMode retryMode)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
case SUPPORTS_NOT_NULL_CONSTRAINT:
return false;

case SUPPORTS_TRUNCATE:
return true;

case SUPPORTS_NEGATIVE_DATE:
return false;

Expand Down