-
Notifications
You must be signed in to change notification settings - Fork 4k
[opt](jdbc) Support Oracle BINARY_FLOAT and BINARY_DOUBLE types #68200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -217,6 +217,9 @@ protected Type jdbcTypeToDoris(JdbcFieldSchema fieldSchema) { | |
| precision = scale; | ||
| } | ||
| return createDecimalOrStringType(precision, scale); | ||
| case "BINARY_FLOAT": | ||
| return Type.FLOAT; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Do not push bare NaN/Infinity tokens to Oracle After the production mapping is fixed, these types make non-finite predicates reachable. The connector currently unwraps |
||
| case "BINARY_DOUBLE": | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Preserve the binary format on Oracle JDBC writes Once these cases are added to the production connector mapper, the columns also become writable through the JDBC catalog. The sink currently binds every Doris |
||
| case "FLOAT": | ||
| return Type.DOUBLE; | ||
| case "DATE": | ||
|
|
@@ -237,8 +240,6 @@ protected Type jdbcTypeToDoris(JdbcFieldSchema fieldSchema) { | |
| : ScalarType.createStringType(); | ||
| case "NCLOB": | ||
| case "BFILE": | ||
| case "BINARY_FLOAT": | ||
| case "BINARY_DOUBLE": | ||
| default: | ||
| return Type.UNSUPPORTED; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| package org.apache.doris.datasource.jdbc.client; | ||
|
|
||
| import org.apache.doris.catalog.Type; | ||
| import org.apache.doris.datasource.jdbc.util.JdbcFieldSchema; | ||
|
|
||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.mockito.Answers; | ||
| import org.mockito.Mockito; | ||
|
|
||
| import java.sql.DatabaseMetaData; | ||
| import java.sql.ResultSet; | ||
| import java.sql.SQLException; | ||
| import java.sql.Types; | ||
|
|
||
| public class JdbcOracleClientTest { | ||
| private final JdbcOracleClient client = Mockito.mock(JdbcOracleClient.class, Answers.CALLS_REAL_METHODS); | ||
|
|
||
| private static JdbcFieldSchema column(String typeName, int dataType) throws SQLException { | ||
| ResultSet resultSet = Mockito.mock(ResultSet.class); | ||
| Mockito.when(resultSet.getString("COLUMN_NAME")).thenReturn("col"); | ||
| Mockito.when(resultSet.getInt("DATA_TYPE")).thenReturn(dataType); | ||
| Mockito.when(resultSet.getString("TYPE_NAME")).thenReturn(typeName); | ||
| Mockito.when(resultSet.getInt("COLUMN_SIZE")).thenReturn(8); | ||
| Mockito.when(resultSet.getInt("DECIMAL_DIGITS")).thenReturn(0); | ||
| Mockito.when(resultSet.getInt("NULLABLE")).thenReturn(DatabaseMetaData.columnNullable); | ||
| return new JdbcFieldSchema(resultSet); | ||
| } | ||
|
|
||
| @Test | ||
| public void testOracleBinaryFloatingPointTypes() throws SQLException { | ||
| Assertions.assertEquals(Type.FLOAT, | ||
| client.jdbcTypeToDoris(column("BINARY_FLOAT", Types.FLOAT))); | ||
| Assertions.assertEquals(Type.DOUBLE, | ||
| client.jdbcTypeToDoris(column("BINARY_DOUBLE", Types.DOUBLE))); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Update the Oracle connector mapper used by JDBC catalogs
A normal
type='jdbc'catalog is routed throughJdbcConnectorProvidertoJdbcOracleConnectorClient, andJdbcConnectorMetadata#getTableSchemacalls that class'sjdbcTypeToConnectorType. Its switch still has onlyFLOATand falls through toUNSUPPORTEDfor bothBINARY_FLOATandBINARY_DOUBLE; this legacyJdbcOracleClientmapper is not on the catalog path (its remaining production callers are streaming helpers whose source enum excludes Oracle). Consequently this unit test can pass whileDESC/queries on an Oracle catalog still reject these columns. Please add the two mappings toJdbcOracleConnectorClientand cover that production mapper, ideally with the existing Oracle JDBC regression suite.