feat: support structured C types in SQLBindParameter for string SQL types#749
Merged
sfc-gh-makowalski merged 6 commits intomainfrom Apr 3, 2026
Merged
Conversation
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
2 tasks
f5f01b3 to
f0f2ba6
Compare
33122b1 to
fc535e4
Compare
f0f2ba6 to
16e574d
Compare
9f45025 to
02415d1
Compare
16e574d to
d6f0bf6
Compare
4 tasks
4632498 to
055aa4a
Compare
3360a20 to
0914a53
Compare
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Apr 1, 2026
…SQL types (#748) ## Summary - Expand `SnowflakeVarchar::ReadODBC` to properly handle integer, float, and BIT C types when bound to string SQL types (`SQL_VARCHAR`, `SQL_CHAR`, `SQL_LONGVARCHAR`, `SQL_WCHAR`, `SQL_WVARCHAR`, `SQL_WLONGVARCHAR`) - Previously all non-WCHAR C types fell through to `read_char_str`, which interpreted raw struct bytes as a char string — producing garbage for numeric C types like `SQL_C_LONG` or `SQL_C_DOUBLE` - Map `SQL_C_DEFAULT` to `read_char_str` to match the `WriteODBCType` side and avoid a regression from the prior catch-all - Normalize `-0.0` to `"0"` for float-to-varchar binding to match old driver behavior - The catch-all now returns `UnsupportedCDataType` error instead of silently misinterpreting unknown C types ### C types now supported for string SQL parameters | C Type | Conversion | |--------|-----------| | `SQL_C_LONG` / `SQL_C_SLONG` | `i32 -> .to_string()` | | `SQL_C_SHORT` / `SQL_C_SSHORT` | `i16 -> .to_string()` | | `SQL_C_SBIGINT` | `i64 -> .to_string()` | | `SQL_C_ULONG` | `u32 -> .to_string()` | | `SQL_C_USHORT` | `u16 -> .to_string()` | | `SQL_C_UBIGINT` | `u64 -> .to_string()` | | `SQL_C_TINYINT` / `SQL_C_STINYINT` | `i8 -> .to_string()` | | `SQL_C_UTINYINT` | `u8 -> .to_string()` | | `SQL_C_DOUBLE` | `f64 -> .to_string()` (negative zero normalized to "0") | | `SQL_C_FLOAT` | `f32 -> .to_string()` (negative zero normalized to "0") | | `SQL_C_BIT` | `u8 -> "0" or "1"` | ### Follow-up (PR 2) Structured C types (`SQL_C_TYPE_TIMESTAMP`, `SQL_C_TYPE_DATE`, `SQL_C_TYPE_TIME`, `SQL_C_NUMERIC`, `SQL_C_BINARY`) are handled in the stacked PR #749. ## Test plan - [x] 36 e2e tests: - Each numeric C type bound to SQL_VARCHAR (SLONG, ULONG, SSHORT, USHORT, SBIGINT, UBIGINT, STINYINT, UTINYINT, DOUBLE, FLOAT) - Negative value test (negative SLONG) - BIT true, BIT false, BIT value > 1 - Deprecated C type aliases (SQL_C_LONG, SQL_C_SHORT, SQL_C_TINYINT) - SQL_C_SLONG bound to all 5 other string SQL types (SQL_CHAR, SQL_LONGVARCHAR, SQL_WCHAR, SQL_WVARCHAR, SQL_WLONGVARCHAR) - Boundary values: INT_MIN, INT_MAX, zero, LLONG_MIN, LLONG_MAX, ULLONG_MAX - Float edge cases: -0.0, NaN (double + float), +infinity (double + float), -infinity (double + float) - SQL_C_DEFAULT bound to SQL_VARCHAR - [x] All existing unit tests continue to pass SNOW-3031761
0914a53 to
5229587
Compare
Contributor
|
Please add E2E tests |
sfc-gh-pbulawa
requested changes
Apr 1, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the ODBC parameter-to-JSON conversion path for string SQL parameter types (e.g., VARCHAR) by adding support for additional structured/typed C buffers in SnowflakeVarchar::read_odbc, enabling date/time/timestamp, SQL_NUMERIC_STRUCT, and binary parameters to be represented as strings.
Changes:
- Added string formatting for
SQL_C_TYPE_TIMESTAMP/SQL_C_TIMESTAMP,SQL_C_TYPE_DATE/SQL_C_DATE, andSQL_C_TYPE_TIME/SQL_C_TIMEwhen binding toVARCHAR. - Added
SQL_C_NUMERIC(SQL_NUMERIC_STRUCT) conversion to a decimal string (magnitude/sign/scale). - Added
SQL_C_BINARYconversion to lowercase hex string, plus end-to-end tests covering these conversions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
odbc/src/conversion/varchar.rs |
Adds structured C-type decoding/formatting in SnowflakeVarchar::read_odbc for string SQL types. |
odbc/src/conversion/param_binding.rs |
Adds unit tests validating the new structured C-type → VARCHAR conversion behavior. |
sfc-gh-pbulawa
approved these changes
Apr 2, 2026
…ypes Add date, time, timestamp, SQL_NUMERIC_STRUCT, and binary C type conversions in SnowflakeVarchar::ReadODBC for string SQL parameters. - SQL_C_TYPE_TIMESTAMP: formats as "YYYY-MM-DD HH:MM:SS[.nnnnnnnnn]" (matches old driver format from BindCatchTest) - SQL_C_TYPE_DATE: formats as "YYYY-MM-DD" - SQL_C_TYPE_TIME: formats as "HH:MM:SS" - SQL_C_NUMERIC: reads SQL_NUMERIC_STRUCT, converts 128-bit LE magnitude with sign and scale to decimal string - SQL_C_BINARY: hex-encodes raw bytes SNOW-3031761 Made-with: Cursor
Per ODBC spec, SQL_NUMERIC_STRUCT.scale is SQLSCHAR (signed). Negative scale means the value is multiplied by 10^|scale| (e.g. val=123, scale=-2 represents 12300). Previously this fell through to the scale==0 branch, returning the raw magnitude without trailing zeros. Made-with: Cursor
8 new tests covering SQL_C_TYPE_TIMESTAMP (with and without fraction), SQL_C_TYPE_DATE, SQL_C_TYPE_TIME, SQL_C_NUMERIC (integer, negative with scale, negative scale), and SQL_C_BINARY bound to SQL_VARCHAR. Made-with: Cursor
BD#32: Old driver (Simba SDK) ignores the scale field in SQL_NUMERIC_STRUCT when converting to VARCHAR. New driver applies scale per ODBC spec (value = val × 10^(−scale)). BD#33: Old driver fails with HTTP 400 when binding SQL_C_BINARY to SQL_VARCHAR. New driver hex-encodes the binary data, which Snowflake accepts. Also fix clang-format issues in the new e2e tests. Made-with: Cursor
Made-with: Cursor
f979995 to
36d0388
Compare
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
Add date, time, timestamp, SQL_NUMERIC_STRUCT, and binary C type
conversions in SnowflakeVarchar::ReadODBC for string SQL parameters.
(matches old driver format from BindCatchTest)
with sign and scale (including negative scale) to decimal string
Follow-up from PR #748
Handles the remaining structured C types that were left as
UnsupportedCDataTypein the first PR.Test plan
SNOW-3031761