Skip to content
Draft

testing #1544

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
2 changes: 2 additions & 0 deletions google/cloud/odbc/bq_client_interface/odbc_bq_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "google/cloud/odbc/bq_client_interface/datasets.h"
#include "google/cloud/odbc/bq_client_interface/jobs.h"
#include "google/cloud/odbc/bq_client_interface/odbc_authentication.h"
#include "google/cloud/odbc/bq_client_interface/setenv.h"
#include "google/cloud/odbc/bq_client_interface/projects.h"
#include "google/cloud/odbc/bq_client_interface/storage.h"
#include "google/cloud/odbc/bq_client_interface/tables.h"
Expand Down Expand Up @@ -292,6 +293,7 @@ StatusRecordOr<std::shared_ptr<ODBCBQClient>> ODBCBQClient::CreateBQClient(
read_options.set<google::cloud::GrpcCredentialOption>(ssl_creds);
}
#endif
SetEnv("GRPC_DNS_RESOLVER", "native");
BigQueryReadClient bigquery_read_client =
BigQueryReadClient(MakeBigQueryReadConnection(read_options));

Expand Down
37 changes: 36 additions & 1 deletion google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
// limitations under the License.

#include "google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.h"
#include "google/cloud/odbc/bq_client_interface/setenv.h"
#include "google/cloud/odbc/bq_client_interface/utils.h"
#include "google/cloud/odbc/bq_driver/internal/odbc_internal_commons.h"
#include "google/cloud/odbc/bq_driver/internal/trace_utils.h"
#include <thread>
#include <cstdlib>

//////////////////////////////////////////////////////////////////
// This file has query execution related utilities which can have
Expand Down Expand Up @@ -47,6 +49,13 @@ using google::cloud::odbc_bq_driver_internal::StatementHandle;
using google::cloud::odbc_internal::SQLStates;
using chrono_ms = std::chrono::milliseconds;

#if (!defined(_WIN32) || defined(_WIN64)) && !defined(NO_ARROW)
bool IsGrpcDnsResolverError(StatusRecord const& status) {
return status.message.find("hostname lookup error") != std::string::npos ||
status.message.find("DNS query cancelled") != std::string::npos;
}
#endif // (!defined(_WIN32) || defined(_WIN64)) && !defined(NO_ARROW)

StatusRecord ConstructPositionalQueryParams(
DescriptorHandle& apd, DescriptorHandle& ipd,
std::vector<QueryParameter>& basic_query_params, bool is_data_buff_req) {
Expand Down Expand Up @@ -596,7 +605,20 @@ StatusRecord FetchBQDataReadArrow(StatementHandle& stmt_handle,
auto read_session_status =
bq_client->CreateReadSession(create_read_session_request, options);
if (!read_session_status) {
return read_session_status.GetStatusRecord();
StatusRecord status = read_session_status.GetStatusRecord();
if (!IsGrpcDnsResolverError(status)) {
return status;
}
#ifdef _WIN32
_putenv_s("GRPC_DNS_RESOLVER", "native");
#else
setenv("GRPC_DNS_RESOLVER", "native", 1);
#endif
read_session_status =
bq_client->CreateReadSession(create_read_session_request, options);
if (!read_session_status) {
return read_session_status.GetStatusRecord();
}
}

auto session = *read_session_status;
Expand Down Expand Up @@ -624,6 +646,19 @@ StatusRecord FetchBQDataReadArrow(StatementHandle& stmt_handle,
read_rows_stream =
bq_client->GetReadRowsStream(read_rows_request, options);
stmt_handle.SetReadRowsStream(std::move(read_rows_stream));
StatusRecord status = ReadNextResultsFromStream(stmt_handle);
if (status.ok() || !IsGrpcDnsResolverError(status)) {
return status;
}
#ifdef _WIN32
_putenv_s("GRPC_DNS_RESOLVER", "native");
#else
setenv("GRPC_DNS_RESOLVER", "native", 1);
#endif
stmt_handle.ClearReadRowsStream();
stmt_handle.ClearReadRowsIterator();
read_rows_stream = bq_client->GetReadRowsStream(read_rows_request, options);
stmt_handle.SetReadRowsStream(std::move(read_rows_stream));
return ReadNextResultsFromStream(stmt_handle);
}

Expand Down
Loading