Skip to content
Closed
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
12 changes: 3 additions & 9 deletions google/cloud/odbc/bq_driver/internal/odbc_sql_columns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,7 @@ using ::google::cloud::odbc_internal::SQLStates;
using ::google::cloud::odbc_internal::StatusRecord;
using ::google::cloud::odbc_internal::StatusRecordOr;

namespace {

inline bool IsTableNotFound(StatusRecord const& status) {
return status.native_error_code == 404;
}

} // namespace
namespace {} // namespace

StatusRecord CreateResultSetRowSchema(ResultSet& result_set) {
for (auto const& entry : kODBCColumnsMap) {
Expand Down Expand Up @@ -504,8 +498,8 @@ StatusRecordOr<std::vector<Table>> FetchBQTablesData(

if (IsTableNotFound(status)) {
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
26 changes: 17 additions & 9 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,15 @@ StatusRecordOr<std::vector<std::string>> GetFilteredDatasetIds(
StatusRecordOr<std::vector<ListFormatDataset>> datasets =
bq_client.FilterDatasets(project_id, filter, options);
if (!datasets) {
LOG(ERROR) << "GetFilteredDatasetIds::FilterDatasets:: "
<< datasets.GetStatusRecord().message;
return datasets.GetStatusRecord();
auto const& status = datasets.GetStatusRecord();
if (IsTableNotFound(status)) {
LOG(WARNING)
<< "GetFilteredDatasetIds:: Skipping project (not found or access "
<< "denied): '" << project_id << "': " << status.message;
return std::vector<std::string>{};
}
LOG(ERROR) << "GetFilteredDatasetIds::FilterDatasets:: " << status.message;
return status;
}
for (auto const& dataset : *datasets) {
if ((!metadata_id && datasets_filter == "%") ||
Expand Down Expand Up @@ -244,12 +250,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 (IsTableNotFound(status)) {
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
4 changes: 4 additions & 0 deletions google/cloud/odbc/bq_driver/internal/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,10 @@ odbc_internal::StatusRecordOr<SQLUINTEGER> ParseStringToInteger(
std::string const& input);

std::string GetLocationfromPSC(std::string const& psc);

inline bool IsTableNotFound(odbc_internal::StatusRecord const& status) {
return status.native_error_code == 404 || status.native_error_code == 403;
}
} // namespace google::cloud::odbc_bq_driver_internal

#endif // CPP_BIGQUERY_ODBC_GOOGLE_CLOUD_ODBC_BQ_DRIVER_INTERNAL_UTILS_H
Loading