Commit fa5a585
authored
test: add end-to-end DatabaseMetaData integration tests against local Hyper (#172)
Existing DatabaseMetaData coverage was unit-test-only with mocked gRPC
responses, which couldn't catch mismatches between QueryMetadataUtil's
type mapping and what a real pg_catalog returns.
Test harness:
- DatabaseAttachInterceptor: gRPC ClientInterceptor that attaches a
named .hyper database to every ExecuteQuery call. Lets a JDBC connection
target a specific database file without touching the caller's
QueryParam.
- HyperDatabaseSetup: raw-gRPC (JDBC-independent) utility that creates a
temp .hyper database and populates a test table covering every supported
type — bool, smallint, int, bigint, double precision, numeric, text,
varchar, char, date, time, timestamp, timestamptz, interval, json, oid,
int[], text[], plus explicit nullable / NOT NULL int columns.
- hyper_with_database.yaml: hyperd config with DATABASE_HYPER_EXTERNAL
authorization, fixed init-user, and experimental_data_type_persistence
so arrays survive in non-temp tables.
- HyperServerConfig.databasePath: new -d flag passthrough for hyperd.
- HyperServerManager.ConfigFile.WITH_DATABASE: new config profile.
Tests:
DatabaseMetadataIntegrationTest boots hyperd with -d, creates a real
database via the interceptor, and exercises getSchemas / getTables /
getColumns against actual pg_catalog rows.
The suite is deliberately a living bug list: every assertion that pins
current-but-incorrect behaviour carries a BUG: comment stating the
spec-correct value. Fixing the underlying defect will break the
assertion and force the override to be deleted.
The single strongest test is a cross-check between DatabaseMetaData
.getColumns() (pg_catalog path, via QueryMetadataUtil) and
ResultSetMetaData from SELECT * WHERE false (Arrow schema path, via
ArrowToColumnTypeMapper). The two paths both claim to describe the same
column and must agree — today they disagree for 14 of 20 cross-checked
columns. The test encodes the exact set of known disagreements, so any
fix to either path immediately surfaces.
Bugs surfaced (all in QueryMetadataUtil unless noted):
- dbTypeToSql keys on pg-internal short names (int2, int4, float8, ...)
but the SQL template calls format_type() which emits long forms
(smallint, integer, double precision, ...). 7 of the 15 map entries are
unreachable; DATA_TYPE falls through to raw pg type OIDs instead of
java.sql.Types values.
- No prefix/contains handling for parameterised types, so 'character
varying(255)', 'character(1)', 'array(integer)', 'array(text)' never
match.
- COLUMN_SIZE is hardcoded to 255 regardless of the column.
- DECIMAL_DIGITS is hardcoded to 2 regardless of atttypmod.
- interval and json have no JDBC mapping at all.
- DECIMAL (Arrow) vs NUMERIC (pg_catalog) disagreement for numeric().
- oid is reported as INTEGER via Arrow but BIGINT via pg_catalog.
- ArrowToColumnTypeMapper.visit(Interval) throws, so any SELECT that
materialises an interval column crashes the driver.
Not covered: 32-bit floats (hyperd rejects 'real' locally with 'This
database does not support 32-bit floating points') and bytea.1 parent 5a78b40 commit fa5a585
6 files changed
Lines changed: 1188 additions & 2 deletions
File tree
- jdbc-core/src
- main/java/com/salesforce/datacloud/jdbc/interceptor
- testFixtures/java/com/salesforce/datacloud/jdbc/hyper
- test
- java/com/salesforce/datacloud/jdbc/hyper
- resources
Lines changed: 75 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 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 | + | |
0 commit comments