Skip to content
Draft
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
6 changes: 3 additions & 3 deletions google/cloud/odbc/bq_driver/internal/odbc_sql_columns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,10 @@ StatusRecordOr<std::vector<Table>> FetchBQTablesData(
if (!tables_status) {
auto const& status = tables_status.GetStatusRecord();

if (IsTableNotFound(status)) {
if (IsTableNotFound(status) || status.native_error_code == 403) {
LOG(WARNING)
<< "FetchBQTablesData:: Skipping dataset not found or with "
<< "no tables: '" << dataset_task.dataset
<< "FetchBQTablesData:: Skipping inaccessible dataset or one "
<< "with no tables: '" << dataset_task.dataset
<< "': " << status.message;
return batch;
}
Expand Down
25 changes: 17 additions & 8 deletions google/cloud/odbc/bq_driver/internal/odbc_sql_tables.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,16 @@ StatusRecordOr<std::vector<std::string>> GetFilteredDatasetIds(
StatusRecordOr<std::vector<ListFormatDataset>> datasets =
bq_client.FilterDatasets(project_id, filter, options);
if (!datasets) {
auto const& status = datasets.GetStatusRecord();
if (status.native_error_code == 404 || status.native_error_code == 403) {
LOG(WARNING)
<< "GetFilteredDatasetIds:: Skipping project (not found or access "
<< "denied): '" << project_id << "': " << status.message;
return std::vector<std::string>{};
}
LOG(ERROR) << "GetFilteredDatasetIds::FilterDatasets:: "
<< datasets.GetStatusRecord().message;
return datasets.GetStatusRecord();
<< status.message;
return status;
}
for (auto const& dataset : *datasets) {
if ((!metadata_id && datasets_filter == "%") ||
Expand Down Expand Up @@ -244,12 +251,14 @@ StatusRecordOr<std::vector<FilteredTableResponse>> GetFilteredTables(
auto tables_status = bq_client.ListAllTables(project_id, dataset_id, options);
if (!tables_status) {
auto const& status = tables_status.GetStatusRecord();
// A dataset may be deleted between listing datasets and reading its tables;
// treat "not found" as an empty dataset rather than failing the whole call.
if (status.native_error_code == 404) {
LOG(WARNING) << "GetFilteredTables:: Skipping dataset not found: '"
<< project_id << "." << dataset_id
<< "': " << status.message;
// A dataset may be deleted between listing datasets and reading its tables,
// or the user may not have permission to list tables in it. Treat both as
// an empty dataset rather than failing the whole metadata call.
if (status.native_error_code == 404 || status.native_error_code == 403) {
LOG(WARNING)
<< "GetFilteredTables:: Skipping dataset (not found or access "
<< "denied): '" << project_id << "." << dataset_id
<< "': " << status.message;
return std::vector<FilteredTableResponse>{};
}
LOG(ERROR) << "GetFilteredTables::ListAllTables:: " << status.message;
Expand Down
Loading