forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Oracle destination implementation (airbytehq#3498)
Working implementation of Oracle destination Co-authored-by: cgardens <[email protected]>
- Loading branch information
1 parent
a262f46
commit 8dadd1c
Showing
19 changed files
with
827 additions
and
11 deletions.
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
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
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
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
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
85 changes: 85 additions & 0 deletions
85
...c/main/java/io/airbyte/integrations/standardtest/destination/LocalAirbyteDestination.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,85 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Airbyte | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.airbyte.integrations.standardtest.destination; | ||
|
||
import io.airbyte.config.StandardTargetConfig; | ||
import io.airbyte.integrations.base.AirbyteMessageConsumer; | ||
import io.airbyte.integrations.base.Destination; | ||
import io.airbyte.protocol.models.AirbyteMessage; | ||
import io.airbyte.workers.protocols.airbyte.AirbyteDestination; | ||
import java.nio.file.Path; | ||
import java.util.Optional; | ||
|
||
// Simple class to host a Destination in-memory rather than spinning up a container for it. | ||
// For debugging and testing purposes only; not recommended to use this for real code | ||
public class LocalAirbyteDestination implements AirbyteDestination { | ||
|
||
private Destination dest; | ||
private AirbyteMessageConsumer consumer; | ||
private boolean isClosed = false; | ||
|
||
public LocalAirbyteDestination(Destination dest) { | ||
this.dest = dest; | ||
} | ||
|
||
@Override | ||
public void start(StandardTargetConfig targetConfig, Path jobRoot) throws Exception { | ||
consumer = | ||
dest.getConsumer(targetConfig.getDestinationConnectionConfiguration(), targetConfig.getCatalog(), Destination::defaultOutputRecordCollector); | ||
consumer.start(); | ||
} | ||
|
||
@Override | ||
public void accept(AirbyteMessage message) throws Exception { | ||
consumer.accept(message); | ||
} | ||
|
||
@Override | ||
public void notifyEndOfStream() { | ||
// nothing to do here | ||
} | ||
|
||
@Override | ||
public void close() throws Exception { | ||
consumer.close(); | ||
isClosed = true; | ||
} | ||
|
||
@Override | ||
public void cancel() { | ||
// nothing to do here | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return isClosed; | ||
} | ||
|
||
@Override | ||
public Optional<AirbyteMessage> attemptRead() { | ||
return Optional.empty(); | ||
} | ||
|
||
} |
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
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
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
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
3 changes: 3 additions & 0 deletions
3
airbyte-integrations/connectors/destination-oracle/.dockerignore
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,3 @@ | ||
* | ||
!Dockerfile | ||
!build |
12 changes: 12 additions & 0 deletions
12
airbyte-integrations/connectors/destination-oracle/Dockerfile
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,12 @@ | ||
FROM airbyte/integration-base-java:dev | ||
|
||
WORKDIR /airbyte | ||
|
||
ENV APPLICATION destination-oracle | ||
|
||
COPY build/distributions/${APPLICATION}*.tar ${APPLICATION}.tar | ||
|
||
RUN tar xf ${APPLICATION}.tar --strip-components=1 | ||
|
||
LABEL io.airbyte.version=0.1.0 | ||
LABEL io.airbyte.name=airbyte/destination-oracle |
31 changes: 31 additions & 0 deletions
31
airbyte-integrations/connectors/destination-oracle/build.gradle
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,31 @@ | ||
plugins { | ||
id 'application' | ||
id 'airbyte-docker' | ||
id 'airbyte-integration-test-java' | ||
} | ||
|
||
application { | ||
mainClass = 'io.airbyte.integrations.destination.oracle.OracleDestination' | ||
} | ||
|
||
dependencies { | ||
|
||
// required so that log4j uses a standard xml parser instead of an oracle one (that gets pulled in by the oracle driver) | ||
implementation group: 'xerces', name: 'xercesImpl', version: '2.12.1' | ||
|
||
implementation project(':airbyte-db') | ||
implementation project(':airbyte-integrations:bases:base-java') | ||
implementation project(':airbyte-protocol:models') | ||
implementation project(':airbyte-integrations:connectors:destination-jdbc') | ||
|
||
implementation "com.oracle.database.jdbc:ojdbc8-production:19.7.0.0" | ||
|
||
testImplementation 'org.apache.commons:commons-lang3:3.11' | ||
testImplementation 'org.testcontainers:oracle-xe:1.15.2' | ||
|
||
integrationTestJavaImplementation project(':airbyte-integrations:bases:standard-destination-test') | ||
integrationTestJavaImplementation project(':airbyte-integrations:connectors:destination-oracle') | ||
|
||
implementation files(project(':airbyte-integrations:bases:base-java').airbyteDocker.outputs) | ||
integrationTestJavaImplementation files(project(':airbyte-integrations:bases:base-normalization').airbyteDocker.outputs) | ||
} |
75 changes: 75 additions & 0 deletions
75
...on-oracle/src/main/java/io/airbyte/integrations/destination/oracle/OracleDestination.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,75 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Airbyte | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.oracle; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.google.common.collect.ImmutableMap; | ||
import io.airbyte.commons.json.Jsons; | ||
import io.airbyte.integrations.base.Destination; | ||
import io.airbyte.integrations.base.IntegrationRunner; | ||
import io.airbyte.integrations.base.JavaBaseConstants; | ||
import io.airbyte.integrations.destination.jdbc.AbstractJdbcDestination; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class OracleDestination extends AbstractJdbcDestination implements Destination { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(OracleDestination.class); | ||
|
||
public static final String DRIVER_CLASS = "oracle.jdbc.OracleDriver"; | ||
|
||
public static final String COLUMN_NAME_AB_ID = JavaBaseConstants.COLUMN_NAME_AB_ID.substring(1).toUpperCase(); | ||
public static final String COLUMN_NAME_DATA = JavaBaseConstants.COLUMN_NAME_DATA.substring(1).toUpperCase(); | ||
public static final String COLUMN_NAME_EMITTED_AT = JavaBaseConstants.COLUMN_NAME_EMITTED_AT.substring(1).toUpperCase(); | ||
|
||
public OracleDestination() { | ||
super(DRIVER_CLASS, new OracleNameTransformer(), new OracleOperations("users")); | ||
System.setProperty("oracle.jdbc.timezoneAsRegion", "false"); | ||
} | ||
|
||
@Override | ||
public JsonNode toJdbcConfig(JsonNode config) { | ||
final ImmutableMap.Builder<Object, Object> configBuilder = ImmutableMap.builder() | ||
.put("username", config.get("username").asText()) | ||
.put("jdbc_url", String.format("jdbc:oracle:thin:@//%s:%s/%s", | ||
config.get("host").asText(), | ||
config.get("port").asText(), | ||
config.get("sid").asText())); | ||
|
||
if (config.has("password")) { | ||
configBuilder.put("password", config.get("password").asText()); | ||
} | ||
|
||
return Jsons.jsonNode(configBuilder.build()); | ||
} | ||
|
||
public static void main(String[] args) throws Exception { | ||
final Destination destination = new OracleDestination(); | ||
LOGGER.info("starting destination: {}", OracleDestination.class); | ||
new IntegrationRunner(destination).run(args); | ||
LOGGER.info("completed destination: {}", OracleDestination.class); | ||
} | ||
|
||
} |
Oops, something went wrong.