-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial code * added vertica md file * added vertica svg file * Update vertica.md Only Full Refresh Sync supported as per this PR. * Update vertica.md set 12.0.x for vertica documentation * pointing to a database running on a cluster * Automated Commit - Formatting Changes * adding metadata.yml file * move icon and add changelog * rename icon --------- Co-authored-by: dhanjimahto <dhanji.km@simplify3x.com> Co-authored-by: dhanjimahto <122617093+dhanjimahto@users.noreply.github.com> Co-authored-by: rakeshsimplify3xaccount <127210710+rakeshsimplify3xaccount@users.noreply.github.com> Co-authored-by: dhanjimahto <dhanjimahto@users.noreply.github.com>
- Loading branch information
1 parent
e3076e6
commit 3aa0c28
Showing
14 changed files
with
846 additions
and
0 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
3 changes: 3 additions & 0 deletions
3
airbyte-integrations/connectors/destination-vertica/.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 |
18 changes: 18 additions & 0 deletions
18
airbyte-integrations/connectors/destination-vertica/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,18 @@ | ||
FROM airbyte/integration-base-java:dev AS build | ||
|
||
WORKDIR /airbyte | ||
ENV APPLICATION destination-vertica | ||
|
||
COPY build/distributions/${APPLICATION}*.tar ${APPLICATION}.tar | ||
|
||
RUN tar xf ${APPLICATION}.tar --strip-components=1 && rm -rf ${APPLICATION}.tar | ||
|
||
FROM airbyte/integration-base-java:dev | ||
|
||
WORKDIR /airbyte | ||
ENV APPLICATION destination-vertica | ||
|
||
COPY --from=build /airbyte /airbyte | ||
|
||
LABEL io.airbyte.version=0.1.0 | ||
LABEL io.airbyte.name=airbyte/destination-vertica |
68 changes: 68 additions & 0 deletions
68
airbyte-integrations/connectors/destination-vertica/README.md
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,68 @@ | ||
# Destination Vertica | ||
|
||
This is the repository for the Vertica destination connector in Java. | ||
For information about how to use this connector within Airbyte, see [the User Documentation](https://docs.airbyte.com/integrations/destinations/vertica). | ||
|
||
## Local development | ||
|
||
#### Building via Gradle | ||
From the Airbyte repository root, run: | ||
``` | ||
./gradlew :airbyte-integrations:connectors:destination-vertica:build | ||
``` | ||
|
||
#### Create credentials | ||
**If you are a community contributor**, generate the necessary credentials and place them in `secrets/config.json` conforming to the spec file in `src/main/resources/spec.json`. | ||
Note that the `secrets` directory is git-ignored by default, so there is no danger of accidentally checking in sensitive information. | ||
|
||
**If you are an Airbyte core member**, follow the [instructions](https://docs.airbyte.com/connector-development#using-credentials-in-ci) to set up the credentials. | ||
|
||
### Locally running the connector docker image | ||
|
||
#### Build | ||
Build the connector image via Gradle: | ||
``` | ||
./gradlew :airbyte-integrations:connectors:destination-vertica:airbyteDocker | ||
``` | ||
When building via Gradle, the docker image name and tag, respectively, are the values of the `io.airbyte.name` and `io.airbyte.version` `LABEL`s in | ||
the Dockerfile. | ||
|
||
#### Run | ||
Then run any of the connector commands as follows: | ||
``` | ||
docker run --rm airbyte/destination-vertica:dev spec | ||
docker run --rm -v $(pwd)/secrets:/secrets airbyte/destination-vertica:dev check --config /secrets/config.json | ||
docker run --rm -v $(pwd)/secrets:/secrets airbyte/destination-vertica:dev discover --config /secrets/config.json | ||
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/destination-vertica:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json | ||
``` | ||
|
||
## Testing | ||
We use `JUnit` for Java tests. | ||
|
||
### Unit and Integration Tests | ||
Place unit tests under `src/test/io/airbyte/integrations/destinations/vertica`. | ||
|
||
#### Acceptance Tests | ||
Airbyte has a standard test suite that all destination connectors must pass. Implement the `TODO`s in | ||
`src/test-integration/java/io/airbyte/integrations/destinations/verticaDestinationAcceptanceTest.java`. | ||
|
||
### Using gradle to run tests | ||
All commands should be run from airbyte project root. | ||
To run unit tests: | ||
``` | ||
./gradlew :airbyte-integrations:connectors:destination-vertica:unitTest | ||
``` | ||
To run acceptance and custom integration tests: | ||
``` | ||
./gradlew :airbyte-integrations:connectors:destination-vertica:integrationTest | ||
``` | ||
|
||
## Dependency Management | ||
|
||
### Publishing a new version of the connector | ||
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what? | ||
1. Make sure your changes are passing unit and integration tests. | ||
1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use [SemVer](https://semver.org/)). | ||
1. Create a Pull Request. | ||
1. Pat yourself on the back for being an awesome contributor. | ||
1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master. |
22 changes: 22 additions & 0 deletions
22
airbyte-integrations/connectors/destination-vertica/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,22 @@ | ||
plugins { | ||
id 'application' | ||
id 'airbyte-docker' | ||
id 'airbyte-integration-test-java' | ||
} | ||
|
||
application { | ||
mainClass = 'io.airbyte.integrations.destination.vertica.VerticaDestination' | ||
} | ||
|
||
dependencies { | ||
implementation project(':airbyte-db:db-lib') | ||
implementation project(':airbyte-config-oss:config-models-oss') | ||
implementation libs.airbyte.protocol | ||
implementation project(':airbyte-integrations:bases:base-java') | ||
implementation files(project(':airbyte-integrations:bases:base-java').airbyteDocker.outputs) | ||
implementation project(path: ':airbyte-integrations:bases:bases-destination-jdbc') | ||
implementation group: 'com.vertica.jdbc', name: 'vertica-jdbc', version: '12.0.3-0' | ||
integrationTestJavaImplementation project(':airbyte-integrations:bases:standard-destination-test') | ||
integrationTestJavaImplementation project(':airbyte-integrations:connectors:destination-vertica') | ||
implementation group: 'org.testcontainers', name: 'jdbc', version: '1.18.0' | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions
18
airbyte-integrations/connectors/destination-vertica/metadata.yml
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,18 @@ | ||
data: | ||
registries: | ||
cloud: | ||
enabled: true | ||
oss: | ||
enabled: true | ||
connectorSubtype: database | ||
connectorType: destination | ||
definitionId: ca81ee7c-3163-9678-af40-094cc31e5e42 | ||
dockerImageTag: 0.1.0 | ||
dockerRepository: airbyte/destination-vertica | ||
githubIssueLabel: destination-vertica | ||
icon: vertica.svg | ||
license: MIT | ||
name: Vertica | ||
releaseStage: alpha | ||
supportUrl: https://docs.airbyte.com/integrations/destinations/vertica | ||
metadataSpecVersion: "1.0" |
148 changes: 148 additions & 0 deletions
148
...vertica/src/main/java/io/airbyte/integrations/destination/vertica/VerticaDestination.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,148 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.vertica; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.google.common.collect.ImmutableMap; | ||
import io.airbyte.commons.exceptions.ConnectionErrorException; | ||
import io.airbyte.commons.json.Jsons; | ||
import io.airbyte.commons.map.MoreMaps; | ||
import io.airbyte.db.factory.DataSourceFactory; | ||
import io.airbyte.db.factory.DatabaseDriver; | ||
import io.airbyte.db.jdbc.JdbcDatabase; | ||
import io.airbyte.db.jdbc.JdbcUtils; | ||
import io.airbyte.integrations.base.*; | ||
import io.airbyte.integrations.base.ssh.SshWrappedDestination; | ||
import io.airbyte.integrations.destination.NamingConventionTransformer; | ||
import io.airbyte.integrations.destination.jdbc.AbstractJdbcDestination; | ||
import io.airbyte.integrations.destination.jdbc.JdbcBufferedConsumerFactory; | ||
import io.airbyte.protocol.models.v0.AirbyteConnectionStatus; | ||
import io.airbyte.protocol.models.v0.AirbyteMessage; | ||
import io.airbyte.protocol.models.v0.ConfiguredAirbyteCatalog; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.sql.DataSource; | ||
import java.util.Map; | ||
import java.util.function.Consumer; | ||
|
||
import static io.airbyte.integrations.base.errors.messages.ErrorMessage.getErrorMessage; | ||
|
||
public class VerticaDestination extends AbstractJdbcDestination implements Destination { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(VerticaDestination.class); | ||
|
||
public static final String DRIVER_CLASS = DatabaseDriver.VERTICA.getDriverClassName(); | ||
|
||
public static final String COLUMN_NAME_AB_ID = | ||
"\"" + JavaBaseConstants.COLUMN_NAME_AB_ID + "\""; | ||
public static final String COLUMN_NAME_DATA = | ||
"\"" + JavaBaseConstants.COLUMN_NAME_DATA + "\""; | ||
public static final String COLUMN_NAME_EMITTED_AT = | ||
"\"" + JavaBaseConstants.COLUMN_NAME_EMITTED_AT + "\""; | ||
private final NamingConventionTransformer namingResolver; | ||
private final VerticaSqlOperations verticaSqlOperations; | ||
|
||
private final String driverClass; | ||
|
||
|
||
static final Map<String, String> DEFAULT_JDBC_PARAMETERS = ImmutableMap.of( | ||
"zeroDateTimeBehavior", "convertToNull", | ||
"allowLoadLocalInfile", "true"); | ||
|
||
public VerticaDestination(final String driverClass, | ||
final NamingConventionTransformer namingResolver, | ||
final VerticaSqlOperations verticaSqlOperations) { | ||
super(DRIVER_CLASS, namingResolver, verticaSqlOperations); | ||
this.verticaSqlOperations = verticaSqlOperations; | ||
this.namingResolver = namingResolver; | ||
this.driverClass = driverClass; | ||
|
||
|
||
} | ||
public static Destination sshWrappedDestination() { | ||
return new SshWrappedDestination(new VerticaDestination(DRIVER_CLASS,new VerticaNameTransformer(),new VerticaSqlOperations()), JdbcUtils.HOST_LIST_KEY, JdbcUtils.PORT_LIST_KEY); | ||
} | ||
|
||
public static void main(String[] args) throws Exception { | ||
final Destination destination = VerticaDestination.sshWrappedDestination(); | ||
LOGGER.info("starting destination: {}", VerticaDestination.class); | ||
new IntegrationRunner(destination).run(args); | ||
LOGGER.info("completed destination: {}", VerticaDestination.class); | ||
} | ||
|
||
@Override | ||
public AirbyteConnectionStatus check(JsonNode config) { | ||
final DataSource dataSource = getDataSource(config); | ||
try { | ||
final JdbcDatabase database = getDatabase(dataSource); | ||
final VerticaSqlOperations mySQLSqlOperations = (VerticaSqlOperations) getSqlOperations(); | ||
final String outputSchema = getNamingResolver().getIdentifier(config.get(JdbcUtils.DATABASE_KEY).asText()); | ||
attemptSQLCreateAndDropTableOperations(outputSchema, database, getNamingResolver(), | ||
mySQLSqlOperations); | ||
return new AirbyteConnectionStatus().withStatus(AirbyteConnectionStatus.Status.SUCCEEDED); | ||
} catch (final ConnectionErrorException e) { | ||
final String message = getErrorMessage(e.getStateCode(), e.getErrorCode(), e.getExceptionMessage(), e); | ||
AirbyteTraceMessageUtility.emitConfigErrorTrace(e, message); | ||
return new AirbyteConnectionStatus() | ||
.withStatus(AirbyteConnectionStatus.Status.FAILED) | ||
.withMessage(message); | ||
} catch (final Exception e) { | ||
LOGGER.error("Exception while checking connection: ", e); | ||
return new AirbyteConnectionStatus() | ||
.withStatus(AirbyteConnectionStatus.Status.FAILED) | ||
.withMessage("Could not connect with provided configuration. \n" + e.getMessage()); | ||
} finally { | ||
try { | ||
DataSourceFactory.close(dataSource); | ||
} catch (final Exception e) { | ||
LOGGER.warn("Unable to close data source.", e); | ||
} | ||
} | ||
} | ||
|
||
static final Map<String, String> DEFAULT_SSL_JDBC_PARAMETERS = MoreMaps.merge(ImmutableMap.of( | ||
"useSSL", "false", | ||
"requireSSL", "fase", | ||
"verifyServerCertificate", "false"), | ||
DEFAULT_JDBC_PARAMETERS); | ||
|
||
@Override | ||
protected Map<String, String> getDefaultConnectionProperties(JsonNode config) { | ||
if (JdbcUtils.useSsl(config)) { | ||
return DEFAULT_SSL_JDBC_PARAMETERS; | ||
} else { | ||
return DEFAULT_JDBC_PARAMETERS; | ||
} | ||
} | ||
|
||
@Override | ||
public JsonNode toJdbcConfig(JsonNode config) { | ||
final String jdbcUrl = String.format("jdbc:vertica://%s:%s/%s", | ||
config.get(JdbcUtils.HOST_KEY).asText(), | ||
config.get(JdbcUtils.PORT_KEY).asText(), | ||
config.get(JdbcUtils.DATABASE_KEY).asText()); | ||
|
||
final ImmutableMap.Builder<Object, Object> configBuilder = ImmutableMap.builder() | ||
.put(JdbcUtils.USERNAME_KEY, config.get(JdbcUtils.USERNAME_KEY).asText()) | ||
.put(JdbcUtils.JDBC_URL_KEY, jdbcUrl); | ||
|
||
if (config.has(JdbcUtils.PASSWORD_KEY)) { | ||
configBuilder.put(JdbcUtils.PASSWORD_KEY, config.get(JdbcUtils.PASSWORD_KEY).asText()); | ||
} | ||
if (config.has(JdbcUtils.JDBC_URL_PARAMS_KEY)) { | ||
configBuilder.put(JdbcUtils.JDBC_URL_PARAMS_KEY, config.get(JdbcUtils.JDBC_URL_PARAMS_KEY)); | ||
} | ||
return Jsons.jsonNode(configBuilder.build()); | ||
} | ||
|
||
@Override | ||
public AirbyteMessageConsumer getConsumer(final JsonNode config, | ||
final ConfiguredAirbyteCatalog catalog, | ||
final Consumer<AirbyteMessage> outputRecordCollector) { | ||
return JdbcBufferedConsumerFactory.create(outputRecordCollector, getDatabase(getDataSource(config)), verticaSqlOperations, namingResolver, config, | ||
catalog); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...ica/src/main/java/io/airbyte/integrations/destination/vertica/VerticaNameTransformer.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,7 @@ | ||
package io.airbyte.integrations.destination.vertica; | ||
|
||
import io.airbyte.integrations.destination.StandardNameTransformer; | ||
|
||
public class VerticaNameTransformer extends StandardNameTransformer { | ||
|
||
} |
Oops, something went wrong.