[coverage] Conformance findings: PARAMQUERY-021 (#1599) - #1636
Open
peco-engineer-bot[bot] wants to merge 1 commit into
Open
[coverage] Conformance findings: PARAMQUERY-021 (#1599)#1636peco-engineer-bot[bot] wants to merge 1 commit into
peco-engineer-bot[bot] wants to merge 1 commit into
Conversation
Signed-off-by: peco-engineer-bot[bot] <3815206+peco-engineer-bot[bot]@users.noreply.github.com>
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
Automated fix for #1599 — [coverage] Conformance findings: PARAMQUERY-021.
Fixed DatabricksTypeUtil.getDatabricksTypeFromSQLType so Types.FLOAT maps to the 8-byte Databricks DOUBLE (JDBC spec Appendix B: FLOAT is a synonym for DOUBLE), while Types.REAL alone maps to the 4-byte FLOAT. Verified against the live warehouse via the e2e test (SELECT ? AS v with setObject Types.FLOAT now yields a DOUBLE result column, distinct from Types.REAL which yields FLOAT) and the unit-level mapping guard.
Root cause & plan
Root cause: DatabricksTypeUtil.getDatabricksTypeFromSQLType() maps BOTH Types.FLOAT and Types.REAL to the Databricks 4-byte FLOAT wire type (DatabricksTypeUtil.java:477-479). Per the JDBC spec (Appendix B type table), Types.FLOAT is a synonym for DOUBLE (8-byte double precision, Java double); only Types.REAL is 4-byte single precision (Java float). So a setObject(i, x, Types.FLOAT) bind is silently narrowed to single precision instead of riding as the 8-byte DOUBLE the spec requires. This mapping feeds DatabricksPreparedStatement.setObject(int,Object,int) (line 339) which stores the parameter's ColumnInfoTypeName and sends the type string on the wire (mapToSparkParameterListItem / mapToParameterListItem); for
SELECT ? AS vthe server echoes the bound param type as the result column type, making the narrowing observable end-to-end.Files:
jdbc-core/src/main/java/com/databricks/jdbc/common/util/DatabricksTypeUtil.java,jdbc-core/src/test/java/com/databricks/jdbc/common/util/DatabricksTypeUtilTest.java,jdbc-core/src/test/java/com/databricks/jdbc/integration/e2e/ParameterBindTypeTests.javaPlanned coverage:
SELECT ? AS vbinding a double value with setObject(1, x, Types.FLOAT); assert the result column type is Types.DOUBLE (8-byte double, the wire type Types.FLOAT must ride as per JDBC spec), and contrast with a Types.REAL bind of the same value which must yield Types.FLOAT — demonstrating the declared target type drives the wire type and that FLOAT and REAL no longer collapse. Also assert the DOUBLE-bound value round-trips at double precision. (Types.FLOAT target must ride as the 8-byte Databricks DOUBLE, not the 4-byte FLOAT (and must differ from Types.REAL).)Files changed
src/test/java/com/databricks/jdbc/integration/e2e/ParameterBindTypeTests.javasrc/test/java/com/databricks/jdbc/common/util/DatabricksTypeUtilTest.javasrc/main/java/com/databricks/jdbc/common/util/DatabricksTypeUtil.javaTest plan
com.databricks.jdbc.integration.e2e.ParameterBindTypeTests#testTargetTypeDrivesWireTypeAcrossScalarTypes— fails (red) against the original code, passes (green) after the fixcom.databricks.jdbc.common.util.DatabricksTypeUtilTest#testGetDatabricksTypeFromSQLType— fails (red) against the original code, passes (green) after the fixNO_CHANGELOG=true
🤖 Generated by engineer-bot (bug-fix flow) — review before merge.