-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[Feature][Connector-V2] oracle connector #2550
Merged
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
4fdb8c1
[Feature][Connector-V2] support oracle connector
liugddx 4a1492e
Merge remote-tracking branch 'upstream/dev' into jdbc-oracle
liugddx d4fcb57
Merge remote-tracking branch 'upstream/dev' into jdbc-oracle
liugddx 77ccbc7
[Feature][Connector-V2] modify oracle connector
liugddx ff15742
Merge remote-tracking branch 'upstream/dev' into jdbc-oracle
liugddx 7f555bd
add oracle test case
liugddx bd68ba9
add oracle test case
liugddx 5b91970
add oracle test case
liugddx 9ba0432
fix some bug
liugddx 5c94d1d
fix some bug
liugddx a86ec48
fix NETWORK_ALIASES
liugddx 1714e6d
fix a bug
liugddx a746f19
fix some code
liugddx 3d991e3
fix spark test bug
liugddx 06ec7a0
fix some bug
liugddx e3031db
test all data type
liugddx b9224ff
test all data type
liugddx 127fb71
test all data type
liugddx 20b888e
test all data type
liugddx f8e4859
add oracle connector doc
liugddx 35f1adf
Update seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/sr…
liugddx cfe8cdf
Merge remote-tracking branch 'upstream/dev' into jdbc-oracle
liugddx 40b2f23
Merge remote-tracking branch 'upstream/dev' into jdbc-oracle
liugddx File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
39 changes: 39 additions & 0 deletions
39
...org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/OracleDialect.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle; | ||
|
||
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.converter.JdbcRowConverter; | ||
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect; | ||
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectTypeMapper; | ||
|
||
public class OracleDialect implements JdbcDialect { | ||
@Override | ||
public String dialectName() { | ||
return "Oracle"; | ||
} | ||
|
||
@Override | ||
public JdbcRowConverter getRowConverter() { | ||
return new OracleJdbcRowConverter(); | ||
} | ||
|
||
@Override | ||
public JdbcDialectTypeMapper getJdbcDialectTypeMapper() { | ||
return new OracleTypeMapper(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...che/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/OracleDialectFactory.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* 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.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle; | ||
|
||
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect; | ||
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectFactory; | ||
|
||
import com.google.auto.service.AutoService; | ||
|
||
/** | ||
* Factory for {@link OracleDialect}. | ||
*/ | ||
|
||
@AutoService(JdbcDialectFactory.class) | ||
public class OracleDialectFactory implements JdbcDialectFactory { | ||
@Override | ||
public boolean acceptsURL(String url) { | ||
return url.startsWith("jdbc:oracle:thin:"); | ||
} | ||
|
||
@Override | ||
public JdbcDialect create() { | ||
return new OracleDialect(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...e/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/OracleJdbcRowConverter.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle; | ||
|
||
import org.apache.seatunnel.api.table.type.SeaTunnelRow; | ||
import org.apache.seatunnel.api.table.type.SeaTunnelRowType; | ||
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.converter.AbstractJdbcRowConverter; | ||
|
||
import java.sql.ResultSet; | ||
import java.sql.ResultSetMetaData; | ||
import java.sql.SQLException; | ||
|
||
public class OracleJdbcRowConverter extends AbstractJdbcRowConverter { | ||
|
||
@Override | ||
public String converterName() { | ||
return "Oracle"; | ||
} | ||
|
||
@Override | ||
public SeaTunnelRow toInternal(ResultSet rs, ResultSetMetaData metaData, SeaTunnelRowType typeInfo) throws SQLException { | ||
return super.toInternal(rs, metaData, typeInfo); | ||
} | ||
} |
111 changes: 111 additions & 0 deletions
111
.../apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/oracle/OracleTypeMapper.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* 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.seatunnel.connectors.seatunnel.jdbc.internal.dialect.oracle; | ||
|
||
import org.apache.seatunnel.api.table.type.BasicType; | ||
import org.apache.seatunnel.api.table.type.DecimalType; | ||
import org.apache.seatunnel.api.table.type.LocalTimeType; | ||
import org.apache.seatunnel.api.table.type.PrimitiveByteArrayType; | ||
import org.apache.seatunnel.api.table.type.SeaTunnelDataType; | ||
import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectTypeMapper; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.sql.ResultSetMetaData; | ||
import java.sql.SQLException; | ||
|
||
@Slf4j | ||
public class OracleTypeMapper implements JdbcDialectTypeMapper { | ||
|
||
// ============================data types===================== | ||
|
||
private static final String ORACLE_UNKNOWN = "UNKNOWN"; | ||
|
||
// -------------------------number---------------------------- | ||
private static final String ORACLE_BINARY_DOUBLE = "BINARY_DOUBLE"; | ||
private static final String ORACLE_BINARY_FLOAT = "BINARY_FLOAT"; | ||
private static final String ORACLE_NUMBER = "NUMBER"; | ||
private static final String ORACLE_FLOAT = "FLOAT"; | ||
|
||
// -------------------------string---------------------------- | ||
private static final String ORACLE_CHAR = "CHAR"; | ||
private static final String ORACLE_VARCHAR2 = "VARCHAR2"; | ||
private static final String ORACLE_NCHAR = "NCHAR"; | ||
private static final String ORACLE_NVARCHAR2 = "NVARCHAR2"; | ||
private static final String ORACLE_LONG = "LONG"; | ||
private static final String ORACLE_ROWID = "ROWID"; | ||
private static final String ORACLE_CLOB = "CLOB"; | ||
private static final String ORACLE_NCLOB = "NCLOB"; | ||
|
||
// ------------------------------time------------------------- | ||
private static final String ORACLE_DATE = "DATE"; | ||
private static final String ORACLE_TIMESTAMP = "TIMESTAMP"; | ||
private static final String ORACLE_TIME_WITHOUT_TIME_ZONE = "TIME WITHOUT TIME ZONE"; | ||
private static final String ORACLE_TIMESTAMP_WITHOUT_TIME_ZONE = "TIMESTAMP WITHOUT TIME ZONE"; | ||
|
||
// ------------------------------blob------------------------- | ||
private static final String ORACLE_BLOB = "BLOB"; | ||
private static final String ORACLE_BFILE = "BFILE"; | ||
private static final String ORACLE_RAW = "RAW"; | ||
private static final String ORACLE_LONG_RAW = "LONG RAW"; | ||
|
||
@SuppressWarnings("checkstyle:MagicNumber") | ||
@Override | ||
public SeaTunnelDataType<?> mapping(ResultSetMetaData metadata, int colIndex) throws SQLException { | ||
String oracleType = metadata.getColumnTypeName(colIndex).toUpperCase(); | ||
String columnName = metadata.getColumnName(colIndex); | ||
int precision = metadata.getPrecision(colIndex); | ||
int scale = metadata.getScale(colIndex); | ||
switch (oracleType) { | ||
case ORACLE_NUMBER: | ||
return new DecimalType(precision, scale); | ||
case ORACLE_FLOAT: | ||
case ORACLE_BINARY_DOUBLE: | ||
return BasicType.DOUBLE_TYPE; | ||
case ORACLE_BINARY_FLOAT: | ||
return BasicType.FLOAT_TYPE; | ||
case ORACLE_CHAR: | ||
case ORACLE_NCHAR: | ||
case ORACLE_NVARCHAR2: | ||
case ORACLE_VARCHAR2: | ||
case ORACLE_LONG: | ||
case ORACLE_ROWID: | ||
case ORACLE_NCLOB: | ||
case ORACLE_CLOB: | ||
return BasicType.STRING_TYPE; | ||
case ORACLE_DATE: | ||
case ORACLE_TIMESTAMP: | ||
case ORACLE_TIME_WITHOUT_TIME_ZONE: | ||
case ORACLE_TIMESTAMP_WITHOUT_TIME_ZONE: | ||
return LocalTimeType.LOCAL_DATE_TIME_TYPE; | ||
case ORACLE_BLOB: | ||
case ORACLE_RAW: | ||
case ORACLE_LONG_RAW: | ||
case ORACLE_BFILE: | ||
return PrimitiveByteArrayType.INSTANCE; | ||
//Doesn't support yet | ||
case ORACLE_UNKNOWN: | ||
default: | ||
final String jdbcColumnName = metadata.getColumnName(colIndex); | ||
throw new UnsupportedOperationException( | ||
String.format( | ||
"Doesn't support ORACLE type '%s' on column '%s' yet.", | ||
oracleType, jdbcColumnName)); | ||
} | ||
} | ||
} |
This file contains 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
Oops, something went wrong.
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.
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.
use
provided
?