Skip to content

Commit

Permalink
Merge pull request #363 from cognitedata/add-instances-type-to-transf…
Browse files Browse the repository at this point in the history
…ormation-jobs

transformations: add support for data model destination type
  • Loading branch information
dsorenes authored Feb 19, 2024
2 parents 2d9f95c + 23551b3 commit 4ba0f3c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ SDK v2
<dependency>
<groupId>com.cognite</groupId>
<artifactId>cdf-sdk-java</artifactId>
<version>2.2.1</version>
<version>2.3.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.cognite</groupId>
<artifactId>cdf-sdk-java</artifactId>
<version>2.2.1</version>
<version>2.3.0</version>
<licenses>
<license>
<name>Apache 2</name>
Expand Down
6 changes: 6 additions & 0 deletions releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Changes are grouped as follows:
- Extraction pipelines configuration
- Data models

## [2.3.0] 2024-02-13

### Added

- Added support for returning data model destination type when retrieving transformation jobs.

## [2.2.1] 2023-11-16

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,35 @@ public static void extractNodes(Transformation.Job.Builder tmBuilder, JsonNode r
builderDest.setExternalId(sequenceRowDataSourceNode.path("externalId").textValue());
}
tmBuilder.setDestination(builderDest.build());
} else if (root.path("destination").path("type").textValue().equals("instances")) {
JsonNode instanceDataSourceNode = root.path("destination");
Transformation.Destination.Builder builderDest = Transformation.Destination.newBuilder();

builderDest.setType(instanceDataSourceNode.path("type").textValue());

if (instanceDataSourceNode.path("dataModel").isObject()) {
JsonNode dataModelSourceNode = instanceDataSourceNode.path("dataModel");
Transformation.Destination.Datamodel.Builder dataModelBuilderDest = Transformation.Destination.Datamodel.newBuilder();
JsonNode space = dataModelSourceNode.path("space");
JsonNode externalId = dataModelSourceNode.path("externalId");
JsonNode version = dataModelSourceNode.path("version");
JsonNode destinationType = dataModelSourceNode.path("destinationType");
if (space.isTextual())
dataModelBuilderDest.setSpace(space.textValue());
if (externalId.isTextual())
dataModelBuilderDest.setExternalId(externalId.textValue());
if (version.isTextual())
dataModelBuilderDest.setVersion(version.textValue());
if (destinationType.isTextual())
dataModelBuilderDest.setDestinationType(destinationType.textValue());

builderDest.setDataModel(dataModelBuilderDest.build());
}
JsonNode instanceSpace = instanceDataSourceNode.path("instanceSpace");
if (instanceSpace.isTextual())
builderDest.setInstanceSpace(instanceSpace.textValue());

tmBuilder.setDestination(builderDest.build());
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/proto/transformation.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ message Transformation {

message Destination {

message Datamodel {
string space = 1;
string external_id = 2;
string version = 3;
string destination_type = 4;
string destination_relationship_from_type = 5;
}

enum DataSourceType {
ASSETS = 0;
TIMESERIES = 1;
Expand All @@ -24,12 +32,15 @@ message Transformation {
LABELS = 9;
RELATIONSHIPS = 10;
DATA_SETS = 11;
INSTANCES = 12;
}

optional string type = 2;
optional string database = 3;
optional string table = 4;
string external_id = 5;
optional Datamodel data_model = 6;
optional string instance_space = 7;
}

message FlatOidcCredentials {
Expand Down

0 comments on commit 4ba0f3c

Please sign in to comment.