Skip to content

Commit 88d3a39

Browse files
committed
[fix](jdbc) Map Oracle binary floating-point types
### What problem does this PR solve? Issue Number: None Related PR: None Problem Summary: Oracle JDBC catalogs use JdbcOracleConnectorClient for schema discovery. Its production type mapper returned UNSUPPORTED for BINARY_FLOAT and BINARY_DOUBLE even though the legacy JdbcOracleClient mapped them. Map BINARY_FLOAT to FLOAT and BINARY_DOUBLE to DOUBLE in the connector client and cover the production mapper directly. ### Release note Support Oracle BINARY_FLOAT and BINARY_DOUBLE columns in JDBC catalogs. ### Check List (For Author) - Test: Unit Test - mvn -f fe/pom.xml -pl :fe-connector-jdbc -am test -Dmaven.build.cache.enabled=false - Behavior changed: Yes, Oracle JDBC catalogs expose BINARY_FLOAT as FLOAT and BINARY_DOUBLE as DOUBLE instead of UNSUPPORTED. - Does this need documentation: No
1 parent 2319b68 commit 88d3a39

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

‎fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/client/JdbcOracleConnectorClient.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ public ConnectorType jdbcTypeToConnectorType(JdbcFieldInfo fieldInfo) {
171171
}
172172
return createDecimalOrString(scale, scale);
173173
}
174+
case "BINARY_FLOAT":
175+
return ConnectorType.of("FLOAT");
176+
case "BINARY_DOUBLE":
174177
case "FLOAT":
175178
return ConnectorType.of("DOUBLE");
176179
case "DATE":
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.doris.connector.jdbc.client;
19+
20+
import org.apache.doris.connector.jdbc.JdbcDbType;
21+
import org.apache.doris.connector.spi.ConnectorType;
22+
23+
import org.junit.jupiter.api.Assertions;
24+
import org.junit.jupiter.api.Test;
25+
26+
import java.sql.Types;
27+
import java.util.Collections;
28+
import java.util.Optional;
29+
30+
public class JdbcOracleConnectorClientTest {
31+
32+
private JdbcOracleConnectorClient createClient() {
33+
return new JdbcOracleConnectorClient(
34+
"test_catalog",
35+
JdbcDbType.ORACLE,
36+
"jdbc:oracle:thin:@localhost:1521:XE",
37+
false,
38+
Collections.emptyMap(),
39+
Collections.emptyMap(),
40+
false,
41+
false);
42+
}
43+
44+
private JdbcFieldInfo column(String typeName, int dataType) {
45+
return new JdbcFieldInfo(
46+
"col", Optional.of(typeName), dataType,
47+
Optional.of(8), Optional.of(0), Optional.empty());
48+
}
49+
50+
@Test
51+
void testOracleBinaryFloatingPointTypes() {
52+
JdbcOracleConnectorClient client = createClient();
53+
Assertions.assertEquals(
54+
ConnectorType.of("FLOAT"),
55+
client.jdbcTypeToConnectorType(column("BINARY_FLOAT", Types.FLOAT)));
56+
Assertions.assertEquals(
57+
ConnectorType.of("DOUBLE"),
58+
client.jdbcTypeToConnectorType(column("BINARY_DOUBLE", Types.DOUBLE)));
59+
}
60+
}

0 commit comments

Comments
 (0)