Repository navigation
feat(bq_driver): implement cross-platform File DSN connection support - #1701
Draft
KanchanShu wants to merge 1 commit into
Draft
KanchanShu wants to merge 1 commit into
KanchanShu wants to merge 1 commit into
Conversation
KanchanShu
force-pushed
the
imple_file_dsn
branch
from
October 28, 2026 22:19
707a7d8 to
cd0c6ac
Compare
| // Strip UTF-8 BOM if present | ||
| if (is_first_line) { | ||
| is_first_line = false; | ||
| if (line.size() >= 3 && static_cast<unsigned char>(line[0]) == 0xEF && |
Contributor
There was a problem hiding this comment.
why are we doing this handling? will this work for cross platform , ascii/ non-ascii encodings?
Contributor
Author
There was a problem hiding this comment.
On Windows, editors like Notepad often prepend a 3-byte UTF-8 BOM (0xEF, 0xBB, 0xBF). Without stripping it, [ODBC] is read as \xEF\xBB\xBF[ODBC], causing line.front() == '[' to fail and the section to be missed.
It is safe across platforms and encodings:
- ASCII: Characters are
0x00–0x7F, so they will never match0xEF(safe no-op). - Cross-platform / Non-ASCII (UTF-8): The BOM sequence is endian-neutral and identical across Linux, macOS, and Windows. Only the leading 3 bytes on the first line are stripped; all non-ASCII payloads remain intact.
If you'd prefer to omit BOM handling to stay consistent with ParseConfig, I'm happy to remove it—let me know!
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for File DSN connections (
FILEDSN=<path>) in the BigQuery ODBC Driver across all supported platforms (Linux, macOS, and Windows) for bothSQLDriverConnectandSQLBrowseConnect.It also adds comprehensive unit and integration test coverage for File DSN connection flows, invalid credentials, empty paths, and non-existent files without introducing any static or hardcoded local file paths.
Changes
1. Driver Core & Parsing Logic
ProcessFileDSNextraction: Centralized File DSN parsing logic into a shared helper function ingoogle/cloud/odbc/bq_driver/odbc_connection.ccused by bothSQLDriverConnectInternalandSQLBrowseConnectInternal.DefaultDSNDirfromHKLM\SOFTWARE\ODBC\ODBC.INI\ODBC File DSNif a relative filename is provided..size() >= 2bounds checking prior to string slicing to eliminate potential unsigned underflow/overflow risks.std::tolowerwithstatic_cast<unsigned char>to prevent undefined behavior with signed characters under Clang / AddressSanitizer (ASAN).SQLSTATE 08001/HY000) when a File DSN path cannot be read or opened.2. Testing
google/cloud/odbc/bq_driver/internal/utils_test.cc):.dsnfiles with key-value parsing and quote stripping.Cleanerstruct for deterministic cleanup of temporary test files.google/cloud/odbc/integration_tests/odbc_driver_tests/connection_test.cc):ConnectionTest.FileDSN_Success: Generates a dynamic, self-cleaning temporary.dsnfile with absolute path resolution viastd::filesystem::absoluteto support both Google Driver and Simba Driver seamlessly across platforms.FileDSN_NonExistentFile_Fails,FileDSN_EmptyPath_Fails, andFileDSN_InvalidCredentials_Fails.GTEST_SKIP()guard whenCPP_BIGQUERY_ODBC_TEST_SERVICE_ACCOUNT_AUTH_KEYis not present, allowing test suites to pass gracefully on local developer machines without active GCP credentials.Bug: Buganizer Issue 576846795