Commit 6d6ef5b
Fix type inference for int64/uint64 (BIGINT) and float64 (DOUBLE) (#316)
## Summary
Fixes type inference bugs for numeric parameters:
- **int64/uint64**: Were incorrectly mapped to `SqlInteger` instead of
`SqlBigInt` (fixes #250)
- **float64**: Was incorrectly mapped to `SqlFloat` instead of
`SqlDouble` (fixes #314)
## Problems Fixed
### 1. int64/uint64 → BIGINT
When inserting int64/uint64 values into BIGINT columns, the driver was
sending them with type `INTEGER` instead of `BIGINT`, causing the server
to reject large values with error:
```
[INVALID_PARAMETER_MARKER_VALUE.INVALID_VALUE_FOR_DATA_TYPE] An invalid parameter mapping was provided:
the value '1311768467463790320' for parameter 'null' cannot be cast to INT because it is malformed.
```
Additionally, int64 was using `strconv.Itoa(int(value))` which truncates
values larger than int32.
### 2. float64 → DOUBLE
When inserting float64 values into DOUBLE columns, the driver was
sending them with type `FLOAT` (32-bit) instead of `DOUBLE` (64-bit),
causing:
- Precision loss for high-precision float64 values
- Potential overflow for values beyond float32 range (~3.4e38)
### 3. Panic with explicit Parameter type
When using `Parameter{Type: SqlBigInt, Value: int64(...)}` with a
non-string value, the driver panicked at
`convertNamedValuesToSparkParams` due to unsafe type assertion.
## Changes
- `parameters.go`:
- int64 now uses `strconv.FormatInt()` and maps to `SqlBigInt`
- uint64 now maps to `SqlBigInt`
- float64 now maps to `SqlDouble` instead of `SqlFloat`
- Added safe type assertion with fallback in
`convertNamedValuesToSparkParams`
## Test plan
- [x] Added unit tests for int64/uint64 type inference
(`TestParameter_BigInt`)
- [x] Added unit tests for float64/float32 type inference
(`TestParameter_Float`)
- [x] Verified large int64 values are correctly inserted and retrieved
from BIGINT columns
- [x] Verified float64 values with high precision are correctly inserted
and retrieved
- [x] All existing parameter tests pass
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.5 <[email protected]>1 parent a0d5e75 commit 6d6ef5b
2 files changed
+157
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
40 | 176 | | |
41 | 177 | | |
42 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
| 143 | + | |
| 144 | + | |
145 | 145 | | |
146 | | - | |
147 | | - | |
| 146 | + | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
153 | | - | |
| 152 | + | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
| |||
179 | 179 | | |
180 | 180 | | |
181 | 181 | | |
182 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
183 | 197 | | |
184 | 198 | | |
185 | 199 | | |
| |||
0 commit comments