Commit 93dee9d
committed
refactor: centralize type logic via HyperType
Introduce a Hyper-native internal type model (HyperType) in a new
com.salesforce.datacloud.jdbc.core.types package and route every
Arrow, pg_catalog, prepared-statement, and Spark conversion through
it. Translation to java.sql.JDBCType / Types only happens at the JDBC
API boundary via HyperTypes.
New types package:
- HyperTypeKind enum (BOOL, INT8-INT64, OID, FLOAT4/8, DECIMAL, CHAR,
VARCHAR, BINARY, VARBINARY, DATE, TIME[_TZ], TIMESTAMP[_TZ], ARRAY,
NULL, INTERVAL, JSON)
- HyperType @value class with factories per kind and a visitor
- HyperTypes utility: toJdbcType/Code/Name, toJavaClass, getPrecision,
getScale, getDisplaySize, isSigned, isCaseSensitive,
needsDecimalDigits/CharOctetLength, fromJdbcTypeCode, typeInfoRows
- ArrowToHyperTypeMapper: Arrow Field -> HyperType (reads hyper:type /
hyper:max_string_length metadata)
- HyperTypeToArrow: HyperType -> Arrow FieldType for prepared-statement
parameter schemas
- PgCatalogTypeParser: Hyper format_type() string -> HyperType, throws
IllegalArgumentException for any unrecognized name (no UNKNOWN
catch-all; unsupported types fail loudly at the JDBC boundary)
Deleted:
- ColumnType.java, ArrowToColumnTypeMapper.java (replaced by
HyperType and ArrowToHyperTypeMapper)
- QueryMetadataUtil.dbTypeToSql map (which used PG internal aliases
int2/int4/int8/bool/float4/float8 that Hyper's format_type never
emits) and the isDecimalType/isCharType string helpers
- ArrowUtils.SQL_TYPE_TO_FIELD_TYPE map (replaced by HyperTypeToArrow)
Migrated callers:
- ColumnMetadata holds HyperType
- DataCloudResultSetMetaData delegates to HyperTypes.*
- StreamingResultSet, DataCloudArray, DataCloudConnection.getSchemaForQueryId,
ArrowUtils.toColumnMetaData route through ArrowToHyperTypeMapper
- QueryMetadataUtil.constructColumnData routes through PgCatalogTypeParser
- SimpleResultSet switches from JDBCType to HyperTypeKind; also picks
up TINYINT numeric coercions and the getFloat wasNull/range-check
fix that were planned as Phase 0 work
- ParameterBinding holds HyperType; DataCloudPreparedStatement setXxx
methods build HyperType factories directly
- VectorPopulator.VectorValueSetterFactory keyed by HyperTypeKind
- TypeMapping.scala (Spark): switches expanded to cover TINYINT,
NUMERIC, CHAR, NULL, FLOAT, NCHAR, NVARCHAR, LONGNVARCHAR
- DataCloudDatabaseMetadata.getTypeInfo() returns a real 18-column
result derived from HyperTypeKind (was empty before)
Observable behaviour changes in DatabaseMetaData.getColumns():
- TYPE_NAME is now consistently JDBC-uppercase ("BIGINT", "BOOLEAN",
"INTEGER", "DECIMAL", ...) instead of a mix of Hyper-lowercase and
uppercase strings. INTERVAL and JSON show the Hyper-uppercase form.
- DATA_TYPE is always a java.sql.Types value (was a raw PG OID for
types unmapped by the old dbTypeToSql).
- Numeric/decimal unified to DECIMAL (both Arrow Decimal and Hyper
numeric map to HyperTypeKind.DECIMAL / JDBCType.DECIMAL).
- Unsupported column types throw SQLException (state 42704) rather
than silently surfacing as Types.OTHER with a raw name.
Exception contract:
- PgCatalogTypeParser, HyperTypes.fromJdbcTypeCode, HyperTypeToArrow,
and ArrowToHyperTypeMapper throw IllegalArgumentException for types
they do not model. Every JDBC entry point that reaches them
(DataCloudDatabaseMetadata.getColumns, DataCloudConnection.getSchemaForQueryId,
DataCloudPreparedStatement.setNull / setObject / getQueryParamBuilder,
StreamingResultSet.of) catches and wraps in SQLException with an
appropriate SQL state (42704 / HYC00 / HY000 / 0A000).
Also fixes pre-existing DataCloudDatabaseMetadataTest expectations
that hadn't been updated when the recent "DatabaseMetaData spec
violations" commit landed (e.g. testGetJDBCMajorVersion expecting 1
rather than 4, testGetProcedures expecting .isNull() on a method now
throwing SQLFeatureNotSupportedException).
Made-with: Cursor1 parent d4b1dcf commit 93dee9d
46 files changed
Lines changed: 2834 additions & 1477 deletions
File tree
- jdbc-core/src
- main/java/com/salesforce/datacloud/jdbc
- core
- accessor/impl
- metadata
- resultset
- types
- protocol/data
- util
- test/java/com/salesforce/datacloud/jdbc
- core
- metadata
- resultset
- types
- hyper
- protocol/data
- spark-datasource-core/src/main/scala/com/salesforce/datacloud/spark
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
Lines changed: 10 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
182 | 183 | | |
183 | 184 | | |
184 | 185 | | |
185 | | - | |
| 186 | + | |
186 | 187 | | |
187 | 188 | | |
188 | 189 | | |
| |||
281 | 282 | | |
282 | 283 | | |
283 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
284 | 291 | | |
285 | 292 | | |
286 | 293 | | |
| |||
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
753 | 755 | | |
754 | 756 | | |
755 | 757 | | |
756 | | - | |
| 758 | + | |
| 759 | + | |
757 | 760 | | |
758 | 761 | | |
759 | 762 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
Lines changed: 44 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
54 | | - | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
60 | | - | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
65 | | - | |
| 67 | + | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
71 | | - | |
72 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
73 | 79 | | |
74 | 80 | | |
75 | 81 | | |
| |||
94 | 100 | | |
95 | 101 | | |
96 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
97 | 107 | | |
98 | 108 | | |
99 | 109 | | |
| |||
131 | 141 | | |
132 | 142 | | |
133 | 143 | | |
134 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
135 | 153 | | |
136 | 154 | | |
137 | 155 | | |
138 | 156 | | |
139 | | - | |
| 157 | + | |
140 | 158 | | |
141 | 159 | | |
142 | 160 | | |
143 | 161 | | |
144 | | - | |
| 162 | + | |
145 | 163 | | |
146 | 164 | | |
147 | 165 | | |
148 | 166 | | |
149 | | - | |
| 167 | + | |
150 | 168 | | |
151 | 169 | | |
152 | 170 | | |
153 | 171 | | |
154 | | - | |
| 172 | + | |
155 | 173 | | |
156 | 174 | | |
157 | 175 | | |
158 | 176 | | |
159 | | - | |
| 177 | + | |
160 | 178 | | |
161 | 179 | | |
162 | 180 | | |
163 | 181 | | |
164 | | - | |
| 182 | + | |
165 | 183 | | |
166 | 184 | | |
167 | 185 | | |
168 | 186 | | |
169 | | - | |
| 187 | + | |
170 | 188 | | |
171 | 189 | | |
172 | 190 | | |
173 | 191 | | |
174 | | - | |
| 192 | + | |
| 193 | + | |
175 | 194 | | |
176 | 195 | | |
177 | 196 | | |
178 | 197 | | |
179 | | - | |
| 198 | + | |
180 | 199 | | |
181 | 200 | | |
182 | 201 | | |
| |||
186 | 205 | | |
187 | 206 | | |
188 | 207 | | |
189 | | - | |
| 208 | + | |
190 | 209 | | |
191 | 210 | | |
192 | 211 | | |
193 | 212 | | |
194 | | - | |
| 213 | + | |
195 | 214 | | |
196 | 215 | | |
197 | 216 | | |
198 | 217 | | |
199 | | - | |
| 218 | + | |
200 | 219 | | |
201 | 220 | | |
202 | 221 | | |
| |||
229 | 248 | | |
230 | 249 | | |
231 | 250 | | |
232 | | - | |
| 251 | + | |
233 | 252 | | |
234 | 253 | | |
235 | 254 | | |
236 | 255 | | |
237 | 256 | | |
238 | | - | |
| 257 | + | |
239 | 258 | | |
240 | 259 | | |
241 | 260 | | |
242 | | - | |
| 261 | + | |
243 | 262 | | |
244 | 263 | | |
245 | 264 | | |
| |||
307 | 326 | | |
308 | 327 | | |
309 | 328 | | |
310 | | - | |
| 329 | + | |
311 | 330 | | |
312 | 331 | | |
313 | 332 | | |
314 | 333 | | |
315 | 334 | | |
316 | | - | |
| 335 | + | |
317 | 336 | | |
318 | 337 | | |
319 | 338 | | |
320 | 339 | | |
321 | | - | |
| 340 | + | |
322 | 341 | | |
323 | 342 | | |
324 | 343 | | |
| |||
0 commit comments