Skip to content

Conversation

@chenjian2664
Copy link
Contributor

@chenjian2664 chenjian2664 commented Jan 8, 2026

Description

Reading FLOAT in Query table function in Oracle will fail with:

io.trino.testing.QueryFailedException: com.google.common.util.concurrent.UncheckedExecutionException: 
java.lang.UnsupportedOperationException: 
Unsupported type: JdbcTypeHandle[jdbcType=2, jdbcTypeName=Optional[NUMBER], columnSize=Optional[126], decimalDigits=Optional[-127], arrayDimensions=Optional.empty, caseSensitivity=Optional[CASE_INSENSITIVE]] of column: Y

The return types in Query table function are derived from a prepared query https://github.com/trinodb/trino/blob/ce0492437e72d9e7483ef0028a941b333f82e488/plugin/trino-base-jdbc/src/main/java/io/trino/plugin/jdbc/ptf/Query.java#L99C8-L106
Oracle will declare type to NUMBER for the FLOAT type.

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text:

## Oracle
* Fix failure when reading `float` type in `query` table function. ({issue}`27880`)

@cla-bot cla-bot bot added the cla-signed label Jan 8, 2026
@github-actions github-actions bot added the oracle Oracle connector label Jan 8, 2026
@chenjian2664 chenjian2664 force-pushed the jack/fix-float-type-ptf-oracle branch from 5ff6b71 to 19052a6 Compare January 8, 2026 03:20
@chenjian2664 chenjian2664 requested review from ebyhr and findepi January 8, 2026 03:21
Optional.of(caseSensitive));
}

private static boolean isAllowedNumber(int precision, int columnSize)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this doesn't compare columnSize and precision values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the logic to follow

if (precision < scale) {
if (roundingMode == RoundingMode.UNNECESSARY) {
break;
}
scale = min(Decimals.MAX_PRECISION, scale);
precision = scale;
}
else if (numberDefaultScale.isPresent() && precision == PRECISION_OF_UNSPECIFIED_NUMBER) {
precision = Decimals.MAX_PRECISION;
scale = numberDefaultScale.get();
}
else if (precision > Decimals.MAX_PRECISION || actualPrecision <= 0) {
break;
}

The purpose of the method is to check if it is able to be handled as the NUMBER - as we could always correct interpret the type and with less "lossy"
If it not, we use it actual type - FLOAT

@findinpath findinpath requested a review from krvikash January 9, 2026 08:51
@chenjian2664 chenjian2664 requested a review from findepi January 12, 2026 01:15
@chenjian2664 chenjian2664 requested a review from krvikash January 12, 2026 08:03
@chenjian2664 chenjian2664 force-pushed the jack/fix-float-type-ptf-oracle branch from 80c4b57 to 974aefb Compare January 14, 2026 11:22
return columns.build();
}

private static JdbcTypeHandle getJdbcTypeHandle(ConnectorSession session, ResultSetMetaData metadata, int column)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: columnIndex

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to make consistency with

for (int column = 1; column <= metadata.getColumnCount(); column++) {
so, let's keep the column as the name

{
ImmutableList.Builder<JdbcColumnHandle> columns = ImmutableList.builder();
for (int column = 1; column <= metadata.getColumnCount(); column++) {
JdbcTypeHandle jdbcTypeHandle = getJdbcTypeHandle(session, metadata, column);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we introduce getJdbcTypeHandle as an extension point so that connectors could implement their logic without mimicing the boilder plate code ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently only Oracle has the requirements, so seems not so urgent to do such extension, wdyt?

@ebyhr ebyhr force-pushed the jack/fix-float-type-ptf-oracle branch from ca69056 to 28178dc Compare January 20, 2026 01:22
@ebyhr ebyhr merged commit f84c750 into trinodb:master Jan 20, 2026
7 of 15 checks passed
@github-actions github-actions bot added this to the 480 milestone Jan 20, 2026
@chenjian2664 chenjian2664 deleted the jack/fix-float-type-ptf-oracle branch January 20, 2026 04:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed oracle Oracle connector

Development

Successfully merging this pull request may close these issues.

5 participants