Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ protected Type jdbcTypeToDoris(JdbcFieldSchema fieldSchema) {
precision = scale;
}
return createDecimalOrStringType(precision, scale);
case "BINARY_FLOAT":

Copy link
Copy Markdown
Contributor

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 through JdbcConnectorProvider to JdbcOracleConnectorClient, and JdbcConnectorMetadata#getTableSchema calls that class's jdbcTypeToConnectorType. Its switch still has only FLOAT and falls through to UNSUPPORTED for both BINARY_FLOAT and BINARY_DOUBLE; this legacy JdbcOracleClient mapper is not on the catalog path (its remaining production callers are streaming helpers whose source enum excludes Oracle). Consequently this unit test can pass while DESC/queries on an Oracle catalog still reject these columns. Please add the two mappings to JdbcOracleConnectorClient and cover that production mapper, ideally with the existing Oracle JDBC regression suite.

return Type.FLOAT;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 CAST, carries the Java Double into JdbcQueryBuilder, and literalToSql renders it with toString(), so for example binary_double_col < CAST('Infinity' AS DOUBLE) becomes "BD" < Infinity. Oracle accepts the supplied BINARY_FLOAT_NAN/BINARY_DOUBLE_NAN and BINARY_FLOAT_INFINITY/BINARY_DOUBLE_INFINITY constants, not bare NaN/Infinity tokens (Oracle literals). Please render the type-appropriate Oracle literal (including negative infinity) or decline this conjunct from pushdown so BE evaluates it locally, and add query-builder/regression coverage.

case "BINARY_DOUBLE":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 FLOAT/DOUBLE with standard PreparedStatement.setFloat/setDouble, and its writer parameters carry neither the remote Oracle type nor even table_type. Oracle documents that these standard setters send NUMBER-format bits by default; converting those bits back into BINARY_FLOAT/BINARY_DOUBLE is not bit-exact and can corrupt values (OraclePreparedStatement). Please preserve enough Oracle/type information to use native binary setters, or enable SetFloatAndDoubleUseBinary for Oracle writer connections, and cover a binary-float INSERT/readback round trip.

case "FLOAT":
return Type.DOUBLE;
case "DATE":
Expand All @@ -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;
}
Expand Down
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)));
}
}
Loading