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.
🎉 New Destination: Rockset (airbytehq#8006)
- Loading branch information
1 parent
be2ed7d
commit 3748c66
Showing
18 changed files
with
1,007 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...esources/config/STANDARD_DESTINATION_DEFINITION/2c9d93a7-9a17-4789-9de9-f46f0097eb70.json
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 @@ | ||
{ | ||
"destinationDefinitionId": "2c9d93a7-9a17-4789-9de9-f46f0097eb70", | ||
"name": "Rockset", | ||
"dockerRepository": "airbyte/destination-rockset", | ||
"dockerImageTag": "0.1.0", | ||
"documentationUrl": "https://docs.airbyte.io/integrations/destinations/rockset" | ||
} |
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-rockset/.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 |
6 changes: 6 additions & 0 deletions
6
airbyte-integrations/connectors/destination-rockset/BOOTSTRAP.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,6 @@ | ||
# Rockset Destination Connector Bootstrap | ||
|
||
[Rockset](https://rockset.com/) is a real-time analytics database for fast queries on fresh data from databases, lakes and streams. | ||
An [API key](https://rockset.com/docs/rest-api/#authentication) is required. | ||
Configured collections will be created as required and data will be written via the [write API](https://rockset.com/docs/rest-api/#adddocuments). | ||
|
11 changes: 11 additions & 0 deletions
11
airbyte-integrations/connectors/destination-rockset/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,11 @@ | ||
FROM airbyte/integration-base-java:dev | ||
|
||
WORKDIR /airbyte | ||
ENV APPLICATION destination-rockset | ||
|
||
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-rockset |
68 changes: 68 additions & 0 deletions
68
airbyte-integrations/connectors/destination-rockset/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 Rockset | ||
|
||
This is the repository for the Rockset destination connector in Java. | ||
For information about how to use this connector within Airbyte, see [the User Documentation](https://docs.airbyte.io/integrations/destinations/rockset). | ||
|
||
## Local development | ||
|
||
#### Building via Gradle | ||
From the Airbyte repository root, run: | ||
``` | ||
./gradlew :airbyte-integrations:connectors:destination-rockset: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.io/contributing-to-airbyte/building-new-connector#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-rockset: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-rockset:dev spec | ||
docker run --rm -v $(pwd)/secrets:/secrets airbyte/destination-rockset:dev check --config /secrets/config.json | ||
docker run --rm -v $(pwd)/secrets:/secrets airbyte/destination-rockset:dev discover --config /secrets/config.json | ||
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/destination-rockset: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/rockset`. | ||
|
||
#### 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/rocksetDestinationAcceptanceTest.java`. | ||
|
||
### Using gradle to run tests | ||
All commands should be run from airbyte project root. | ||
To run unit tests: | ||
``` | ||
./gradlew :airbyte-integrations:connectors:destination-rockset:unitTest | ||
``` | ||
To run acceptance and custom integration tests: | ||
``` | ||
./gradlew :airbyte-integrations:connectors:destination-rockset: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. |
29 changes: 29 additions & 0 deletions
29
airbyte-integrations/connectors/destination-rockset/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,29 @@ | ||
plugins { | ||
id 'application' | ||
id 'airbyte-docker' | ||
id 'airbyte-integration-test-java' | ||
} | ||
|
||
application { | ||
mainClass = 'io.airbyte.integrations.destination.rockset.RocksetDestination' | ||
} | ||
|
||
repositories { | ||
maven { url "https://mvnrepository.com/artifact/com.rockset/rockset-java" } | ||
maven { url "https://mvnrepository.com/artifact/org.awaitility/awaitility" } | ||
} | ||
|
||
dependencies { | ||
implementation project(':airbyte-config:models') | ||
implementation project(':airbyte-protocol:models') | ||
implementation project(':airbyte-integrations:bases:base-java') | ||
implementation files(project(':airbyte-integrations:bases:base-java').airbyteDocker.outputs) | ||
implementation project(':airbyte-integrations:connectors:destination-jdbc') | ||
|
||
implementation group: 'com.rockset', name: 'rockset-java', version: '0.9.0' | ||
implementation group: 'org.awaitility', name: 'awaitility', version: '4.1.1' | ||
|
||
|
||
integrationTestJavaImplementation project(':airbyte-integrations:bases:standard-destination-test') | ||
integrationTestJavaImplementation project(':airbyte-integrations:connectors:destination-rockset') | ||
} |
94 changes: 94 additions & 0 deletions
94
...rockset/src/main/java/io/airbyte/integrations/destination/rockset/RocksetDestination.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,94 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.rockset; | ||
|
||
import static io.airbyte.integrations.destination.rockset.RocksetUtils.ROCKSET_WORKSPACE_ID; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.rockset.client.ApiClient; | ||
import com.rockset.client.api.DocumentsApi; | ||
import com.rockset.client.model.AddDocumentsRequest; | ||
import io.airbyte.integrations.BaseConnector; | ||
import io.airbyte.integrations.base.AirbyteMessageConsumer; | ||
import io.airbyte.integrations.base.Destination; | ||
import io.airbyte.integrations.base.IntegrationRunner; | ||
import io.airbyte.protocol.models.AirbyteConnectionStatus; | ||
import io.airbyte.protocol.models.AirbyteConnectionStatus.Status; | ||
import io.airbyte.protocol.models.AirbyteMessage; | ||
import io.airbyte.protocol.models.ConfiguredAirbyteCatalog; | ||
|
||
import java.util.Map; | ||
import java.util.UUID; | ||
import java.util.function.Consumer; | ||
|
||
import org.apache.commons.lang3.RandomStringUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class RocksetDestination extends BaseConnector implements Destination { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(RocksetDestination.class); | ||
private static final ObjectMapper mapper = new ObjectMapper(); | ||
|
||
public static void main(String[] args) throws Exception { | ||
new IntegrationRunner(new RocksetDestination()).run(args); | ||
} | ||
|
||
@Override | ||
public AirbyteConnectionStatus check(final JsonNode config) { | ||
ApiClient client = null; | ||
String workspace = null; | ||
// Create a temporary table | ||
final String cname = "tmp_test_airbyte_collection_" + RandomStringUtils.randomAlphabetic(7).toLowerCase(); | ||
|
||
try { | ||
client = RocksetUtils.apiClientFromConfig(config); | ||
|
||
workspace = config.get(ROCKSET_WORKSPACE_ID).asText(); | ||
RocksetUtils.createWorkspaceIfNotExists(client, workspace); | ||
|
||
|
||
RocksetUtils.createCollectionIfNotExists(client, workspace, cname); | ||
RocksetUtils.waitUntilCollectionReady(client, workspace, cname); | ||
|
||
// Write a single document | ||
final String unique = UUID.randomUUID().toString(); | ||
final Map<String, String> dummyRecord = ImmutableMap.of("_id", unique); | ||
final AddDocumentsRequest req = new AddDocumentsRequest(); | ||
req.addDataItem(mapper.convertValue(dummyRecord, new TypeReference<>() { | ||
})); | ||
new DocumentsApi(client).add(workspace, cname, req); | ||
|
||
// Verify that the doc shows up | ||
final String sql = String.format("SELECT * FROM %s.%s WHERE _id = '%s';", workspace, cname, unique); | ||
RocksetUtils.waitUntilDocCount(client, sql, 1); | ||
|
||
LOGGER.info("Check succeeded"); | ||
return new AirbyteConnectionStatus().withStatus(Status.SUCCEEDED); | ||
} catch (Exception e) { | ||
LOGGER.info("Check failed.", e); | ||
return new AirbyteConnectionStatus().withStatus(Status.FAILED).withMessage(e.getMessage() != null ? e.getMessage() : e.toString()); | ||
} finally { | ||
// Delete the collection | ||
if (client != null && workspace != null) { | ||
RocksetUtils.deleteCollectionIfExists(client, workspace, cname); | ||
} | ||
|
||
} | ||
} | ||
|
||
@Override | ||
public AirbyteMessageConsumer getConsumer( | ||
JsonNode config, | ||
ConfiguredAirbyteCatalog catalog, | ||
Consumer<AirbyteMessage> outputRecordCollector) | ||
throws Exception { | ||
return new RocksetWriteApiConsumer(config, catalog, outputRecordCollector); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
.../src/main/java/io/airbyte/integrations/destination/rockset/RocksetSQLNameTransformer.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,21 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.rockset; | ||
|
||
import io.airbyte.integrations.destination.ExtendedNameTransformer; | ||
|
||
public class RocksetSQLNameTransformer extends ExtendedNameTransformer { | ||
|
||
@Override | ||
public String convertStreamName(String input) { | ||
return super.convertStreamName(input).toLowerCase(); | ||
} | ||
|
||
@Override | ||
protected String applyDefaultCase(String input) { | ||
return input.toLowerCase(); | ||
} | ||
|
||
} |
Oops, something went wrong.