From 7c81814a1e7545d2889e0b8d55d8e2fb2acb9f38 Mon Sep 17 00:00:00 2001 From: Anshu6250 Date: Sun, 31 May 2026 22:09:42 +0530 Subject: [PATCH 1/9] test --- google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc b/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc index 69618d66f8..98599a3326 100644 --- a/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc +++ b/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc @@ -16,6 +16,7 @@ #include "google/cloud/odbc/bq_driver/internal/data_translation.h" #include "google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.h" #include "google/cloud/odbc/bq_driver/internal/trace_utils.h" +#include namespace google::cloud::odbc_bq_driver_internal { @@ -256,6 +257,11 @@ StatusRecord FetchNextResultSet(StatementHandle& stmt_handle) { } #if (!defined(_WIN32) || defined(_WIN64)) && !defined(NO_ARROW) if (stmt_handle.WasHtapiEnabled()) { +#ifdef _WIN32 + _putenv_s("GRPC_DNS_RESOLVER", "native"); +#else + setenv("GRPC_DNS_RESOLVER", "native", 1); +#endif StatusRecord read_status = ReadNextResultsFromStream(stmt_handle); if (!read_status.ok()) { LOG(ERROR) << "ReadNextResultsFromStream:: " << read_status.message; From e8b3a5d4d4b1fa439593186f37f66d472cbdb6eb Mon Sep 17 00:00:00 2001 From: Anshu6250 Date: Mon, 1 Jun 2026 12:28:20 +0530 Subject: [PATCH 2/9] test --- .../odbc/bq_driver/internal/odbc_sql_fetch.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc b/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc index 98599a3326..33d85017b5 100644 --- a/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc +++ b/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc @@ -257,15 +257,22 @@ StatusRecord FetchNextResultSet(StatementHandle& stmt_handle) { } #if (!defined(_WIN32) || defined(_WIN64)) && !defined(NO_ARROW) if (stmt_handle.WasHtapiEnabled()) { + StatusRecord read_status = ReadNextResultsFromStream(stmt_handle); + if (!read_status.ok()) { + if (read_status.message.find( + "errors resolving bigquerystorage.googleapis.com") != + std::string::npos) { #ifdef _WIN32 - _putenv_s("GRPC_DNS_RESOLVER", "native"); + _putenv_s("GRPC_DNS_RESOLVER", "native"); #else - setenv("GRPC_DNS_RESOLVER", "native", 1); + setenv("GRPC_DNS_RESOLVER", "native", 1); #endif - StatusRecord read_status = ReadNextResultsFromStream(stmt_handle); - if (!read_status.ok()) { - LOG(ERROR) << "ReadNextResultsFromStream:: " << read_status.message; - return read_status; + read_status = ReadNextResultsFromStream(stmt_handle); + } + if (!read_status.ok()) { + LOG(ERROR) << "ReadNextResultsFromStream:: " << read_status.message; + return read_status; + } } } else { StatusRecord read_status = FetchNextPageResultSet(stmt_handle); From 08157d0e531e6d6c695dcdd2be13b5bb02918a4f Mon Sep 17 00:00:00 2001 From: Anshu6250 Date: Mon, 1 Jun 2026 13:45:25 +0530 Subject: [PATCH 3/9] test --- google/cloud/odbc/bq_client_interface/odbc_bq_client.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc b/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc index 7e42ecc02f..e6a0551987 100644 --- a/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc +++ b/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc @@ -17,6 +17,7 @@ #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/projects.h" +#include "google/cloud/odbc/bq_client_interface/setenv.h" #include "google/cloud/odbc/bq_client_interface/storage.h" #include "google/cloud/odbc/bq_client_interface/tables.h" #include "google/cloud/odbc/internal/status_record_or.h" @@ -28,6 +29,7 @@ #include "absl/log/log.h" #include #include +#include namespace google::cloud::odbc_bigquery_client_interface { @@ -155,6 +157,13 @@ google::cloud::ProxyConfig CreateProxyConfig(std::string hostname, StatusRecordOr> ODBCBQClient::CreateBQClient( Oauth const& oauth) { + // The BigQuery Storage API client uses gRPC. On Windows, gRPC's default DNS + // resolver can fail inside host applications such as Power BI with messages + // like "errors resolving bigquerystorage.googleapis.com" and "DNS query + // cancelled". Set the resolver before any gRPC channel is created so the + // BigQuery Read client consistently uses the OS/native DNS resolver. + SetEnv("GRPC_DNS_RESOLVER", "native"); + // 1. Initialize Options and set Proxy/SSL settings FIRST google::cloud::Options options; From dab4a34803da3f825396ff1f9fb1db811db8bac2 Mon Sep 17 00:00:00 2001 From: Anshu6250 Date: Mon, 1 Jun 2026 15:32:08 +0530 Subject: [PATCH 4/9] test --- .../bq_client_interface/odbc_bq_client.cc | 9 ------- .../internal/odbc_sql_execute_utils.cc | 24 ++++++++++++++++++- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc b/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc index e6a0551987..7e42ecc02f 100644 --- a/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc +++ b/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc @@ -17,7 +17,6 @@ #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/projects.h" -#include "google/cloud/odbc/bq_client_interface/setenv.h" #include "google/cloud/odbc/bq_client_interface/storage.h" #include "google/cloud/odbc/bq_client_interface/tables.h" #include "google/cloud/odbc/internal/status_record_or.h" @@ -29,7 +28,6 @@ #include "absl/log/log.h" #include #include -#include namespace google::cloud::odbc_bigquery_client_interface { @@ -157,13 +155,6 @@ google::cloud::ProxyConfig CreateProxyConfig(std::string hostname, StatusRecordOr> ODBCBQClient::CreateBQClient( Oauth const& oauth) { - // The BigQuery Storage API client uses gRPC. On Windows, gRPC's default DNS - // resolver can fail inside host applications such as Power BI with messages - // like "errors resolving bigquerystorage.googleapis.com" and "DNS query - // cancelled". Set the resolver before any gRPC channel is created so the - // BigQuery Read client consistently uses the OS/native DNS resolver. - SetEnv("GRPC_DNS_RESOLVER", "native"); - // 1. Initialize Options and set Proxy/SSL settings FIRST google::cloud::Options options; diff --git a/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc b/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc index a4480d7f6d..72553a473a 100644 --- a/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc +++ b/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc @@ -16,6 +16,7 @@ #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 #include ////////////////////////////////////////////////////////////////// @@ -767,8 +768,29 @@ StatusRecord FetchBQDataRead(StatementHandle& stmt_handle, return StatusRecord{SQLStates::k_HY000(), error_message}; } - return FetchBQDataReadArrow( + StatusRecord read_arrow_status = FetchBQDataReadArrow( stmt_handle, insert_response->configuration.query.destination_table); + if (!read_arrow_status.ok() && + (read_arrow_status.message.find( + "errors resolving bigquerystorage.googleapis.com") != + std::string::npos || + read_arrow_status.message.find("DNS query cancelled") != + std::string::npos)) { + LOG(WARNING) << "FetchBQDataRead:: BigQuery Storage API read failed with " + "a DNS error. Setting GRPC_DNS_RESOLVER=native and " + "retrying HTAPI once: " + << read_arrow_status.message; +#ifdef _WIN32 + _putenv_s("GRPC_DNS_RESOLVER", "native"); +#else + setenv("GRPC_DNS_RESOLVER", "native", 1); +#endif + stmt_handle.ClearReadRowsStream(); + stmt_handle.ClearReadRowsIterator(); + read_arrow_status = FetchBQDataReadArrow( + stmt_handle, insert_response->configuration.query.destination_table); + } + return read_arrow_status; } #endif // (!defined(_WIN32) || defined(_WIN64)) && !defined(NO_ARROW) From 6429536814552c214ba1277d47d092ff4178fdc4 Mon Sep 17 00:00:00 2001 From: Anshu6250 Date: Mon, 1 Jun 2026 16:45:50 +0530 Subject: [PATCH 5/9] test --- .../cloud/odbc/bq_client_interface/odbc_bq_client.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc b/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc index 7e42ecc02f..09c044b795 100644 --- a/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc +++ b/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc @@ -28,6 +28,7 @@ #include "absl/log/log.h" #include #include +#include namespace google::cloud::odbc_bigquery_client_interface { @@ -155,6 +156,15 @@ google::cloud::ProxyConfig CreateProxyConfig(std::string hostname, StatusRecordOr> ODBCBQClient::CreateBQClient( Oauth const& oauth) { + // BigQuery Storage API uses gRPC. Set the DNS resolver before creating any + // gRPC BigQueryReadClient/connection; setting it after a DNS failure is too + // late because the resolver/channel may already be initialized. +#ifdef _WIN32 + _putenv_s("GRPC_DNS_RESOLVER", "native"); +#else + setenv("GRPC_DNS_RESOLVER", "native", 1); +#endif + // 1. Initialize Options and set Proxy/SSL settings FIRST google::cloud::Options options; From 2d4ea3c0dab455117c6d488d9546a4df5f09046a Mon Sep 17 00:00:00 2001 From: Anshu6250 Date: Wed, 3 Jun 2026 11:58:16 +0530 Subject: [PATCH 6/9] test --- .../cloud/odbc/bq_client_interface/odbc_bq_client.cc | 10 +++++----- .../odbc/bq_driver/internal/odbc_sql_execute_utils.cc | 3 ++- google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc b/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc index 09c044b795..364d5b90c8 100644 --- a/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc +++ b/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc @@ -159,11 +159,11 @@ StatusRecordOr> ODBCBQClient::CreateBQClient( // BigQuery Storage API uses gRPC. Set the DNS resolver before creating any // gRPC BigQueryReadClient/connection; setting it after a DNS failure is too // late because the resolver/channel may already be initialized. -#ifdef _WIN32 - _putenv_s("GRPC_DNS_RESOLVER", "native"); -#else - setenv("GRPC_DNS_RESOLVER", "native", 1); -#endif +// #ifdef _WIN32 +// _putenv_s("GRPC_DNS_RESOLVER", "native"); +// #else +// setenv("GRPC_DNS_RESOLVER", "native", 1); +// #endif // 1. Initialize Options and set Proxy/SSL settings FIRST google::cloud::Options options; diff --git a/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc b/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc index 72553a473a..b0dd8dd75d 100644 --- a/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc +++ b/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc @@ -776,7 +776,7 @@ StatusRecord FetchBQDataRead(StatementHandle& stmt_handle, std::string::npos || read_arrow_status.message.find("DNS query cancelled") != std::string::npos)) { - LOG(WARNING) << "FetchBQDataRead:: BigQuery Storage API read failed with " + LOG(INFO) << "FetchBQDataRead:: BigQuery Storage API read failed with " "a DNS error. Setting GRPC_DNS_RESOLVER=native and " "retrying HTAPI once: " << read_arrow_status.message; @@ -790,6 +790,7 @@ StatusRecord FetchBQDataRead(StatementHandle& stmt_handle, read_arrow_status = FetchBQDataReadArrow( stmt_handle, insert_response->configuration.query.destination_table); } + LOG(INFO) << "FetchBQDataReadArrow::not entered env block"; return read_arrow_status; } diff --git a/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc b/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc index 33d85017b5..8b77ceecb8 100644 --- a/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc +++ b/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc @@ -262,6 +262,7 @@ StatusRecord FetchNextResultSet(StatementHandle& stmt_handle) { if (read_status.message.find( "errors resolving bigquerystorage.googleapis.com") != std::string::npos) { + LOG(INFO) << "WasHtapiEnabled:: env variable set block entered"; #ifdef _WIN32 _putenv_s("GRPC_DNS_RESOLVER", "native"); #else @@ -269,6 +270,7 @@ StatusRecord FetchNextResultSet(StatementHandle& stmt_handle) { #endif read_status = ReadNextResultsFromStream(stmt_handle); } + LOG(INFO) << "WasHtapiEnabled:: env variable set block not entered"; if (!read_status.ok()) { LOG(ERROR) << "ReadNextResultsFromStream:: " << read_status.message; return read_status; From a344ef720d62d5e64d21aafddb99eab39e3124d3 Mon Sep 17 00:00:00 2001 From: Anshu6250 Date: Wed, 3 Jun 2026 15:15:54 +0530 Subject: [PATCH 7/9] test --- google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc b/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc index 8b77ceecb8..ed2f61876d 100644 --- a/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc +++ b/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc @@ -268,7 +268,9 @@ StatusRecord FetchNextResultSet(StatementHandle& stmt_handle) { #else setenv("GRPC_DNS_RESOLVER", "native", 1); #endif - read_status = ReadNextResultsFromStream(stmt_handle); + stmt_handle.ClearReadRowsStream(); + stmt_handle.ClearReadRowsIterator(); + read_status = ReadNextResultsFromStream(stmt_handle); } LOG(INFO) << "WasHtapiEnabled:: env variable set block not entered"; if (!read_status.ok()) { From 88c5e045a76cafff144246af375366ffc23f669e Mon Sep 17 00:00:00 2001 From: Anshu6250 Date: Wed, 3 Jun 2026 16:16:02 +0530 Subject: [PATCH 8/9] test --- .../bq_driver/internal/odbc_conn_handle.cc | 22 +++++++++++++++++++ .../bq_driver/internal/odbc_conn_handle.h | 1 + .../internal/odbc_sql_execute_utils.cc | 1 + 3 files changed, 24 insertions(+) diff --git a/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.cc b/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.cc index aeea40d1ea..839377fa0f 100644 --- a/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.cc +++ b/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.cc @@ -322,6 +322,28 @@ StatusRecord ConnectionHandle::Connect(Authentication& auth) { return StatusRecord::Ok(); } +void ConnectionHandle::ResetClient() { + LOG(INFO) << "ConnectionHandle::ResetClient:: Recreating BQ Client to pick up environment changes."; + + // Re-create the client using the authentication info saved during Connect() + StatusRecordOr> response = + ODBCBQClient::CreateBQClient(auth_.oauth); + + if (!response) { + LOG(ERROR) << "ConnectionHandle::ResetClient:: Failed to recreate client: " + << response.GetStatusRecord().message; + return; + } + + // Replace the old client with the new one + client_ = *response; + + // Re-apply the RM ListProjects parent if it was set + if (!GetDsn().list_projects_parent.empty()) { + client_->SetListProjectsParent(GetDsn().list_projects_parent); + } +} + odbc_internal::StatusRecord ConnectionHandle::GetAttribute( SQLINTEGER attribute, SQLPOINTER value, SQLINTEGER buf_len, SQLINTEGER* str_len) { diff --git a/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.h b/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.h index bd026cc428..746bc2eda3 100644 --- a/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.h +++ b/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.h @@ -134,6 +134,7 @@ class ConnectionHandle : public Handle { Dsn GetDsn() const { return dsn_; } std::shared_ptr GetClient() { return client_; } + void ResetClient(); odbc_internal::StatusRecord GetAttribute(SQLINTEGER attribute, SQLPOINTER value, SQLINTEGER buf_len, diff --git a/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc b/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc index b0dd8dd75d..6454dca37b 100644 --- a/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc +++ b/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc @@ -785,6 +785,7 @@ StatusRecord FetchBQDataRead(StatementHandle& stmt_handle, #else setenv("GRPC_DNS_RESOLVER", "native", 1); #endif + conn_handle.ResetClient(); stmt_handle.ClearReadRowsStream(); stmt_handle.ClearReadRowsIterator(); read_arrow_status = FetchBQDataReadArrow( From de64fc607da144650df92cc5abcfa67925e1c6b6 Mon Sep 17 00:00:00 2001 From: Sachin Purohit Date: Mon, 8 Jun 2026 14:19:01 +0000 Subject: [PATCH 9/9] minor: unconditionally setting GRPC_DNS_RESOLVER to native for windows --- .../bq_client_interface/odbc_bq_client.cc | 10 ------- .../bq_driver/internal/odbc_conn_handle.cc | 22 ---------------- .../bq_driver/internal/odbc_conn_handle.h | 1 - .../internal/odbc_sql_execute_utils.cc | 26 +------------------ .../odbc/bq_driver/internal/odbc_sql_fetch.cc | 21 ++------------- google/cloud/odbc/bq_driver/internal/utils.cc | 2 ++ 6 files changed, 5 insertions(+), 77 deletions(-) diff --git a/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc b/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc index 364d5b90c8..7e42ecc02f 100644 --- a/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc +++ b/google/cloud/odbc/bq_client_interface/odbc_bq_client.cc @@ -28,7 +28,6 @@ #include "absl/log/log.h" #include #include -#include namespace google::cloud::odbc_bigquery_client_interface { @@ -156,15 +155,6 @@ google::cloud::ProxyConfig CreateProxyConfig(std::string hostname, StatusRecordOr> ODBCBQClient::CreateBQClient( Oauth const& oauth) { - // BigQuery Storage API uses gRPC. Set the DNS resolver before creating any - // gRPC BigQueryReadClient/connection; setting it after a DNS failure is too - // late because the resolver/channel may already be initialized. -// #ifdef _WIN32 -// _putenv_s("GRPC_DNS_RESOLVER", "native"); -// #else -// setenv("GRPC_DNS_RESOLVER", "native", 1); -// #endif - // 1. Initialize Options and set Proxy/SSL settings FIRST google::cloud::Options options; diff --git a/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.cc b/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.cc index 839377fa0f..aeea40d1ea 100644 --- a/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.cc +++ b/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.cc @@ -322,28 +322,6 @@ StatusRecord ConnectionHandle::Connect(Authentication& auth) { return StatusRecord::Ok(); } -void ConnectionHandle::ResetClient() { - LOG(INFO) << "ConnectionHandle::ResetClient:: Recreating BQ Client to pick up environment changes."; - - // Re-create the client using the authentication info saved during Connect() - StatusRecordOr> response = - ODBCBQClient::CreateBQClient(auth_.oauth); - - if (!response) { - LOG(ERROR) << "ConnectionHandle::ResetClient:: Failed to recreate client: " - << response.GetStatusRecord().message; - return; - } - - // Replace the old client with the new one - client_ = *response; - - // Re-apply the RM ListProjects parent if it was set - if (!GetDsn().list_projects_parent.empty()) { - client_->SetListProjectsParent(GetDsn().list_projects_parent); - } -} - odbc_internal::StatusRecord ConnectionHandle::GetAttribute( SQLINTEGER attribute, SQLPOINTER value, SQLINTEGER buf_len, SQLINTEGER* str_len) { diff --git a/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.h b/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.h index 746bc2eda3..bd026cc428 100644 --- a/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.h +++ b/google/cloud/odbc/bq_driver/internal/odbc_conn_handle.h @@ -134,7 +134,6 @@ class ConnectionHandle : public Handle { Dsn GetDsn() const { return dsn_; } std::shared_ptr GetClient() { return client_; } - void ResetClient(); odbc_internal::StatusRecord GetAttribute(SQLINTEGER attribute, SQLPOINTER value, SQLINTEGER buf_len, diff --git a/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc b/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc index 6454dca37b..a4480d7f6d 100644 --- a/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc +++ b/google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.cc @@ -16,7 +16,6 @@ #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 #include ////////////////////////////////////////////////////////////////// @@ -768,31 +767,8 @@ StatusRecord FetchBQDataRead(StatementHandle& stmt_handle, return StatusRecord{SQLStates::k_HY000(), error_message}; } - StatusRecord read_arrow_status = FetchBQDataReadArrow( + return FetchBQDataReadArrow( stmt_handle, insert_response->configuration.query.destination_table); - if (!read_arrow_status.ok() && - (read_arrow_status.message.find( - "errors resolving bigquerystorage.googleapis.com") != - std::string::npos || - read_arrow_status.message.find("DNS query cancelled") != - std::string::npos)) { - LOG(INFO) << "FetchBQDataRead:: BigQuery Storage API read failed with " - "a DNS error. Setting GRPC_DNS_RESOLVER=native and " - "retrying HTAPI once: " - << read_arrow_status.message; -#ifdef _WIN32 - _putenv_s("GRPC_DNS_RESOLVER", "native"); -#else - setenv("GRPC_DNS_RESOLVER", "native", 1); -#endif - conn_handle.ResetClient(); - stmt_handle.ClearReadRowsStream(); - stmt_handle.ClearReadRowsIterator(); - read_arrow_status = FetchBQDataReadArrow( - stmt_handle, insert_response->configuration.query.destination_table); - } - LOG(INFO) << "FetchBQDataReadArrow::not entered env block"; - return read_arrow_status; } #endif // (!defined(_WIN32) || defined(_WIN64)) && !defined(NO_ARROW) diff --git a/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc b/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc index ed2f61876d..69618d66f8 100644 --- a/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc +++ b/google/cloud/odbc/bq_driver/internal/odbc_sql_fetch.cc @@ -16,7 +16,6 @@ #include "google/cloud/odbc/bq_driver/internal/data_translation.h" #include "google/cloud/odbc/bq_driver/internal/odbc_sql_execute_utils.h" #include "google/cloud/odbc/bq_driver/internal/trace_utils.h" -#include namespace google::cloud::odbc_bq_driver_internal { @@ -259,24 +258,8 @@ StatusRecord FetchNextResultSet(StatementHandle& stmt_handle) { if (stmt_handle.WasHtapiEnabled()) { StatusRecord read_status = ReadNextResultsFromStream(stmt_handle); if (!read_status.ok()) { - if (read_status.message.find( - "errors resolving bigquerystorage.googleapis.com") != - std::string::npos) { - LOG(INFO) << "WasHtapiEnabled:: env variable set block entered"; -#ifdef _WIN32 - _putenv_s("GRPC_DNS_RESOLVER", "native"); -#else - setenv("GRPC_DNS_RESOLVER", "native", 1); -#endif - stmt_handle.ClearReadRowsStream(); - stmt_handle.ClearReadRowsIterator(); - read_status = ReadNextResultsFromStream(stmt_handle); - } - LOG(INFO) << "WasHtapiEnabled:: env variable set block not entered"; - if (!read_status.ok()) { - LOG(ERROR) << "ReadNextResultsFromStream:: " << read_status.message; - return read_status; - } + LOG(ERROR) << "ReadNextResultsFromStream:: " << read_status.message; + return read_status; } } else { StatusRecord read_status = FetchNextPageResultSet(stmt_handle); diff --git a/google/cloud/odbc/bq_driver/internal/utils.cc b/google/cloud/odbc/bq_driver/internal/utils.cc index 56aaaba952..016425c01f 100644 --- a/google/cloud/odbc/bq_driver/internal/utils.cc +++ b/google/cloud/odbc/bq_driver/internal/utils.cc @@ -26,6 +26,7 @@ #include #include #ifdef _WIN32 +#include #include // Required for SetWindowTheme #pragma comment(lib, "UxTheme.lib") // Link UxTheme.lib HINSTANCE g_hDllInstance = NULL; @@ -433,6 +434,7 @@ extern "C" BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason, switch (ul_reason) { case DLL_PROCESS_ATTACH: g_hDllInstance = hModule; + _putenv_s("GRPC_DNS_RESOLVER", "native"); break; } return TRUE;