You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2021/09/09 19:59:31 UTC

[incubator-streampipes-extensions] branch dev updated: [STREAMPIPES-79] Remove timestamp field from events in data lake sink

This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git


The following commit(s) were added to refs/heads/dev by this push:
     new ec83577  [STREAMPIPES-79] Remove timestamp field from events in data lake sink
ec83577 is described below

commit ec835778c2548b2bed8a59f285bc66fae5e8a6c0
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Thu Sep 9 21:58:45 2021 +0200

    [STREAMPIPES-79] Remove timestamp field from events in data lake sink
---
 .../streampipes/sinks/internal/jvm/datalake/DataLake.java     | 11 ++++++++---
 .../sinks/internal/jvm/datalake/DataLakeInfluxDbClient.java   |  4 +---
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/datalake/DataLake.java b/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/datalake/DataLake.java
index 2fc6163..d7134f1 100644
--- a/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/datalake/DataLake.java
+++ b/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/datalake/DataLake.java
@@ -76,10 +76,18 @@ public class DataLake implements EventSink<DataLakeParameters> {
     );
 
     EventSchema schema = runtimeContext.getInputSchemaInfo().get(0).getEventSchema();
+    // Remove the timestamp field from the event schema
+    List<EventProperty> eventPropertiesWithoutTimestamp = schema.getEventProperties()
+            .stream()
+            .filter(eventProperty -> !this.timestampField.endsWith(eventProperty.getRuntimeName()))
+            .collect(Collectors.toList());
+    schema.setEventProperties(eventPropertiesWithoutTimestamp);
 
     // deep copy of event schema. Event property runtime name is changed to lower case for the schema registration
     this.eventSchema = new EventSchema(schema);
 
+
+
     schema.getEventProperties().stream().forEach(eventProperty -> {
       eventProperty.setRuntimeName(prepareString(eventProperty.getRuntimeName()));
     });
@@ -97,7 +105,6 @@ public class DataLake implements EventSink<DataLakeParameters> {
 
   @Override
   public void onEvent(Event event) {
-
     try {
 
       this.imageProperties.stream().forEach(eventProperty -> {
@@ -111,8 +118,6 @@ public class DataLake implements EventSink<DataLakeParameters> {
         event.updateFieldBySelector("s0::" + eventProperty.getRuntimeName(), fileRoute);
       });
 
-      event.addField("sp_internal_label", "");
-
       influxDbClient.save(event, this.eventSchema);
     } catch (SpRuntimeException e) {
       LOG.error(e.getMessage());
diff --git a/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/datalake/DataLakeInfluxDbClient.java b/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/datalake/DataLakeInfluxDbClient.java
index 6feb5be..eb7cd62 100644
--- a/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/datalake/DataLakeInfluxDbClient.java
+++ b/streampipes-sinks-internal-jvm/src/main/java/org/apache/streampipes/sinks/internal/jvm/datalake/DataLakeInfluxDbClient.java
@@ -177,9 +177,7 @@ public class DataLakeInfluxDbClient {
             if (ep instanceof EventPropertyPrimitive) {
                 String runtimeName = ep.getRuntimeName();
 
-
-
-                if (!runtimeName.equals(timestampField.split("::")[1])) {
+                if (!timestampField.endsWith(runtimeName)) {
                     String preparedRuntimeName = DataLake.prepareString(runtimeName);
                     PrimitiveField eventPropertyPrimitiveField = event.getFieldByRuntimeName(runtimeName).getAsPrimitive();