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 2026/03/13 15:15:26 UTC

(streampipes) branch 4250-add-csv-dataset-import-with-preview-for-data-sets updated (038007ba62 -> 30660e94dc)

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

zehnder pushed a change to branch 4250-add-csv-dataset-import-with-preview-for-data-sets
in repository https://gitbox.apache.org/repos/asf/streampipes.git


    from 038007ba62 chore(deps): bump actions/upload-artifact from 6 to 7 (#4206)
     new fd812634bc feat(#4250): First version of the csv upload
     new 30660e94dc feat(#4250): Improve upload dialog

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .idea/runConfigurations/AllExtensionsIIoTInit.xml  |    1 +
 .../model/datalake/importer/CsvImportColumn.java   |  104 ++
 .../datalake/importer/CsvImportConfiguration.java  |   43 +-
 .../CsvImportPreviewRequest.java}                  |   63 +-
 .../datalake/importer/CsvImportPreviewResult.java  |  100 ++
 .../model/datalake/importer/CsvImportRequest.java  |   89 ++
 .../model/datalake/importer/CsvImportResult.java   |   71 ++
 .../datalake/importer/CsvImportSchemaIssue.java    |   74 ++
 .../importer/CsvImportSchemaIssueType.java         |   11 +-
 .../CsvImportSchemaValidationRequest.java}         |   37 +-
 .../importer/CsvImportSchemaValidationResult.java  |   45 +-
 .../importer/CsvImportTarget.java}                 |   22 +-
 .../datalake/importer/CsvImportTargetMode.java     |    6 +-
 .../importer/CsvImportValidationMessage.java       |   32 +-
 .../impl/datalake/CsvDataLakeImportService.java    | 1199 ++++++++++++++++++++
 .../rest/impl/datalake/CsvImportUploadStorage.java |  130 +++
 .../datalake/CsvImportValidationException.java     |   24 +-
 .../rest/impl/datalake/DataLakeDataWriter.java     |   52 +-
 .../rest/impl/datalake/DataLakeImportResource.java |  122 ++
 .../datalake/CsvDataLakeImportServiceTest.java     |  326 ++++++
 .../rest/impl/datalake/DataLakeDataWriterTest.java |   56 +
 ...hine-data-simulator-import-later-timestamps.csv |    8 +
 ...-data-simulator-import-mismatched-timestamp.csv |    8 +
 ...achine-data-simulator-import-missing-values.csv |    8 +
 ...hine-data-simulator-import-string-timestamp.csv |    8 +
 .../datalake/machine-data-simulator-import.csv     |    8 +
 ui/cypress/support/utils/dataset/DatasetBtns.ts    |   97 ++
 ui/cypress/support/utils/dataset/DatasetUtils.ts   |  108 ++
 ui/cypress/tests/dataset/csvImport.spec.ts         |   96 ++
 .../src/lib/apis/datalake-rest.service.ts          |   34 +
 .../src/lib/model/datalake/csv-import.model.ts     |  111 ++
 .../platform-services/src/public-api.ts            |    1 +
 .../datalake-configuration.component.html          |    9 +
 .../datalake-configuration.component.ts            |   21 +
 .../csv-import-dialog.component.html               |  523 +++++++++
 .../csv-import-dialog.component.scss               |  236 ++++
 .../csv-import-dialog.component.ts                 |  854 ++++++++++++++
 37 files changed, 4589 insertions(+), 148 deletions(-)
 create mode 100644 streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportColumn.java
 copy streampipes-extensions/streampipes-processors-transformation-jvm/src/main/java/org/apache/streampipes/processors/transformation/jvm/processor/state/labeler/model/Statement.java => streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportConfiguration.java (52%)
 copy streampipes-model/src/main/java/org/apache/streampipes/model/datalake/{DataSeries.java => importer/CsvImportPreviewRequest.java} (54%)
 create mode 100644 streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportPreviewResult.java
 create mode 100644 streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportRequest.java
 create mode 100644 streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportResult.java
 create mode 100644 streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportSchemaIssue.java
 copy streampipes-client-api/src/main/java/org/apache/streampipes/client/api/live/EventProcessor.java => streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportSchemaIssueType.java (80%)
 copy streampipes-model/src/main/java/org/apache/streampipes/model/{grounding/TransportFormat.java => datalake/importer/CsvImportSchemaValidationRequest.java} (56%)
 copy streampipes-extensions-api/src/main/java/org/apache/streampipes/extensions/api/monitoring/FixedSizeList.java => streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportSchemaValidationResult.java (53%)
 copy streampipes-model/src/main/java/org/apache/streampipes/model/{NotificationCount.java => datalake/importer/CsvImportTarget.java} (64%)
 copy streampipes-connect-transformer-api/src/main/java/org/apache/streampipes/connect/transformer/api/Context.java => streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportTargetMode.java (88%)
 copy streampipes-rest-shared/src/main/java/org/apache/streampipes/rest/shared/exception/SpLogMessageException.java => streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportValidationMessage.java (62%)
 create mode 100644 streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportService.java
 create mode 100644 streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvImportUploadStorage.java
 copy streampipes-model/src/main/java/org/apache/streampipes/model/export/ExportConfiguration.java => streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvImportValidationException.java (57%)
 create mode 100644 streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeImportResource.java
 create mode 100644 streampipes-rest/src/test/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportServiceTest.java
 create mode 100644 streampipes-rest/src/test/java/org/apache/streampipes/rest/impl/datalake/DataLakeDataWriterTest.java
 create mode 100644 ui/cypress/fixtures/datalake/machine-data-simulator-import-later-timestamps.csv
 create mode 100644 ui/cypress/fixtures/datalake/machine-data-simulator-import-mismatched-timestamp.csv
 create mode 100644 ui/cypress/fixtures/datalake/machine-data-simulator-import-missing-values.csv
 create mode 100644 ui/cypress/fixtures/datalake/machine-data-simulator-import-string-timestamp.csv
 create mode 100644 ui/cypress/fixtures/datalake/machine-data-simulator-import.csv
 create mode 100644 ui/cypress/tests/dataset/csvImport.spec.ts
 create mode 100644 ui/projects/streampipes/platform-services/src/lib/model/datalake/csv-import.model.ts
 create mode 100644 ui/src/app/dataset/dialog/csv-import-dialog/csv-import-dialog.component.html
 create mode 100644 ui/src/app/dataset/dialog/csv-import-dialog/csv-import-dialog.component.scss
 create mode 100644 ui/src/app/dataset/dialog/csv-import-dialog/csv-import-dialog.component.ts


(streampipes) 02/02: feat(#4250): Improve upload dialog

Posted by ze...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch 4250-add-csv-dataset-import-with-preview-for-data-sets
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit 30660e94dc1e177694975b4c0c9bfa7d2af6277d
Author: Philipp Zehnder <te...@users.noreply.github.com>
AuthorDate: Fri Mar 13 16:15:16 2026 +0100

    feat(#4250): Improve upload dialog
---
 .../datalake/importer/CsvImportPreviewRequest.java |   9 +
 .../datalake/importer/CsvImportPreviewResult.java  |   9 +
 .../model/datalake/importer/CsvImportRequest.java  |   9 +
 .../impl/datalake/CsvDataLakeImportService.java    | 578 ++++++++++++++++++---
 .../rest/impl/datalake/CsvImportUploadStorage.java | 130 +++++
 .../rest/impl/datalake/DataLakeDataWriter.java     |  47 +-
 .../rest/impl/datalake/DataLakeImportResource.java |  44 +-
 .../datalake/CsvDataLakeImportServiceTest.java     | 109 +++-
 .../rest/impl/datalake/DataLakeDataWriterTest.java |  56 ++
 ...achine-data-simulator-import-missing-values.csv |   8 +
 10 files changed, 914 insertions(+), 85 deletions(-)

diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportPreviewRequest.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportPreviewRequest.java
index 84e52dbeb1..7af3a0f44b 100644
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportPreviewRequest.java
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportPreviewRequest.java
@@ -22,12 +22,21 @@ import java.util.List;
 
 public class CsvImportPreviewRequest {
 
+  private String uploadId;
   private String fileName;
   private CsvImportConfiguration csvConfig;
   private List<String> headers;
   private List<List<String>> rows;
   private CsvImportTarget target;
 
+  public String getUploadId() {
+    return uploadId;
+  }
+
+  public void setUploadId(String uploadId) {
+    this.uploadId = uploadId;
+  }
+
   public String getFileName() {
     return fileName;
   }
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportPreviewResult.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportPreviewResult.java
index 6f6ebcf227..4bb9b84cf8 100644
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportPreviewResult.java
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportPreviewResult.java
@@ -25,6 +25,7 @@ import java.util.List;
 
 public class CsvImportPreviewResult {
 
+  private String uploadId;
   private List<String> headers = new ArrayList<>();
   private List<List<String>> previewRows = new ArrayList<>();
   private List<CsvImportColumn> columns = new ArrayList<>();
@@ -33,6 +34,14 @@ public class CsvImportPreviewResult {
   private boolean valid;
   private List<CsvImportValidationMessage> validationMessages = new ArrayList<>();
 
+  public String getUploadId() {
+    return uploadId;
+  }
+
+  public void setUploadId(String uploadId) {
+    this.uploadId = uploadId;
+  }
+
   public List<String> getHeaders() {
     return headers;
   }
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportRequest.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportRequest.java
index e571bae89e..c882562ae7 100644
--- a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportRequest.java
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportRequest.java
@@ -23,6 +23,7 @@ import java.util.List;
 
 public class CsvImportRequest {
 
+  private String uploadId;
   private CsvImportConfiguration csvConfig;
   private List<String> headers = new ArrayList<>();
   private List<List<String>> rows = new ArrayList<>();
@@ -30,6 +31,14 @@ public class CsvImportRequest {
   private String timestampColumn;
   private List<CsvImportColumn> columns = new ArrayList<>();
 
+  public String getUploadId() {
+    return uploadId;
+  }
+
+  public void setUploadId(String uploadId) {
+    this.uploadId = uploadId;
+  }
+
   public CsvImportConfiguration getCsvConfig() {
     return csvConfig;
   }
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportService.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportService.java
index a36980446e..8848170b08 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportService.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportService.java
@@ -22,7 +22,6 @@ import org.apache.streampipes.connect.management.util.EventSchemaUtils;
 import org.apache.streampipes.dataexplorer.api.IDataExplorerSchemaManagement;
 import org.apache.streampipes.model.datalake.DataLakeMeasure;
 import org.apache.streampipes.model.datalake.DataSeriesBuilder;
-import org.apache.streampipes.model.datalake.SpQueryResult;
 import org.apache.streampipes.model.datalake.SpQueryResultBuilder;
 import org.apache.streampipes.model.datalake.importer.CsvImportColumn;
 import org.apache.streampipes.model.datalake.importer.CsvImportConfiguration;
@@ -44,6 +43,14 @@ import org.apache.streampipes.model.schema.PropertyScope;
 import org.apache.streampipes.vocabulary.SO;
 import org.apache.streampipes.vocabulary.XSD;
 
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.io.PushbackReader;
+import java.io.UncheckedIOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.time.Instant;
 import java.time.LocalDateTime;
 import java.time.ZoneOffset;
@@ -61,47 +68,85 @@ import java.util.stream.Collectors;
 public class CsvDataLakeImportService {
 
   private static final int MAX_PREVIEW_ROWS = 50;
+  private static final int MAX_ANALYSIS_ROWS = 200;
+  private static final int IMPORT_BATCH_SIZE = 5000;
   private static final String STREAM_PREFIX = "s0::";
 
   private final IDataExplorerSchemaManagement schemaManagement;
   private final DataLakeDataWriter dataWriter;
+  private final CsvImportUploadStorage uploadStorage;
 
   public CsvDataLakeImportService(IDataExplorerSchemaManagement schemaManagement) {
     this(
         schemaManagement,
-        new DataLakeDataWriter(false)
+        new DataLakeDataWriter(false, true),
+        new CsvImportUploadStorage()
     );
   }
 
   CsvDataLakeImportService(
       IDataExplorerSchemaManagement schemaManagement,
       DataLakeDataWriter dataWriter
+  ) {
+    this(schemaManagement, dataWriter, new CsvImportUploadStorage());
+  }
+
+  CsvDataLakeImportService(
+      IDataExplorerSchemaManagement schemaManagement,
+      DataLakeDataWriter dataWriter,
+      CsvImportUploadStorage uploadStorage
   ) {
     this.schemaManagement = schemaManagement;
     this.dataWriter = dataWriter;
+    this.uploadStorage = uploadStorage;
   }
 
   public CsvImportPreviewResult preview(CsvImportPreviewRequest request) {
     var validationMessages = validatePreviewRequest(request);
     var headers = sanitizeHeaders(request.getHeaders());
     var rows = Optional.ofNullable(request.getRows()).orElseGet(Collections::emptyList);
+    return buildPreviewResult(request, headers, rows, validationMessages, null);
+  }
 
-    var columns = inferColumns(headers, rows, request.getCsvConfig());
-    var eventSchema = buildEventSchema(columns, rows, request.getCsvConfig(), null);
-    validationMessages.addAll(validatePreviewTarget(request.getTarget()));
+  public CsvImportPreviewResult preview(CsvImportPreviewRequest request, String principalSid) {
+    if (!hasUploadId(request)) {
+      return preview(request);
+    }
 
-    var result = new CsvImportPreviewResult();
-    result.setHeaders(headers);
-    result.setPreviewRows(rows.stream().limit(MAX_PREVIEW_ROWS).collect(Collectors.toList()));
-    result.setColumns(columns);
-    result.setGuessedEventSchema(eventSchema);
-    result.setTimestampCandidates(columns.stream()
-        .filter(CsvImportColumn::isTimestampCandidate)
-        .map(CsvImportColumn::getRuntimeName)
-        .collect(Collectors.toList()));
-    result.setValidationMessages(validationMessages);
-    result.setValid(validationMessages.isEmpty());
-    return result;
+    var validationMessages = validatePreviewConfiguration(request);
+    if (!validationMessages.isEmpty()) {
+      return buildInvalidPreviewResult(validationMessages, request.getUploadId());
+    }
+
+    try {
+      var upload = resolveUpload(request.getUploadId(), principalSid);
+      var csvSample = readCsvSample(upload.path(), request.getCsvConfig(), MAX_ANALYSIS_ROWS);
+      return buildPreviewResult(request, csvSample.headers(), csvSample.rows(), validationMessages, upload.uploadId());
+    } catch (CsvImportValidationException e) {
+      return buildInvalidPreviewResult(e.getValidationMessages(), request.getUploadId());
+    } catch (IOException | UncheckedIOException e) {
+      return buildInvalidPreviewResult(
+          List.of(message("file", "The CSV file could not be parsed with the current settings.")),
+          request.getUploadId()
+      );
+    }
+  }
+
+  public CsvImportPreviewResult preview(MultipartFile file, CsvImportPreviewRequest request, String principalSid)
+      throws IOException {
+    var validationMessages = validatePreviewConfiguration(request);
+    if (!validationMessages.isEmpty()) {
+      return buildInvalidPreviewResult(validationMessages, null);
+    }
+
+    var upload = uploadStorage.store(file, principalSid);
+    try {
+      var csvSample = readCsvSample(upload.path(), request.getCsvConfig(), MAX_ANALYSIS_ROWS);
+      return buildPreviewResult(request, csvSample.headers(), csvSample.rows(), validationMessages, upload.uploadId());
+    } catch (IOException | UncheckedIOException e) {
+      uploadStorage.remove(upload.uploadId());
+      throw e;
+    }
   }
 
   public CsvImportSchemaValidationResult validateSchema(CsvImportSchemaValidationRequest request) {
@@ -127,7 +172,11 @@ public class CsvDataLakeImportService {
   }
 
   public CsvImportResult importData(CsvImportRequest request, String principalSid) {
-    var validationMessages = validateImportRequest(request);
+    if (hasUploadId(request)) {
+      return importUploadedData(request, principalSid);
+    }
+
+    var validationMessages = validateInlineImportRequest(request);
     if (!validationMessages.isEmpty()) {
       throw new CsvImportValidationException(validationMessages);
     }
@@ -158,8 +207,14 @@ public class CsvDataLakeImportService {
       measure = requireExistingMeasurement(request.getTarget().getMeasurementName());
     }
 
-    var queryResult = toQueryResult(request);
-    dataWriter.writeData(measure, queryResult);
+    var queryResult = DataSeriesBuilder.create()
+        .withHeaders(request.getColumns().stream().map(CsvImportColumn::getRuntimeName).collect(Collectors.toList()))
+        .withRows(toImportRows(request))
+        .build();
+    dataWriter.writeData(
+        measure,
+        SpQueryResultBuilder.create(queryResult.getHeaders()).withDataSeries(queryResult).build()
+    );
 
     var result = new CsvImportResult();
     result.setMeasurementId(measure.getElementId());
@@ -170,12 +225,211 @@ public class CsvDataLakeImportService {
     return result;
   }
 
-  private List<CsvImportValidationMessage> validatePreviewRequest(CsvImportPreviewRequest request) {
+  private CsvImportResult importUploadedData(CsvImportRequest request, String principalSid) {
+    var validationMessages = validateStoredImportRequest(request);
+    if (!validationMessages.isEmpty()) {
+      throw new CsvImportValidationException(validationMessages);
+    }
+
+    var upload = resolveUpload(request.getUploadId(), principalSid);
+    var sanitizedColumns = sanitizeImportColumns(request.getColumns());
+    var eventSchema = buildConfiguredEventSchema(sanitizedColumns, request.getTimestampColumn());
+
+    validationMessages.addAll(validateImportTarget(request.getTarget(), eventSchema, request.getTimestampColumn()));
+    if (!validationMessages.isEmpty()) {
+      throw new CsvImportValidationException(validationMessages);
+    }
+
+    var createdNewMeasurement = false;
+    DataLakeMeasure measure;
+
+    if (request.getTarget().getMode() == CsvImportTargetMode.NEW) {
+      measure = new DataLakeMeasure();
+      measure.setMeasureName(request.getTarget().getMeasurementName().trim());
+      measure.setTimestampField(STREAM_PREFIX + request.getTimestampColumn());
+      measure.setEventSchema(eventSchema);
+      measure = schemaManagement.createOrUpdateMeasurement(measure, principalSid);
+      createdNewMeasurement = true;
+    } else {
+      measure = requireExistingMeasurement(request.getTarget().getMeasurementName());
+    }
+
+    try {
+      var importedRowCount = importCsvFile(upload.path(), request, measure);
+      uploadStorage.remove(upload.uploadId());
+
+      var result = new CsvImportResult();
+      result.setMeasurementId(measure.getElementId());
+      result.setMeasurementName(measure.getMeasureName());
+      result.setCreatedNewMeasurement(createdNewMeasurement);
+      result.setImportedRowCount(importedRowCount);
+      result.setValidationMessages(List.of());
+      return result;
+    } catch (IOException | UncheckedIOException e) {
+      throw new CsvImportValidationException(List.of(
+          message("file", "The CSV file could not be parsed with the current settings.")
+      ));
+    }
+  }
+
+  private CsvImportPreviewResult buildPreviewResult(
+      CsvImportPreviewRequest request,
+      List<String> headers,
+      List<List<String>> rows,
+      List<CsvImportValidationMessage> validationMessages,
+      String uploadId
+  ) {
+    var messages = new ArrayList<>(validationMessages);
+    var columns = inferColumns(headers, rows, request.getCsvConfig());
+    var eventSchema = buildEventSchema(columns, rows, request.getCsvConfig(), null);
+    messages.addAll(validatePreviewTarget(request.getTarget()));
+
+    var result = new CsvImportPreviewResult();
+    result.setUploadId(uploadId);
+    result.setHeaders(headers);
+    result.setPreviewRows(rows.stream().limit(MAX_PREVIEW_ROWS).collect(Collectors.toList()));
+    result.setColumns(columns);
+    result.setGuessedEventSchema(eventSchema);
+    result.setTimestampCandidates(columns.stream()
+        .filter(CsvImportColumn::isTimestampCandidate)
+        .map(CsvImportColumn::getRuntimeName)
+        .collect(Collectors.toList()));
+    result.setValidationMessages(messages);
+    result.setValid(messages.isEmpty());
+    return result;
+  }
+
+  private CsvImportPreviewResult buildInvalidPreviewResult(
+      List<CsvImportValidationMessage> validationMessages,
+      String uploadId
+  ) {
+    var result = new CsvImportPreviewResult();
+    result.setUploadId(uploadId);
+    result.setValidationMessages(validationMessages);
+    result.setValid(false);
+    return result;
+  }
+
+  private List<List<Object>> toImportRows(CsvImportRequest request) {
+    var rows = new ArrayList<List<Object>>();
+    for (int rowIndex = 0; rowIndex < request.getRows().size(); rowIndex++) {
+      rows.add(convertRow(request.getRows().get(rowIndex), request, rowIndex + 1));
+    }
+    return rows;
+  }
+
+  private int importCsvFile(Path path, CsvImportRequest request, DataLakeMeasure measure) throws IOException {
+    var runtimeHeaders = request.getColumns().stream()
+        .map(CsvImportColumn::getRuntimeName)
+        .collect(Collectors.toList());
+    var batch = new ArrayList<List<Object>>();
+    var importedRows = new int[]{0};
+
+    parseCsvFile(path, request.getCsvConfig(), new CsvRowConsumer() {
+      private List<String> parsedHeaders;
+
+      @Override
+      public void onHeaders(List<String> headers) {
+        parsedHeaders = headers;
+        validateUploadedHeaders(headers, request.getColumns());
+      }
+
+      @Override
+      public void onRow(int rowNumber, List<String> row) {
+        if (row.size() != parsedHeaders.size()) {
+          throw new CsvImportValidationException(List.of(
+              message("rows", "Row " + rowNumber + " does not match the header size.")
+          ));
+        }
+        batch.add(convertRow(row, request, rowNumber));
+        if (batch.size() >= IMPORT_BATCH_SIZE) {
+          flushImportBatch(measure, runtimeHeaders, batch);
+          importedRows[0] += IMPORT_BATCH_SIZE;
+          batch.clear();
+        }
+      }
+    });
+
+    if (!batch.isEmpty()) {
+      var batchSize = batch.size();
+      flushImportBatch(measure, runtimeHeaders, batch);
+      importedRows[0] += batchSize;
+    }
+
+    return importedRows[0];
+  }
+
+  private void flushImportBatch(DataLakeMeasure measure, List<String> runtimeHeaders, List<List<Object>> batch) {
+    dataWriter.writeData(measure, runtimeHeaders, new ArrayList<>(batch));
+  }
+
+  private List<Object> convertRow(List<String> row, CsvImportRequest request, int rowNumber) {
+    var converted = new ArrayList<Object>();
+    for (int i = 0; i < row.size(); i++) {
+      converted.add(convertValue(
+          row.get(i),
+          request.getColumns().get(i),
+          request.getCsvConfig(),
+          request.getTimestampColumn(),
+          rowNumber
+      ));
+    }
+    return converted;
+  }
+
+  private void validateUploadedHeaders(List<String> headers, List<CsvImportColumn> columns) {
+    if (headers.size() != columns.size()) {
+      throw new CsvImportValidationException(List.of(
+          message("headers", "The uploaded CSV file no longer matches the previewed column count.")
+      ));
+    }
+
+    for (int i = 0; i < headers.size(); i++) {
+      if (!Objects.equals(headers.get(i), columns.get(i).getCsvColumn())) {
+        throw new CsvImportValidationException(List.of(
+            message("headers", "The uploaded CSV file no longer matches the previewed headers.")
+        ));
+      }
+    }
+  }
+
+  private CsvImportUploadStorage.StoredUpload resolveUpload(String uploadId, String principalSid) {
+    var upload = uploadStorage.get(uploadId).orElseThrow(() -> new CsvImportValidationException(List.of(
+        message("uploadId", "The uploaded CSV file was not found. Please upload the file again.")
+    )));
+
+    if (!Objects.equals(upload.ownerSid(), principalSid)) {
+      throw new CsvImportValidationException(List.of(
+          message("uploadId", "The uploaded CSV file is no longer available for this user.")
+      ));
+    }
+
+    return upload;
+  }
+
+  private boolean hasUploadId(CsvImportPreviewRequest request) {
+    return request != null && request.getUploadId() != null && !request.getUploadId().isBlank();
+  }
+
+  private boolean hasUploadId(CsvImportRequest request) {
+    return request != null && request.getUploadId() != null && !request.getUploadId().isBlank();
+  }
+
+  private List<CsvImportValidationMessage> validatePreviewConfiguration(CsvImportPreviewRequest request) {
     var messages = new ArrayList<CsvImportValidationMessage>();
     if (request == null) {
       messages.add(message("request", "Import request must be provided."));
       return messages;
     }
+    validateCsvConfig(request.getCsvConfig(), messages);
+    return messages;
+  }
+
+  private List<CsvImportValidationMessage> validatePreviewRequest(CsvImportPreviewRequest request) {
+    var messages = validatePreviewConfiguration(request);
+    if (request == null) {
+      return messages;
+    }
     if (request.getHeaders() == null || request.getHeaders().isEmpty()) {
       messages.add(message("headers", "At least one header must be provided."));
     }
@@ -183,14 +437,12 @@ public class CsvDataLakeImportService {
       messages.add(message("rows", "At least one row must be provided."));
     }
     validateRowsMatchHeaders(request.getHeaders(), request.getRows(), messages);
-    validateCsvConfig(request.getCsvConfig(), messages);
     return messages;
   }
 
-  private List<CsvImportValidationMessage> validateImportRequest(CsvImportRequest request) {
-    var messages = new ArrayList<CsvImportValidationMessage>();
+  private List<CsvImportValidationMessage> validateInlineImportRequest(CsvImportRequest request) {
+    var messages = validateStoredImportRequest(request);
     if (request == null) {
-      messages.add(message("request", "Import request must be provided."));
       return messages;
     }
     if (request.getHeaders() == null || request.getHeaders().isEmpty()) {
@@ -200,6 +452,15 @@ public class CsvDataLakeImportService {
       messages.add(message("rows", "At least one row must be provided."));
     }
     validateRowsMatchHeaders(request.getHeaders(), request.getRows(), messages);
+    return messages;
+  }
+
+  private List<CsvImportValidationMessage> validateStoredImportRequest(CsvImportRequest request) {
+    var messages = new ArrayList<CsvImportValidationMessage>();
+    if (request == null) {
+      messages.add(message("request", "Import request must be provided."));
+      return messages;
+    }
     validateCsvConfig(request.getCsvConfig(), messages);
 
     if (request.getTarget() == null || request.getTarget().getMode() == null) {
@@ -211,6 +472,11 @@ public class CsvDataLakeImportService {
     if (request.getColumns() == null || request.getColumns().isEmpty()) {
       messages.add(message("columns", "Column configuration must be provided."));
     }
+    if (!hasUploadId(request)
+        && (request.getRows() == null || request.getRows().isEmpty())
+        && (request.getHeaders() == null || request.getHeaders().isEmpty())) {
+      messages.add(message("uploadId", "Either an uploadId or inline CSV rows must be provided."));
+    }
     return messages;
   }
 
@@ -397,8 +663,7 @@ public class CsvDataLakeImportService {
         continue;
       }
 
-      if (!Objects.equals(getRuntimeType(entry.getValue()), getRuntimeType(imported))
-      ) {
+      if (!Objects.equals(getRuntimeType(entry.getValue()), getRuntimeType(imported))) {
         issues.add(issue(
             CsvImportSchemaIssueType.COLUMN_TYPE_MISMATCH,
             entry.getKey(),
@@ -427,28 +692,6 @@ public class CsvDataLakeImportService {
         )));
   }
 
-  private SpQueryResult toQueryResult(CsvImportRequest request) {
-    var headers = request.getColumns().stream()
-        .map(CsvImportColumn::getRuntimeName)
-        .collect(Collectors.toList());
-    var rows = new ArrayList<List<Object>>();
-    for (var row : request.getRows()) {
-      var converted = new ArrayList<Object>();
-      for (int i = 0; i < row.size(); i++) {
-        converted.add(convertValue(row.get(i), request.getColumns().get(i), request.getCsvConfig(), request.getTimestampColumn()));
-      }
-      rows.add(converted);
-    }
-
-    var dataSeries = DataSeriesBuilder.create()
-        .withHeaders(headers)
-        .withRows(rows)
-        .build();
-    return SpQueryResultBuilder.create(headers)
-        .withDataSeries(dataSeries)
-        .build();
-  }
-
   private EventSchema buildEventSchema(
       List<CsvImportColumn> columns,
       List<List<String>> rows,
@@ -555,7 +798,6 @@ public class CsvDataLakeImportService {
     var allBoolean = true;
     var allLong = true;
     var allNumber = true;
-    var timestampCandidate = false;
 
     for (var row : rows) {
       var value = row.get(columnIndex);
@@ -573,7 +815,7 @@ public class CsvDataLakeImportService {
       }
     }
 
-    timestampCandidate = isTimestampCandidate(rows, columnIndex, config);
+    var timestampCandidate = isTimestampCandidate(rows, columnIndex, config);
 
     if (timestampCandidate || allLong) {
       return "LONG";
@@ -621,21 +863,53 @@ public class CsvDataLakeImportService {
       CsvImportColumn column,
       CsvImportConfiguration config,
       String timestampColumn
+  ) {
+    return convertValue(rawValue, column, config, timestampColumn, null);
+  }
+
+  private Object convertValue(
+      String rawValue,
+      CsvImportColumn column,
+      CsvImportConfiguration config,
+      String timestampColumn,
+      Integer rowNumber
   ) {
     if (rawValue == null || rawValue.isBlank()) {
+      if (rowNumber != null && Objects.equals(column.getRuntimeName(), timestampColumn)) {
+        throw new CsvImportValidationException(List.of(
+            message(
+                "rows",
+                "Row " + rowNumber + " is missing a value for timestamp column \"" + column.getCsvColumn() + "\"."
+            )
+        ));
+      }
       return null;
     }
+
     var trimmed = rawValue.trim();
-    if (Objects.equals(column.getRuntimeName(), timestampColumn)) {
-      return parseTimestamp(trimmed, config);
-    }
+    try {
+      if (Objects.equals(column.getRuntimeName(), timestampColumn)) {
+        return parseTimestamp(trimmed, config);
+      }
 
-    return switch (finalRuntimeType(column, timestampColumn)) {
-      case "BOOLEAN" -> Boolean.parseBoolean(trimmed.toLowerCase(Locale.ENGLISH));
-      case "LONG" -> Long.parseLong(normalizeNumber(trimmed, config));
-      case "FLOAT" -> Double.parseDouble(normalizeNumber(trimmed, config));
-      default -> trimmed;
-    };
+      return switch (finalRuntimeType(column, timestampColumn)) {
+        case "BOOLEAN" -> Boolean.parseBoolean(trimmed.toLowerCase(Locale.ENGLISH));
+        case "LONG" -> Long.parseLong(normalizeNumber(trimmed, config));
+        case "FLOAT" -> Double.parseDouble(normalizeNumber(trimmed, config));
+        default -> trimmed;
+      };
+    } catch (RuntimeException e) {
+      if (rowNumber == null) {
+        throw e;
+      }
+
+      throw new CsvImportValidationException(List.of(
+          message(
+              "rows",
+              "Row " + rowNumber + " contains an invalid value for column \"" + column.getCsvColumn() + "\"."
+          )
+      ));
+    }
   }
 
   private long parseTimestamp(String value, CsvImportConfiguration config) {
@@ -736,14 +1010,190 @@ public class CsvDataLakeImportService {
     return new CsvImportSchemaIssue(type, columnName, expected, actual);
   }
 
-  private String normalize(String value) {
-    return value == null ? null : value.trim().toLowerCase(Locale.ENGLISH);
-  }
-
   private String getRuntimeType(EventProperty property) {
     if (property instanceof EventPropertyPrimitive primitive) {
       return primitive.getRuntimeType();
     }
     return null;
   }
+
+  private CsvFileSample readCsvSample(Path path, CsvImportConfiguration config, int maxRows) throws IOException {
+    var headers = new ArrayList<String>();
+    var rows = new ArrayList<List<String>>();
+
+    parseCsvFile(path, config, new CsvRowConsumer() {
+      @Override
+      public void onHeaders(List<String> parsedHeaders) {
+        headers.addAll(parsedHeaders);
+      }
+
+      @Override
+      public void onRow(int rowNumber, List<String> row) {
+        if (row.size() != headers.size()) {
+          throw new CsvImportValidationException(List.of(
+              message("rows", "Row " + rowNumber + " does not match the header size.")
+          ));
+        }
+        if (rows.size() < maxRows) {
+          rows.add(row);
+        }
+      }
+    });
+
+    if (headers.isEmpty()) {
+      throw new CsvImportValidationException(List.of(message("headers", "At least one header must be provided.")));
+    }
+    if (rows.isEmpty()) {
+      throw new CsvImportValidationException(List.of(message("rows", "At least one row must be provided.")));
+    }
+
+    return new CsvFileSample(headers, rows);
+  }
+
+  private void parseCsvFile(Path path, CsvImportConfiguration config, CsvRowConsumer consumer) throws IOException {
+    try (var reader = new PushbackReader(Files.newBufferedReader(path, StandardCharsets.UTF_8), 1)) {
+      var delimiter = normalizeDelimiter(config == null ? null : config.getDelimiter());
+      var hasHeader = config == null || config.isHasHeader();
+      List<String> headers = null;
+      int rowNumber = 0;
+      List<String> row;
+
+      while ((row = readNextRow(reader, delimiter)) != null) {
+        if (isBlankRow(row)) {
+          continue;
+        }
+
+        if (headers == null) {
+          if (hasHeader) {
+            headers = normalizeHeaders(row);
+            consumer.onHeaders(headers);
+          } else {
+            headers = generateHeaders(row.size());
+            consumer.onHeaders(headers);
+            rowNumber += 1;
+            consumer.onRow(rowNumber, row);
+          }
+        } else {
+          rowNumber += 1;
+          consumer.onRow(rowNumber, row);
+        }
+      }
+    }
+  }
+
+  private List<String> readNextRow(PushbackReader reader, char delimiter) throws IOException {
+    var currentRow = new ArrayList<String>();
+    var currentValue = new StringBuilder();
+    var inQuotes = false;
+    var readAny = false;
+
+    while (true) {
+      var nextInt = reader.read();
+      if (nextInt == -1) {
+        if (!readAny && currentValue.length() == 0 && currentRow.isEmpty()) {
+          return null;
+        }
+        currentRow.add(currentValue.toString());
+        return currentRow;
+      }
+
+      readAny = true;
+      var currentChar = (char) nextInt;
+      if (currentChar == '"') {
+        if (inQuotes) {
+          var escapedCandidate = reader.read();
+          if (escapedCandidate == '"') {
+            currentValue.append('"');
+          } else {
+            inQuotes = false;
+            if (escapedCandidate != -1) {
+              reader.unread(escapedCandidate);
+            }
+          }
+        } else {
+          inQuotes = true;
+        }
+      } else if (!inQuotes && currentChar == delimiter) {
+        currentRow.add(currentValue.toString());
+        currentValue = new StringBuilder();
+      } else if (!inQuotes && (currentChar == '\n' || currentChar == '\r')) {
+        if (currentChar == '\r') {
+          var maybeLineFeed = reader.read();
+          if (maybeLineFeed != '\n' && maybeLineFeed != -1) {
+            reader.unread(maybeLineFeed);
+          }
+        }
+        currentRow.add(currentValue.toString());
+        return currentRow;
+      } else {
+        currentValue.append(currentChar);
+      }
+    }
+  }
+
+  private char normalizeDelimiter(String delimiter) {
+    if (delimiter == null || delimiter.isEmpty()) {
+      return ',';
+    }
+    if ("\\t".equals(delimiter)) {
+      return '\t';
+    }
+    return delimiter.charAt(0);
+  }
+
+  private List<String> normalizeHeaders(List<String> headers) {
+    var normalized = new ArrayList<String>();
+    for (int i = 0; i < headers.size(); i++) {
+      var value = headers.get(i);
+      if (i == 0) {
+        value = stripBom(value);
+      }
+      var trimmed = value == null ? "" : value.trim();
+      normalized.add(trimmed.isEmpty() ? "column_" + (i + 1) : trimmed);
+    }
+    return normalized;
+  }
+
+  private String stripBom(String value) {
+    return value == null ? null : value.replace("\uFEFF", "");
+  }
+
+  private List<String> generateHeaders(int size) {
+    var headers = new ArrayList<String>();
+    for (int i = 0; i < size; i++) {
+      headers.add("column_" + (i + 1));
+    }
+    return headers;
+  }
+
+  private boolean isBlankRow(List<String> row) {
+    return row.stream().allMatch(cell -> cell == null || cell.trim().isEmpty());
+  }
+
+  @FunctionalInterface
+  private interface CsvRowConsumer {
+    default void onHeaders(List<String> headers) {
+    }
+
+    void onRow(int rowNumber, List<String> row);
+  }
+
+  private static final class CsvFileSample {
+
+    private final List<String> headers;
+    private final List<List<String>> rows;
+
+    private CsvFileSample(List<String> headers, List<List<String>> rows) {
+      this.headers = headers;
+      this.rows = rows;
+    }
+
+    List<String> headers() {
+      return headers;
+    }
+
+    List<List<String>> rows() {
+      return rows;
+    }
+  }
 }
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvImportUploadStorage.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvImportUploadStorage.java
new file mode 100644
index 0000000000..0651034f72
--- /dev/null
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvImportUploadStorage.java
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.rest.impl.datalake;
+
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+class CsvImportUploadStorage {
+
+  private static final Duration DEFAULT_TTL = Duration.ofHours(12);
+
+  private final ConcurrentMap<String, StoredUpload> uploads;
+  private final Duration ttl;
+
+  CsvImportUploadStorage() {
+    this(DEFAULT_TTL);
+  }
+
+  CsvImportUploadStorage(Duration ttl) {
+    this.uploads = new ConcurrentHashMap<>();
+    this.ttl = ttl;
+  }
+
+  StoredUpload store(MultipartFile file, String ownerSid) throws IOException {
+    cleanupExpired();
+
+    var uploadId = UUID.randomUUID().toString();
+    var tempFile = Files.createTempFile("streampipes-csv-import-", ".csv");
+    try (var inputStream = file.getInputStream()) {
+      Files.copy(inputStream, tempFile, StandardCopyOption.REPLACE_EXISTING);
+    }
+
+    var upload = new StoredUpload(
+        uploadId,
+        tempFile,
+        ownerSid,
+        Instant.now()
+    );
+    uploads.put(uploadId, upload);
+    return upload;
+  }
+
+  Optional<StoredUpload> get(String uploadId) {
+    cleanupExpired();
+    return Optional.ofNullable(uploads.get(uploadId));
+  }
+
+  void remove(String uploadId) {
+    var removed = uploads.remove(uploadId);
+    if (removed != null) {
+      deleteQuietly(removed.path());
+    }
+  }
+
+  private void cleanupExpired() {
+    var expiresBefore = Instant.now().minus(ttl);
+    uploads.entrySet().removeIf(entry -> {
+      var expired = entry.getValue().createdAt().isBefore(expiresBefore);
+      if (expired) {
+        deleteQuietly(entry.getValue().path());
+      }
+      return expired;
+    });
+  }
+
+  private void deleteQuietly(Path path) {
+    try {
+      Files.deleteIfExists(path);
+    } catch (IOException ignored) {
+      // Best-effort cleanup of temporary uploads.
+    }
+  }
+
+  static final class StoredUpload {
+
+    private final String uploadId;
+    private final Path path;
+    private final String ownerSid;
+    private final Instant createdAt;
+
+    StoredUpload(String uploadId, Path path, String ownerSid, Instant createdAt) {
+      this.uploadId = uploadId;
+      this.path = path;
+      this.ownerSid = ownerSid;
+      this.createdAt = createdAt;
+    }
+
+    String uploadId() {
+      return uploadId;
+    }
+
+    Path path() {
+      return path;
+    }
+
+    String ownerSid() {
+      return ownerSid;
+    }
+
+    Instant createdAt() {
+      return createdAt;
+    }
+  }
+}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeDataWriter.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeDataWriter.java
index a722b28484..c841e88a34 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeDataWriter.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeDataWriter.java
@@ -31,17 +31,24 @@ import org.apache.streampipes.storage.management.StorageDispatcher;
 
 import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
-import java.util.stream.IntStream;
 
 public class DataLakeDataWriter {
 
   private final boolean ignoreSchemaMismatch;
+  private final boolean allowMissingFields;
 
   public DataLakeDataWriter(boolean ignoreSchemaMismatch) {
+    this(ignoreSchemaMismatch, false);
+  }
+
+  public DataLakeDataWriter(boolean ignoreSchemaMismatch, boolean allowMissingFields) {
     this.ignoreSchemaMismatch = ignoreSchemaMismatch;
+    this.allowMissingFields = allowMissingFields;
   }
 
   public void writeData(String measureName, SpQueryResult queryResult) {
@@ -57,6 +64,14 @@ public class DataLakeDataWriter {
     getTimeSeriesStoreAndPersistQueryResult(dataSeries, measure);
   }
 
+  public void writeData(DataLakeMeasure measure, List<String> headers, List<List<Object>> rows) {
+    var dataSeries = new DataSeries();
+    dataSeries.setHeaders(headers);
+    dataSeries.setRows(rows);
+    dataSeries.setTotal(rows.size());
+    getTimeSeriesStoreAndPersistQueryResult(dataSeries, measure);
+  }
+
   private void getTimeSeriesStoreAndPersistQueryResult(DataSeries dataSeries,
                                                        DataLakeMeasure measure){
     var timeSeriesStore = getTimeSeriesStore(measure);
@@ -99,13 +114,24 @@ public class DataLakeDataWriter {
           .collect(Collectors.toSet());
       var runtimeNameSet = new HashSet<>(runtimeNames);
 
-      if (!runtimeNameSet.equals(strippedEventKeys)){
+      if (!matchesRuntimeNames(runtimeNameSet, strippedEventKeys, allowMissingFields)) {
         throw new SpRuntimeException("The fields of the event do not match. Use \"ignoreSchemaMismatch\" to "
             + "ignore this error. Fields of the event: " + strippedEventKeys);
       }
     }
   }
 
+  static boolean matchesRuntimeNames(
+      Set<String> expectedRuntimeNames,
+      Set<String> actualRuntimeNames,
+      boolean allowMissingFields
+  ) {
+    if (allowMissingFields) {
+      return expectedRuntimeNames.containsAll(actualRuntimeNames);
+    }
+    return expectedRuntimeNames.equals(actualRuntimeNames);
+  }
+
   private List<String> getRuntimeNames(DataLakeMeasure measure) {
     var runtimeNames = new ArrayList<String>();
     runtimeNames.add(measure.getTimestampFieldName());
@@ -124,10 +150,18 @@ public class DataLakeDataWriter {
   }
 
   private Event rowToEvent(List<Object> row, List<String> headers){
-    Map<String, Object> eventMap = IntStream.range(0, headers.size())
-        .boxed()
-        .collect(Collectors.toMap(headers::get, row::get));
-    return EventFactory.fromMap(eventMap);
+    return EventFactory.fromMap(toEventMap(row, headers));
+  }
+
+  static Map<String, Object> toEventMap(List<Object> row, List<String> headers) {
+    var eventMap = new LinkedHashMap<String, Object>();
+    for (int i = 0; i < headers.size(); i++) {
+      var value = row.get(i);
+      if (value != null) {
+        eventMap.put(headers.get(i), value);
+      }
+    }
+    return eventMap;
   }
 
   private void renameTimestampField(Event event, String timestampField){
@@ -137,4 +171,3 @@ public class DataLakeDataWriter {
   }
 
 }
-
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeImportResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeImportResource.java
index a5cebe0d44..d680e08fc3 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeImportResource.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeImportResource.java
@@ -33,7 +33,11 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestPart;
 import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
 
 @RestController
 @RequestMapping("/api/v4/datalake/import")
@@ -53,13 +57,26 @@ public class DataLakeImportResource extends AbstractDataLakeResource {
   )
   @PreAuthorize("this.hasWriteAuthority()")
   public ResponseEntity<CsvImportPreviewResult> preview(@RequestBody CsvImportPreviewRequest request) {
-    if (request.getTarget() != null
-        && request.getTarget().getMode() == CsvImportTargetMode.EXISTING
-        && this.dataLakeMeasureManagement.getExistingMeasureByName(request.getTarget().getMeasurementName()).isPresent()
-        && !this.checkPermissionByName(request.getTarget().getMeasurementName(), "WRITE")) {
+    if (!hasWritePermission(request.getTarget())) {
+      return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
+    }
+    return ok(importService.preview(request, getAuthenticatedUserSid()));
+  }
+
+  @PostMapping(
+      path = "/preview",
+      consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
+      produces = MediaType.APPLICATION_JSON_VALUE
+  )
+  @PreAuthorize("this.hasWriteAuthority()")
+  public ResponseEntity<CsvImportPreviewResult> preview(
+      @RequestPart("file") MultipartFile file,
+      @RequestPart("request") CsvImportPreviewRequest request
+  ) throws IOException {
+    if (!hasWritePermission(request.getTarget())) {
       return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
     }
-    return ok(importService.preview(request));
+    return ok(importService.preview(file, request, getAuthenticatedUserSid()));
   }
 
   @PostMapping(
@@ -71,10 +88,7 @@ public class DataLakeImportResource extends AbstractDataLakeResource {
   public ResponseEntity<CsvImportSchemaValidationResult> validateSchema(
       @RequestBody CsvImportSchemaValidationRequest request
   ) {
-    if (request.getTarget() != null
-        && request.getTarget().getMode() == CsvImportTargetMode.EXISTING
-        && this.dataLakeMeasureManagement.getExistingMeasureByName(request.getTarget().getMeasurementName()).isPresent()
-        && !this.checkPermissionByName(request.getTarget().getMeasurementName(), "WRITE")) {
+    if (!hasWritePermission(request.getTarget())) {
       return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
     }
     return ok(importService.validateSchema(request));
@@ -86,10 +100,7 @@ public class DataLakeImportResource extends AbstractDataLakeResource {
   )
   @PreAuthorize("this.hasWriteAuthority()")
   public ResponseEntity<CsvImportResult> importData(@RequestBody CsvImportRequest request) {
-    if (request.getTarget() != null
-        && request.getTarget().getMode() == CsvImportTargetMode.EXISTING
-        && this.dataLakeMeasureManagement.getExistingMeasureByName(request.getTarget().getMeasurementName()).isPresent()
-        && !this.checkPermissionByName(request.getTarget().getMeasurementName(), "WRITE")) {
+    if (!hasWritePermission(request.getTarget())) {
       return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
     }
 
@@ -101,4 +112,11 @@ public class DataLakeImportResource extends AbstractDataLakeResource {
       return ResponseEntity.badRequest().body(result);
     }
   }
+
+  private boolean hasWritePermission(org.apache.streampipes.model.datalake.importer.CsvImportTarget target) {
+    return target == null
+        || target.getMode() != CsvImportTargetMode.EXISTING
+        || this.dataLakeMeasureManagement.getExistingMeasureByName(target.getMeasurementName()).isEmpty()
+        || this.checkPermissionByName(target.getMeasurementName(), "WRITE");
+  }
 }
diff --git a/streampipes-rest/src/test/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportServiceTest.java b/streampipes-rest/src/test/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportServiceTest.java
index 9224094a7f..c8a9a3283a 100644
--- a/streampipes-rest/src/test/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportServiceTest.java
+++ b/streampipes-rest/src/test/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportServiceTest.java
@@ -20,6 +20,7 @@ package org.apache.streampipes.rest.impl.datalake;
 
 import org.apache.streampipes.dataexplorer.api.IDataExplorerSchemaManagement;
 import org.apache.streampipes.model.datalake.DataLakeMeasure;
+import org.apache.streampipes.model.datalake.SpQueryResult;
 import org.apache.streampipes.model.datalake.importer.CsvImportColumn;
 import org.apache.streampipes.model.datalake.importer.CsvImportConfiguration;
 import org.apache.streampipes.model.datalake.importer.CsvImportPreviewRequest;
@@ -34,7 +35,9 @@ import org.apache.streampipes.vocabulary.SO;
 import org.apache.streampipes.vocabulary.XSD;
 
 import org.junit.jupiter.api.Test;
+import org.springframework.web.multipart.MultipartFile;
 
+import java.io.ByteArrayInputStream;
 import java.util.List;
 import java.util.Optional;
 
@@ -43,6 +46,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyList;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -118,7 +122,102 @@ class CsvDataLakeImportServiceTest {
     assertTrue(result.isCreatedNewMeasurement());
     assertEquals(2, result.getImportedRowCount());
     assertEquals("new-measure", result.getMeasurementName());
-    verify(dataWriter).writeData(any(DataLakeMeasure.class), any());
+    verify(dataWriter).writeData(any(DataLakeMeasure.class), any(SpQueryResult.class));
+  }
+
+  @Test
+  void shouldPreviewOnceAndImportFromStoredUpload() throws Exception {
+    var schemaManagement = mock(IDataExplorerSchemaManagement.class);
+    var dataWriter = mock(DataLakeDataWriter.class);
+    var uploadStorage = new CsvImportUploadStorage();
+    var service = new CsvDataLakeImportService(schemaManagement, dataWriter, uploadStorage);
+
+    when(schemaManagement.getExistingMeasureByName("uploaded-measure"))
+        .thenReturn(Optional.empty());
+    when(schemaManagement.createOrUpdateMeasurement(any(DataLakeMeasure.class), any()))
+        .thenAnswer(invocation -> {
+          var measure = invocation.getArgument(0, DataLakeMeasure.class);
+          measure.setElementId("measure-id");
+          return measure;
+        });
+
+    var previewRequest = new CsvImportPreviewRequest();
+    previewRequest.setCsvConfig(makeCsvConfigWithCommaDelimiter());
+    previewRequest.setTarget(makeTarget(CsvImportTargetMode.NEW, "uploaded-measure"));
+
+    var multipartFile = mock(MultipartFile.class);
+    when(multipartFile.getOriginalFilename()).thenReturn("upload.csv");
+    when(multipartFile.getInputStream()).thenReturn(new ByteArrayInputStream(
+        "timestamp,temperature\n1710000000000,21.3\n1710000060000,22.1\n".getBytes()
+    ));
+
+    var previewResult = service.preview(
+        multipartFile,
+        previewRequest,
+        "sid"
+    );
+
+    assertTrue(previewResult.isValid());
+    assertEquals(2, previewResult.getPreviewRows().size());
+    assertTrue(previewResult.getUploadId() != null && !previewResult.getUploadId().isBlank());
+
+    var importRequest = new CsvImportRequest();
+    importRequest.setUploadId(previewResult.getUploadId());
+    importRequest.setCsvConfig(makeCsvConfigWithCommaDelimiter());
+    importRequest.setTarget(makeTarget(CsvImportTargetMode.NEW, "uploaded-measure"));
+    importRequest.setTimestampColumn("timestamp");
+    importRequest.setColumns(previewResult.getColumns());
+
+    var importResult = service.importData(importRequest, "sid");
+
+    assertTrue(importResult.isCreatedNewMeasurement());
+    assertEquals(2, importResult.getImportedRowCount());
+    verify(dataWriter).writeData(any(DataLakeMeasure.class), anyList(), anyList());
+  }
+
+  @Test
+  void shouldRejectMissingTimestampValuesInUploadedCsv() throws Exception {
+    var schemaManagement = mock(IDataExplorerSchemaManagement.class);
+    var dataWriter = mock(DataLakeDataWriter.class);
+    var uploadStorage = new CsvImportUploadStorage();
+    var service = new CsvDataLakeImportService(schemaManagement, dataWriter, uploadStorage);
+
+    when(schemaManagement.getExistingMeasureByName("uploaded-measure"))
+        .thenReturn(Optional.empty());
+    when(schemaManagement.createOrUpdateMeasurement(any(DataLakeMeasure.class), any()))
+        .thenAnswer(invocation -> {
+          var measure = invocation.getArgument(0, DataLakeMeasure.class);
+          measure.setElementId("measure-id");
+          return measure;
+        });
+
+    var previewRequest = new CsvImportPreviewRequest();
+    previewRequest.setCsvConfig(makeCsvConfigWithCommaDelimiter());
+    previewRequest.setTarget(makeTarget(CsvImportTargetMode.NEW, "uploaded-measure"));
+
+    var multipartFile = mock(MultipartFile.class);
+    when(multipartFile.getOriginalFilename()).thenReturn("upload.csv");
+    when(multipartFile.getInputStream()).thenReturn(new ByteArrayInputStream(
+        "timestamp,temperature\n1710000000000,21.3\n,22.1\n".getBytes()
+    ));
+
+    var previewResult = service.preview(multipartFile, previewRequest, "sid");
+
+    var importRequest = new CsvImportRequest();
+    importRequest.setUploadId(previewResult.getUploadId());
+    importRequest.setCsvConfig(makeCsvConfigWithCommaDelimiter());
+    importRequest.setTarget(makeTarget(CsvImportTargetMode.NEW, "uploaded-measure"));
+    importRequest.setTimestampColumn("timestamp");
+    importRequest.setColumns(previewResult.getColumns());
+
+    var exception = assertThrows(
+        CsvImportValidationException.class,
+        () -> service.importData(importRequest, "sid")
+    );
+
+    assertTrue(exception.getValidationMessages()
+        .stream()
+        .anyMatch(message -> message.getMessage().contains("missing a value for timestamp column")));
   }
 
   @Test
@@ -202,6 +301,14 @@ class CsvDataLakeImportServiceTest {
     return config;
   }
 
+  private CsvImportConfiguration makeCsvConfigWithCommaDelimiter() {
+    var config = new CsvImportConfiguration();
+    config.setDelimiter(",");
+    config.setDecimalSeparator(".");
+    config.setHasHeader(true);
+    return config;
+  }
+
   private EventSchema makeExistingSchema() {
     var timestamp = new EventPropertyPrimitive();
     timestamp.setRuntimeName("timestamp");
diff --git a/streampipes-rest/src/test/java/org/apache/streampipes/rest/impl/datalake/DataLakeDataWriterTest.java b/streampipes-rest/src/test/java/org/apache/streampipes/rest/impl/datalake/DataLakeDataWriterTest.java
new file mode 100644
index 0000000000..ebeee70cfb
--- /dev/null
+++ b/streampipes-rest/src/test/java/org/apache/streampipes/rest/impl/datalake/DataLakeDataWriterTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.rest.impl.datalake;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.HashSet;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class DataLakeDataWriterTest {
+
+  @Test
+  void shouldSkipNullValuesWhenBuildingEventMap() {
+    var headers = List.of("timestamp", "temperature", "status");
+    List<Object> row = new java.util.ArrayList<>();
+    row.add(1710000000000L);
+    row.add(null);
+    row.add("ok");
+
+    var eventMap = DataLakeDataWriter.toEventMap(row, headers);
+
+    assertEquals(2, eventMap.size());
+    assertEquals(1710000000000L, eventMap.get("timestamp"));
+    assertEquals("ok", eventMap.get("status"));
+    assertFalse(eventMap.containsKey("temperature"));
+  }
+
+  @Test
+  void shouldAllowMissingFieldsWhenConfigured() {
+    var expected = new HashSet<>(List.of("timestamp", "temperature", "status"));
+    var actual = new HashSet<>(List.of("timestamp", "status"));
+
+    assertTrue(DataLakeDataWriter.matchesRuntimeNames(expected, actual, true));
+    assertFalse(DataLakeDataWriter.matchesRuntimeNames(expected, actual, false));
+  }
+}
diff --git a/ui/cypress/fixtures/datalake/machine-data-simulator-import-missing-values.csv b/ui/cypress/fixtures/datalake/machine-data-simulator-import-missing-values.csv
new file mode 100644
index 0000000000..8c3c0cce83
--- /dev/null
+++ b/ui/cypress/fixtures/datalake/machine-data-simulator-import-missing-values.csv
@@ -0,0 +1,8 @@
+timestamp,dmc,druckoelraumAnlagenkompensation,druckoelraumBauteiltemperatur1,druckoelraumDifferenztemperatur,druckoelraumDrehzahl,druckoelraumDruck
+1772722801725,0.0,0.0,,0.0,0.0,0.0
+1772722802743,0,0.0,0.0,0.0,0.0,0.0
+1772722803756,0.0,,0.0,0.0,0.0,0.0
+1772722804768,0.0,0.0,,0.0,0.0,0.0
+1772722805777,0.0,0.0,,,0.0,0.0
+1772722806784,0.0,0.0,0.0,0.0,,0.0
+1772722807791,0.0,0.0,0.0,0.0,0.0,


(streampipes) 01/02: feat(#4250): First version of the csv upload

Posted by ze...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zehnder pushed a commit to branch 4250-add-csv-dataset-import-with-preview-for-data-sets
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit fd812634bcb34370bab6e4c2427355b05aa28a3f
Author: Philipp Zehnder <te...@users.noreply.github.com>
AuthorDate: Fri Mar 13 14:57:36 2026 +0100

    feat(#4250): First version of the csv upload
---
 .idea/runConfigurations/AllExtensionsIIoTInit.xml  |   1 +
 .../model/datalake/importer/CsvImportColumn.java   | 104 +++
 .../datalake/importer/CsvImportConfiguration.java  |  59 ++
 .../datalake/importer/CsvImportPreviewRequest.java |  70 ++
 .../datalake/importer/CsvImportPreviewResult.java  |  91 +++
 .../model/datalake/importer/CsvImportRequest.java  |  80 ++
 .../model/datalake/importer/CsvImportResult.java   |  71 ++
 .../datalake/importer/CsvImportSchemaIssue.java    |  74 ++
 .../importer/CsvImportSchemaIssueType.java         |  26 +
 .../importer/CsvImportSchemaValidationRequest.java |  53 ++
 .../importer/CsvImportSchemaValidationResult.java  |  53 ++
 .../model/datalake/importer/CsvImportTarget.java   |  41 +
 .../datalake/importer/CsvImportTargetMode.java     |  24 +
 .../importer/CsvImportValidationMessage.java       |  49 ++
 .../impl/datalake/CsvDataLakeImportService.java    | 749 ++++++++++++++++++
 .../datalake/CsvImportValidationException.java     |  37 +
 .../rest/impl/datalake/DataLakeDataWriter.java     |   5 +-
 .../rest/impl/datalake/DataLakeImportResource.java | 104 +++
 .../datalake/CsvDataLakeImportServiceTest.java     | 219 ++++++
 ...hine-data-simulator-import-later-timestamps.csv |   8 +
 ...-data-simulator-import-mismatched-timestamp.csv |   8 +
 ...hine-data-simulator-import-string-timestamp.csv |   8 +
 .../datalake/machine-data-simulator-import.csv     |   8 +
 ui/cypress/support/utils/dataset/DatasetBtns.ts    |  97 +++
 ui/cypress/support/utils/dataset/DatasetUtils.ts   | 108 +++
 ui/cypress/tests/dataset/csvImport.spec.ts         |  96 +++
 .../src/lib/apis/datalake-rest.service.ts          |  34 +
 .../src/lib/model/datalake/csv-import.model.ts     | 111 +++
 .../platform-services/src/public-api.ts            |   1 +
 .../datalake-configuration.component.html          |   9 +
 .../datalake-configuration.component.ts            |  21 +
 .../csv-import-dialog.component.html               | 523 +++++++++++++
 .../csv-import-dialog.component.scss               | 236 ++++++
 .../csv-import-dialog.component.ts                 | 854 +++++++++++++++++++++
 34 files changed, 4031 insertions(+), 1 deletion(-)

diff --git a/.idea/runConfigurations/AllExtensionsIIoTInit.xml b/.idea/runConfigurations/AllExtensionsIIoTInit.xml
index 8faac42b13..3485b47926 100644
--- a/.idea/runConfigurations/AllExtensionsIIoTInit.xml
+++ b/.idea/runConfigurations/AllExtensionsIIoTInit.xml
@@ -11,6 +11,7 @@
       <env name="SP_KAFKA_HOST" value="localhost" />
       <env name="SP_KAFKA_PORT" value="9094" />
       <env name="SP_PRIORITIZED_PROTOCOL" value="kafka" />
+      <env name="SP_HOST" value="192.168.2.140" />
     </envs>
     <module name="streampipes-extensions-all-iiot" />
     <option name="SPRING_BOOT_MAIN_CLASS" value="org.apache.streampipes.extensions.all.iiot.AllExtensionsIIoTInit" />
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportColumn.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportColumn.java
new file mode 100644
index 0000000000..95f91269b4
--- /dev/null
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportColumn.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.model.datalake.importer;
+
+public class CsvImportColumn {
+
+  private String csvColumn;
+  private String runtimeName;
+  private String runtimeType;
+  private String propertyScope;
+  private String semanticType;
+  private String label;
+  private String description;
+  private String inferredType;
+  private boolean timestampCandidate;
+
+  public String getCsvColumn() {
+    return csvColumn;
+  }
+
+  public void setCsvColumn(String csvColumn) {
+    this.csvColumn = csvColumn;
+  }
+
+  public String getRuntimeName() {
+    return runtimeName;
+  }
+
+  public void setRuntimeName(String runtimeName) {
+    this.runtimeName = runtimeName;
+  }
+
+  public String getRuntimeType() {
+    return runtimeType;
+  }
+
+  public void setRuntimeType(String runtimeType) {
+    this.runtimeType = runtimeType;
+  }
+
+  public String getPropertyScope() {
+    return propertyScope;
+  }
+
+  public void setPropertyScope(String propertyScope) {
+    this.propertyScope = propertyScope;
+  }
+
+  public String getSemanticType() {
+    return semanticType;
+  }
+
+  public void setSemanticType(String semanticType) {
+    this.semanticType = semanticType;
+  }
+
+  public String getLabel() {
+    return label;
+  }
+
+  public void setLabel(String label) {
+    this.label = label;
+  }
+
+  public String getDescription() {
+    return description;
+  }
+
+  public void setDescription(String description) {
+    this.description = description;
+  }
+
+  public String getInferredType() {
+    return inferredType;
+  }
+
+  public void setInferredType(String inferredType) {
+    this.inferredType = inferredType;
+  }
+
+  public boolean isTimestampCandidate() {
+    return timestampCandidate;
+  }
+
+  public void setTimestampCandidate(boolean timestampCandidate) {
+    this.timestampCandidate = timestampCandidate;
+  }
+}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportConfiguration.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportConfiguration.java
new file mode 100644
index 0000000000..8fac2972a9
--- /dev/null
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportConfiguration.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.model.datalake.importer;
+
+public class CsvImportConfiguration {
+
+  private String delimiter;
+  private String decimalSeparator;
+  private boolean hasHeader;
+  private String timestampFormat;
+
+  public String getDelimiter() {
+    return delimiter;
+  }
+
+  public void setDelimiter(String delimiter) {
+    this.delimiter = delimiter;
+  }
+
+  public String getDecimalSeparator() {
+    return decimalSeparator;
+  }
+
+  public void setDecimalSeparator(String decimalSeparator) {
+    this.decimalSeparator = decimalSeparator;
+  }
+
+  public boolean isHasHeader() {
+    return hasHeader;
+  }
+
+  public void setHasHeader(boolean hasHeader) {
+    this.hasHeader = hasHeader;
+  }
+
+  public String getTimestampFormat() {
+    return timestampFormat;
+  }
+
+  public void setTimestampFormat(String timestampFormat) {
+    this.timestampFormat = timestampFormat;
+  }
+}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportPreviewRequest.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportPreviewRequest.java
new file mode 100644
index 0000000000..84e52dbeb1
--- /dev/null
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportPreviewRequest.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.model.datalake.importer;
+
+import java.util.List;
+
+public class CsvImportPreviewRequest {
+
+  private String fileName;
+  private CsvImportConfiguration csvConfig;
+  private List<String> headers;
+  private List<List<String>> rows;
+  private CsvImportTarget target;
+
+  public String getFileName() {
+    return fileName;
+  }
+
+  public void setFileName(String fileName) {
+    this.fileName = fileName;
+  }
+
+  public CsvImportConfiguration getCsvConfig() {
+    return csvConfig;
+  }
+
+  public void setCsvConfig(CsvImportConfiguration csvConfig) {
+    this.csvConfig = csvConfig;
+  }
+
+  public List<String> getHeaders() {
+    return headers;
+  }
+
+  public void setHeaders(List<String> headers) {
+    this.headers = headers;
+  }
+
+  public List<List<String>> getRows() {
+    return rows;
+  }
+
+  public void setRows(List<List<String>> rows) {
+    this.rows = rows;
+  }
+
+  public CsvImportTarget getTarget() {
+    return target;
+  }
+
+  public void setTarget(CsvImportTarget target) {
+    this.target = target;
+  }
+}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportPreviewResult.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportPreviewResult.java
new file mode 100644
index 0000000000..6f6ebcf227
--- /dev/null
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportPreviewResult.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.model.datalake.importer;
+
+import org.apache.streampipes.model.schema.EventSchema;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CsvImportPreviewResult {
+
+  private List<String> headers = new ArrayList<>();
+  private List<List<String>> previewRows = new ArrayList<>();
+  private List<CsvImportColumn> columns = new ArrayList<>();
+  private EventSchema guessedEventSchema;
+  private List<String> timestampCandidates = new ArrayList<>();
+  private boolean valid;
+  private List<CsvImportValidationMessage> validationMessages = new ArrayList<>();
+
+  public List<String> getHeaders() {
+    return headers;
+  }
+
+  public void setHeaders(List<String> headers) {
+    this.headers = headers;
+  }
+
+  public List<List<String>> getPreviewRows() {
+    return previewRows;
+  }
+
+  public void setPreviewRows(List<List<String>> previewRows) {
+    this.previewRows = previewRows;
+  }
+
+  public List<CsvImportColumn> getColumns() {
+    return columns;
+  }
+
+  public void setColumns(List<CsvImportColumn> columns) {
+    this.columns = columns;
+  }
+
+  public EventSchema getGuessedEventSchema() {
+    return guessedEventSchema;
+  }
+
+  public void setGuessedEventSchema(EventSchema guessedEventSchema) {
+    this.guessedEventSchema = guessedEventSchema;
+  }
+
+  public List<String> getTimestampCandidates() {
+    return timestampCandidates;
+  }
+
+  public void setTimestampCandidates(List<String> timestampCandidates) {
+    this.timestampCandidates = timestampCandidates;
+  }
+
+  public boolean isValid() {
+    return valid;
+  }
+
+  public void setValid(boolean valid) {
+    this.valid = valid;
+  }
+
+  public List<CsvImportValidationMessage> getValidationMessages() {
+    return validationMessages;
+  }
+
+  public void setValidationMessages(List<CsvImportValidationMessage> validationMessages) {
+    this.validationMessages = validationMessages;
+  }
+}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportRequest.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportRequest.java
new file mode 100644
index 0000000000..e571bae89e
--- /dev/null
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportRequest.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.model.datalake.importer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CsvImportRequest {
+
+  private CsvImportConfiguration csvConfig;
+  private List<String> headers = new ArrayList<>();
+  private List<List<String>> rows = new ArrayList<>();
+  private CsvImportTarget target;
+  private String timestampColumn;
+  private List<CsvImportColumn> columns = new ArrayList<>();
+
+  public CsvImportConfiguration getCsvConfig() {
+    return csvConfig;
+  }
+
+  public void setCsvConfig(CsvImportConfiguration csvConfig) {
+    this.csvConfig = csvConfig;
+  }
+
+  public List<String> getHeaders() {
+    return headers;
+  }
+
+  public void setHeaders(List<String> headers) {
+    this.headers = headers;
+  }
+
+  public List<List<String>> getRows() {
+    return rows;
+  }
+
+  public void setRows(List<List<String>> rows) {
+    this.rows = rows;
+  }
+
+  public CsvImportTarget getTarget() {
+    return target;
+  }
+
+  public void setTarget(CsvImportTarget target) {
+    this.target = target;
+  }
+
+  public String getTimestampColumn() {
+    return timestampColumn;
+  }
+
+  public void setTimestampColumn(String timestampColumn) {
+    this.timestampColumn = timestampColumn;
+  }
+
+  public List<CsvImportColumn> getColumns() {
+    return columns;
+  }
+
+  public void setColumns(List<CsvImportColumn> columns) {
+    this.columns = columns;
+  }
+}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportResult.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportResult.java
new file mode 100644
index 0000000000..c393160010
--- /dev/null
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportResult.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.model.datalake.importer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CsvImportResult {
+
+  private String measurementName;
+  private String measurementId;
+  private boolean createdNewMeasurement;
+  private int importedRowCount;
+  private List<CsvImportValidationMessage> validationMessages = new ArrayList<>();
+
+  public String getMeasurementName() {
+    return measurementName;
+  }
+
+  public void setMeasurementName(String measurementName) {
+    this.measurementName = measurementName;
+  }
+
+  public String getMeasurementId() {
+    return measurementId;
+  }
+
+  public void setMeasurementId(String measurementId) {
+    this.measurementId = measurementId;
+  }
+
+  public boolean isCreatedNewMeasurement() {
+    return createdNewMeasurement;
+  }
+
+  public void setCreatedNewMeasurement(boolean createdNewMeasurement) {
+    this.createdNewMeasurement = createdNewMeasurement;
+  }
+
+  public int getImportedRowCount() {
+    return importedRowCount;
+  }
+
+  public void setImportedRowCount(int importedRowCount) {
+    this.importedRowCount = importedRowCount;
+  }
+
+  public List<CsvImportValidationMessage> getValidationMessages() {
+    return validationMessages;
+  }
+
+  public void setValidationMessages(List<CsvImportValidationMessage> validationMessages) {
+    this.validationMessages = validationMessages;
+  }
+}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportSchemaIssue.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportSchemaIssue.java
new file mode 100644
index 0000000000..3b67198757
--- /dev/null
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportSchemaIssue.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.model.datalake.importer;
+
+public class CsvImportSchemaIssue {
+
+  private CsvImportSchemaIssueType type;
+  private String columnName;
+  private String expected;
+  private String actual;
+
+  public CsvImportSchemaIssue() {
+  }
+
+  public CsvImportSchemaIssue(
+      CsvImportSchemaIssueType type,
+      String columnName,
+      String expected,
+      String actual
+  ) {
+    this.type = type;
+    this.columnName = columnName;
+    this.expected = expected;
+    this.actual = actual;
+  }
+
+  public CsvImportSchemaIssueType getType() {
+    return type;
+  }
+
+  public void setType(CsvImportSchemaIssueType type) {
+    this.type = type;
+  }
+
+  public String getColumnName() {
+    return columnName;
+  }
+
+  public void setColumnName(String columnName) {
+    this.columnName = columnName;
+  }
+
+  public String getExpected() {
+    return expected;
+  }
+
+  public void setExpected(String expected) {
+    this.expected = expected;
+  }
+
+  public String getActual() {
+    return actual;
+  }
+
+  public void setActual(String actual) {
+    this.actual = actual;
+  }
+}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportSchemaIssueType.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportSchemaIssueType.java
new file mode 100644
index 0000000000..13ac996bb8
--- /dev/null
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportSchemaIssueType.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.model.datalake.importer;
+
+public enum CsvImportSchemaIssueType {
+  TIMESTAMP_COLUMN_MISMATCH,
+  COLUMN_NAME_MISMATCH,
+  COLUMN_TYPE_MISMATCH,
+  COLUMN_SCOPE_MISMATCH
+}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportSchemaValidationRequest.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportSchemaValidationRequest.java
new file mode 100644
index 0000000000..3c25e2952a
--- /dev/null
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportSchemaValidationRequest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.model.datalake.importer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CsvImportSchemaValidationRequest {
+
+  private CsvImportTarget target;
+  private String timestampColumn;
+  private List<CsvImportColumn> columns = new ArrayList<>();
+
+  public CsvImportTarget getTarget() {
+    return target;
+  }
+
+  public void setTarget(CsvImportTarget target) {
+    this.target = target;
+  }
+
+  public String getTimestampColumn() {
+    return timestampColumn;
+  }
+
+  public void setTimestampColumn(String timestampColumn) {
+    this.timestampColumn = timestampColumn;
+  }
+
+  public List<CsvImportColumn> getColumns() {
+    return columns;
+  }
+
+  public void setColumns(List<CsvImportColumn> columns) {
+    this.columns = columns;
+  }
+}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportSchemaValidationResult.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportSchemaValidationResult.java
new file mode 100644
index 0000000000..5b7e23ef93
--- /dev/null
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportSchemaValidationResult.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.model.datalake.importer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class CsvImportSchemaValidationResult {
+
+  private boolean valid;
+  private List<CsvImportValidationMessage> validationMessages = new ArrayList<>();
+  private List<CsvImportSchemaIssue> issues = new ArrayList<>();
+
+  public boolean isValid() {
+    return valid;
+  }
+
+  public void setValid(boolean valid) {
+    this.valid = valid;
+  }
+
+  public List<CsvImportValidationMessage> getValidationMessages() {
+    return validationMessages;
+  }
+
+  public void setValidationMessages(List<CsvImportValidationMessage> validationMessages) {
+    this.validationMessages = validationMessages;
+  }
+
+  public List<CsvImportSchemaIssue> getIssues() {
+    return issues;
+  }
+
+  public void setIssues(List<CsvImportSchemaIssue> issues) {
+    this.issues = issues;
+  }
+}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportTarget.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportTarget.java
new file mode 100644
index 0000000000..61d018884e
--- /dev/null
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportTarget.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.model.datalake.importer;
+
+public class CsvImportTarget {
+
+  private CsvImportTargetMode mode;
+  private String measurementName;
+
+  public CsvImportTargetMode getMode() {
+    return mode;
+  }
+
+  public void setMode(CsvImportTargetMode mode) {
+    this.mode = mode;
+  }
+
+  public String getMeasurementName() {
+    return measurementName;
+  }
+
+  public void setMeasurementName(String measurementName) {
+    this.measurementName = measurementName;
+  }
+}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportTargetMode.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportTargetMode.java
new file mode 100644
index 0000000000..86a16562c3
--- /dev/null
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportTargetMode.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.model.datalake.importer;
+
+public enum CsvImportTargetMode {
+  NEW,
+  EXISTING
+}
diff --git a/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportValidationMessage.java b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportValidationMessage.java
new file mode 100644
index 0000000000..cd5abd99f3
--- /dev/null
+++ b/streampipes-model/src/main/java/org/apache/streampipes/model/datalake/importer/CsvImportValidationMessage.java
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.model.datalake.importer;
+
+public class CsvImportValidationMessage {
+
+  private String field;
+  private String message;
+
+  public CsvImportValidationMessage() {
+  }
+
+  public CsvImportValidationMessage(String field, String message) {
+    this.field = field;
+    this.message = message;
+  }
+
+  public String getField() {
+    return field;
+  }
+
+  public void setField(String field) {
+    this.field = field;
+  }
+
+  public String getMessage() {
+    return message;
+  }
+
+  public void setMessage(String message) {
+    this.message = message;
+  }
+}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportService.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportService.java
new file mode 100644
index 0000000000..a36980446e
--- /dev/null
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportService.java
@@ -0,0 +1,749 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.rest.impl.datalake;
+
+import org.apache.streampipes.connect.management.util.EventSchemaUtils;
+import org.apache.streampipes.dataexplorer.api.IDataExplorerSchemaManagement;
+import org.apache.streampipes.model.datalake.DataLakeMeasure;
+import org.apache.streampipes.model.datalake.DataSeriesBuilder;
+import org.apache.streampipes.model.datalake.SpQueryResult;
+import org.apache.streampipes.model.datalake.SpQueryResultBuilder;
+import org.apache.streampipes.model.datalake.importer.CsvImportColumn;
+import org.apache.streampipes.model.datalake.importer.CsvImportConfiguration;
+import org.apache.streampipes.model.datalake.importer.CsvImportPreviewRequest;
+import org.apache.streampipes.model.datalake.importer.CsvImportPreviewResult;
+import org.apache.streampipes.model.datalake.importer.CsvImportRequest;
+import org.apache.streampipes.model.datalake.importer.CsvImportResult;
+import org.apache.streampipes.model.datalake.importer.CsvImportSchemaIssue;
+import org.apache.streampipes.model.datalake.importer.CsvImportSchemaIssueType;
+import org.apache.streampipes.model.datalake.importer.CsvImportSchemaValidationRequest;
+import org.apache.streampipes.model.datalake.importer.CsvImportSchemaValidationResult;
+import org.apache.streampipes.model.datalake.importer.CsvImportTarget;
+import org.apache.streampipes.model.datalake.importer.CsvImportTargetMode;
+import org.apache.streampipes.model.datalake.importer.CsvImportValidationMessage;
+import org.apache.streampipes.model.schema.EventProperty;
+import org.apache.streampipes.model.schema.EventPropertyPrimitive;
+import org.apache.streampipes.model.schema.EventSchema;
+import org.apache.streampipes.model.schema.PropertyScope;
+import org.apache.streampipes.vocabulary.SO;
+import org.apache.streampipes.vocabulary.XSD;
+
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+public class CsvDataLakeImportService {
+
+  private static final int MAX_PREVIEW_ROWS = 50;
+  private static final String STREAM_PREFIX = "s0::";
+
+  private final IDataExplorerSchemaManagement schemaManagement;
+  private final DataLakeDataWriter dataWriter;
+
+  public CsvDataLakeImportService(IDataExplorerSchemaManagement schemaManagement) {
+    this(
+        schemaManagement,
+        new DataLakeDataWriter(false)
+    );
+  }
+
+  CsvDataLakeImportService(
+      IDataExplorerSchemaManagement schemaManagement,
+      DataLakeDataWriter dataWriter
+  ) {
+    this.schemaManagement = schemaManagement;
+    this.dataWriter = dataWriter;
+  }
+
+  public CsvImportPreviewResult preview(CsvImportPreviewRequest request) {
+    var validationMessages = validatePreviewRequest(request);
+    var headers = sanitizeHeaders(request.getHeaders());
+    var rows = Optional.ofNullable(request.getRows()).orElseGet(Collections::emptyList);
+
+    var columns = inferColumns(headers, rows, request.getCsvConfig());
+    var eventSchema = buildEventSchema(columns, rows, request.getCsvConfig(), null);
+    validationMessages.addAll(validatePreviewTarget(request.getTarget()));
+
+    var result = new CsvImportPreviewResult();
+    result.setHeaders(headers);
+    result.setPreviewRows(rows.stream().limit(MAX_PREVIEW_ROWS).collect(Collectors.toList()));
+    result.setColumns(columns);
+    result.setGuessedEventSchema(eventSchema);
+    result.setTimestampCandidates(columns.stream()
+        .filter(CsvImportColumn::isTimestampCandidate)
+        .map(CsvImportColumn::getRuntimeName)
+        .collect(Collectors.toList()));
+    result.setValidationMessages(validationMessages);
+    result.setValid(validationMessages.isEmpty());
+    return result;
+  }
+
+  public CsvImportSchemaValidationResult validateSchema(CsvImportSchemaValidationRequest request) {
+    var validationMessages = validateSchemaRequest(request);
+    var issues = new ArrayList<CsvImportSchemaIssue>();
+    if (validationMessages.isEmpty()) {
+      var eventSchema = buildConfiguredEventSchema(
+          sanitizeImportColumns(request.getColumns()),
+          request.getTimestampColumn()
+      );
+      issues.addAll(validateSchemaTarget(
+          request.getTarget(),
+          eventSchema,
+          request.getTimestampColumn()
+      ));
+    }
+
+    var result = new CsvImportSchemaValidationResult();
+    result.setValidationMessages(validationMessages);
+    result.setIssues(issues);
+    result.setValid(validationMessages.isEmpty() && issues.isEmpty());
+    return result;
+  }
+
+  public CsvImportResult importData(CsvImportRequest request, String principalSid) {
+    var validationMessages = validateImportRequest(request);
+    if (!validationMessages.isEmpty()) {
+      throw new CsvImportValidationException(validationMessages);
+    }
+
+    var eventSchema = buildEventSchema(
+        sanitizeImportColumns(request.getColumns()),
+        request.getRows(),
+        request.getCsvConfig(),
+        request.getTimestampColumn()
+    );
+
+    validationMessages.addAll(validateImportTarget(request.getTarget(), eventSchema, request.getTimestampColumn()));
+    if (!validationMessages.isEmpty()) {
+      throw new CsvImportValidationException(validationMessages);
+    }
+
+    var createdNewMeasurement = false;
+    DataLakeMeasure measure;
+
+    if (request.getTarget().getMode() == CsvImportTargetMode.NEW) {
+      measure = new DataLakeMeasure();
+      measure.setMeasureName(request.getTarget().getMeasurementName().trim());
+      measure.setTimestampField(STREAM_PREFIX + request.getTimestampColumn());
+      measure.setEventSchema(eventSchema);
+      measure = schemaManagement.createOrUpdateMeasurement(measure, principalSid);
+      createdNewMeasurement = true;
+    } else {
+      measure = requireExistingMeasurement(request.getTarget().getMeasurementName());
+    }
+
+    var queryResult = toQueryResult(request);
+    dataWriter.writeData(measure, queryResult);
+
+    var result = new CsvImportResult();
+    result.setMeasurementId(measure.getElementId());
+    result.setMeasurementName(measure.getMeasureName());
+    result.setCreatedNewMeasurement(createdNewMeasurement);
+    result.setImportedRowCount(request.getRows().size());
+    result.setValidationMessages(List.of());
+    return result;
+  }
+
+  private List<CsvImportValidationMessage> validatePreviewRequest(CsvImportPreviewRequest request) {
+    var messages = new ArrayList<CsvImportValidationMessage>();
+    if (request == null) {
+      messages.add(message("request", "Import request must be provided."));
+      return messages;
+    }
+    if (request.getHeaders() == null || request.getHeaders().isEmpty()) {
+      messages.add(message("headers", "At least one header must be provided."));
+    }
+    if (request.getRows() == null || request.getRows().isEmpty()) {
+      messages.add(message("rows", "At least one row must be provided."));
+    }
+    validateRowsMatchHeaders(request.getHeaders(), request.getRows(), messages);
+    validateCsvConfig(request.getCsvConfig(), messages);
+    return messages;
+  }
+
+  private List<CsvImportValidationMessage> validateImportRequest(CsvImportRequest request) {
+    var messages = new ArrayList<CsvImportValidationMessage>();
+    if (request == null) {
+      messages.add(message("request", "Import request must be provided."));
+      return messages;
+    }
+    if (request.getHeaders() == null || request.getHeaders().isEmpty()) {
+      messages.add(message("headers", "At least one header must be provided."));
+    }
+    if (request.getRows() == null || request.getRows().isEmpty()) {
+      messages.add(message("rows", "At least one row must be provided."));
+    }
+    validateRowsMatchHeaders(request.getHeaders(), request.getRows(), messages);
+    validateCsvConfig(request.getCsvConfig(), messages);
+
+    if (request.getTarget() == null || request.getTarget().getMode() == null) {
+      messages.add(message("target", "An import target must be selected."));
+    }
+    if (request.getTimestampColumn() == null || request.getTimestampColumn().isBlank()) {
+      messages.add(message("timestampColumn", "A timestamp column must be selected."));
+    }
+    if (request.getColumns() == null || request.getColumns().isEmpty()) {
+      messages.add(message("columns", "Column configuration must be provided."));
+    }
+    return messages;
+  }
+
+  private List<CsvImportValidationMessage> validateSchemaRequest(CsvImportSchemaValidationRequest request) {
+    var messages = new ArrayList<CsvImportValidationMessage>();
+    if (request == null) {
+      messages.add(message("request", "Schema validation request must be provided."));
+      return messages;
+    }
+    if (request.getTarget() == null || request.getTarget().getMode() == null) {
+      messages.add(message("target", "An import target must be selected."));
+    }
+    if (request.getTimestampColumn() == null || request.getTimestampColumn().isBlank()) {
+      messages.add(message("timestampColumn", "A timestamp column must be selected."));
+    }
+    if (request.getColumns() == null || request.getColumns().isEmpty()) {
+      messages.add(message("columns", "Column configuration must be provided."));
+    }
+    return messages;
+  }
+
+  private void validateRowsMatchHeaders(
+      List<String> headers,
+      List<List<String>> rows,
+      List<CsvImportValidationMessage> messages
+  ) {
+    if (headers == null || rows == null) {
+      return;
+    }
+    for (int i = 0; i < rows.size(); i++) {
+      if (rows.get(i).size() != headers.size()) {
+        messages.add(message("rows", "Row " + (i + 1) + " does not match the header size."));
+        return;
+      }
+    }
+  }
+
+  private void validateCsvConfig(CsvImportConfiguration csvConfig, List<CsvImportValidationMessage> messages) {
+    if (csvConfig == null) {
+      messages.add(message("csvConfig", "CSV configuration must be provided."));
+      return;
+    }
+    if (csvConfig.getDecimalSeparator() == null
+        || (!",".equals(csvConfig.getDecimalSeparator()) && !".".equals(csvConfig.getDecimalSeparator()))) {
+      messages.add(message("csvConfig.decimalSeparator", "Decimal separator must be '.' or ','."));
+    }
+  }
+
+  private List<CsvImportValidationMessage> validatePreviewTarget(CsvImportTarget target) {
+    var messages = new ArrayList<CsvImportValidationMessage>();
+    if (target == null || target.getMode() == null) {
+      return messages;
+    }
+
+    var measurementName = target.getMeasurementName();
+    if (measurementName == null || measurementName.isBlank()) {
+      messages.add(message("target.measurementName", "A measurement name must be provided."));
+      return messages;
+    }
+
+    if (target.getMode() == CsvImportTargetMode.NEW) {
+      if (schemaManagement.getExistingMeasureByName(measurementName.trim()).isPresent()) {
+        messages.add(message("target.measurementName", "A measurement with this name already exists."));
+      }
+    } else if (schemaManagement.getExistingMeasureByName(measurementName.trim()).isEmpty()) {
+      messages.add(message("target.measurementName", "The selected measurement does not exist."));
+    }
+
+    return messages;
+  }
+
+  private List<CsvImportSchemaIssue> validateSchemaTarget(
+      CsvImportTarget target,
+      EventSchema importSchema,
+      String timestampColumn
+  ) {
+    var issues = new ArrayList<CsvImportSchemaIssue>();
+    if (target == null || target.getMode() == null) {
+      return issues;
+    }
+
+    var measurementName = target.getMeasurementName();
+    if (measurementName == null || measurementName.isBlank()) {
+      return issues;
+    }
+
+    if (target.getMode() == CsvImportTargetMode.NEW) {
+      return issues;
+    }
+
+    var existingOpt = schemaManagement.getExistingMeasureByName(measurementName.trim());
+    if (existingOpt.isPresent() && importSchema != null) {
+      var effectiveTimestampColumn = timestampColumn;
+      if (effectiveTimestampColumn == null) {
+        effectiveTimestampColumn = importSchema.getEventProperties().stream()
+            .filter(property -> SO.DATE_TIME.equals(property.getSemanticType()))
+            .map(EventProperty::getRuntimeName)
+            .findFirst()
+            .orElse(null);
+      }
+      if (effectiveTimestampColumn != null) {
+        issues.addAll(compareSchemas(existingOpt.get(), importSchema, effectiveTimestampColumn));
+      }
+    }
+    return issues;
+  }
+
+  private List<CsvImportValidationMessage> validateImportTarget(
+      CsvImportTarget target,
+      EventSchema importSchema,
+      String timestampColumn
+  ) {
+    var messages = new ArrayList<CsvImportValidationMessage>();
+    if (target == null || target.getMode() == null) {
+      return messages;
+    }
+
+    var measurementName = target.getMeasurementName();
+    if (measurementName == null || measurementName.isBlank()) {
+      messages.add(message("target.measurementName", "A measurement name must be provided."));
+      return messages;
+    }
+
+    if (target.getMode() == CsvImportTargetMode.NEW) {
+      if (schemaManagement.getExistingMeasureByName(measurementName.trim()).isPresent()) {
+        messages.add(message("target.measurementName", "A measurement with this name already exists."));
+      }
+      return messages;
+    }
+
+    var existingOpt = schemaManagement.getExistingMeasureByName(measurementName.trim());
+    if (existingOpt.isEmpty()) {
+      messages.add(message("target.measurementName", "The selected measurement does not exist."));
+    } else if (importSchema != null) {
+      var issues = compareSchemas(existingOpt.get(), importSchema, timestampColumn);
+      if (!issues.isEmpty()) {
+        messages.add(message("columns", "Imported columns must exactly match the existing measurement schema."));
+      }
+    }
+    return messages;
+  }
+
+  private List<CsvImportSchemaIssue> compareSchemas(
+      DataLakeMeasure existingMeasure,
+      EventSchema importSchema,
+      String timestampColumn
+  ) {
+    var issues = new ArrayList<CsvImportSchemaIssue>();
+
+    if (!Objects.equals(existingMeasure.getTimestampFieldName(), timestampColumn)) {
+      issues.add(issue(
+          CsvImportSchemaIssueType.TIMESTAMP_COLUMN_MISMATCH,
+          timestampColumn,
+          existingMeasure.getTimestampFieldName(),
+          timestampColumn
+      ));
+    }
+
+    var existingProperties = existingMeasure.getEventSchema()
+        .getEventProperties()
+        .stream()
+        .collect(Collectors.toMap(EventProperty::getRuntimeName, property -> property));
+    var importedProperties = importSchema.getEventProperties()
+        .stream()
+        .collect(Collectors.toMap(EventProperty::getRuntimeName, property -> property));
+
+    var unexpectedProperties = importedProperties.keySet().stream()
+        .filter(property -> !existingProperties.containsKey(property))
+        .sorted()
+        .toList();
+
+    if (!unexpectedProperties.isEmpty()) {
+      unexpectedProperties.forEach(property -> issues.add(issue(
+          CsvImportSchemaIssueType.COLUMN_NAME_MISMATCH,
+          property,
+          null,
+          property
+      )));
+    }
+
+    for (var entry : existingProperties.entrySet()) {
+      var imported = importedProperties.get(entry.getKey());
+      if (imported == null) {
+        continue;
+      }
+
+      if (!Objects.equals(getRuntimeType(entry.getValue()), getRuntimeType(imported))
+      ) {
+        issues.add(issue(
+            CsvImportSchemaIssueType.COLUMN_TYPE_MISMATCH,
+            entry.getKey(),
+            getRuntimeType(entry.getValue()),
+            getRuntimeType(imported)
+        ));
+      }
+
+      if (!Objects.equals(entry.getValue().getPropertyScope(), imported.getPropertyScope())) {
+        issues.add(issue(
+            CsvImportSchemaIssueType.COLUMN_SCOPE_MISMATCH,
+            entry.getKey(),
+            entry.getValue().getPropertyScope(),
+            imported.getPropertyScope()
+        ));
+      }
+    }
+
+    return issues;
+  }
+
+  private DataLakeMeasure requireExistingMeasurement(String measurementName) {
+    return schemaManagement.getExistingMeasureByName(measurementName)
+        .orElseThrow(() -> new CsvImportValidationException(List.of(
+            message("target.measurementName", "The selected measurement does not exist.")
+        )));
+  }
+
+  private SpQueryResult toQueryResult(CsvImportRequest request) {
+    var headers = request.getColumns().stream()
+        .map(CsvImportColumn::getRuntimeName)
+        .collect(Collectors.toList());
+    var rows = new ArrayList<List<Object>>();
+    for (var row : request.getRows()) {
+      var converted = new ArrayList<Object>();
+      for (int i = 0; i < row.size(); i++) {
+        converted.add(convertValue(row.get(i), request.getColumns().get(i), request.getCsvConfig(), request.getTimestampColumn()));
+      }
+      rows.add(converted);
+    }
+
+    var dataSeries = DataSeriesBuilder.create()
+        .withHeaders(headers)
+        .withRows(rows)
+        .build();
+    return SpQueryResultBuilder.create(headers)
+        .withDataSeries(dataSeries)
+        .build();
+  }
+
+  private EventSchema buildEventSchema(
+      List<CsvImportColumn> columns,
+      List<List<String>> rows,
+      CsvImportConfiguration config,
+      String selectedTimestampColumn
+  ) {
+    var sampleEvent = new LinkedHashMap<String, Object>();
+    for (int i = 0; i < columns.size(); i++) {
+      sampleEvent.put(columns.get(i).getRuntimeName(), sampleValue(rows, i, columns.get(i), config, selectedTimestampColumn));
+    }
+
+    var eventSchema = EventSchemaUtils.guessEventSchema(sampleEvent);
+    var properties = eventSchema.getEventProperties()
+        .stream()
+        .collect(Collectors.toMap(EventProperty::getRuntimeName, property -> property, (a, b) -> a, LinkedHashMap::new));
+
+    for (var column : columns) {
+      var property = (EventPropertyPrimitive) properties.get(column.getRuntimeName());
+      if (property == null) {
+        continue;
+      }
+      property.setRuntimeType(toRuntimeTypeUri(finalRuntimeType(column, selectedTimestampColumn)));
+      property.setPropertyScope(finalPropertyScope(column, selectedTimestampColumn));
+      property.setSemanticType(finalSemanticType(column, selectedTimestampColumn));
+      property.setLabel(Optional.ofNullable(column.getLabel()).orElse(""));
+      property.setDescription(Optional.ofNullable(column.getDescription()).orElse(""));
+    }
+
+    eventSchema.setEventProperties(new ArrayList<>(properties.values()));
+    return eventSchema;
+  }
+
+  private EventSchema buildConfiguredEventSchema(
+      List<CsvImportColumn> columns,
+      String selectedTimestampColumn
+  ) {
+    var properties = new ArrayList<EventProperty>();
+    for (var column : columns) {
+      var property = new EventPropertyPrimitive();
+      property.setRuntimeName(column.getRuntimeName());
+      property.setRuntimeType(toRuntimeTypeUri(finalRuntimeType(column, selectedTimestampColumn)));
+      property.setPropertyScope(finalPropertyScope(column, selectedTimestampColumn));
+      property.setSemanticType(finalSemanticType(column, selectedTimestampColumn));
+      property.setLabel(Optional.ofNullable(column.getLabel()).orElse(""));
+      property.setDescription(Optional.ofNullable(column.getDescription()).orElse(""));
+      properties.add(property);
+    }
+    return new EventSchema(properties);
+  }
+
+  private List<CsvImportColumn> inferColumns(
+      List<String> headers,
+      List<List<String>> rows,
+      CsvImportConfiguration config
+  ) {
+    var columns = new ArrayList<CsvImportColumn>();
+    for (int i = 0; i < headers.size(); i++) {
+      var runtimeName = headers.get(i);
+      var inferredType = inferType(rows, i, config);
+      var timestampCandidate = isTimestampCandidate(rows, i, config);
+      var column = new CsvImportColumn();
+      column.setCsvColumn(headers.get(i));
+      column.setRuntimeName(runtimeName);
+      column.setRuntimeType(inferredType);
+      column.setInferredType(inferredType);
+      column.setPropertyScope(timestampCandidate ? PropertyScope.HEADER_PROPERTY.name() : suggestedScope(inferredType));
+      column.setSemanticType(timestampCandidate ? SO.DATE_TIME : null);
+      column.setTimestampCandidate(timestampCandidate);
+      columns.add(column);
+    }
+    return columns;
+  }
+
+  private List<CsvImportColumn> sanitizeImportColumns(List<CsvImportColumn> columns) {
+    return columns.stream().map(column -> {
+      column.setRuntimeName(column.getRuntimeName().trim());
+      return column;
+    }).collect(Collectors.toList());
+  }
+
+  private List<String> sanitizeHeaders(List<String> headers) {
+    return headers.stream()
+        .map(header -> header == null ? "" : header.trim())
+        .collect(Collectors.toList());
+  }
+
+  private Object sampleValue(
+      List<List<String>> rows,
+      int columnIndex,
+      CsvImportColumn column,
+      CsvImportConfiguration config,
+      String selectedTimestampColumn
+  ) {
+    for (var row : rows) {
+      var converted = convertValue(row.get(columnIndex), column, config, selectedTimestampColumn);
+      if (converted != null) {
+        return converted;
+      }
+    }
+    return null;
+  }
+
+  private String inferType(List<List<String>> rows, int columnIndex, CsvImportConfiguration config) {
+    var allBoolean = true;
+    var allLong = true;
+    var allNumber = true;
+    var timestampCandidate = false;
+
+    for (var row : rows) {
+      var value = row.get(columnIndex);
+      if (value == null || value.isBlank()) {
+        continue;
+      }
+      if (!isBoolean(value)) {
+        allBoolean = false;
+      }
+      if (!isLong(value, config)) {
+        allLong = false;
+      }
+      if (!isNumber(value, config)) {
+        allNumber = false;
+      }
+    }
+
+    timestampCandidate = isTimestampCandidate(rows, columnIndex, config);
+
+    if (timestampCandidate || allLong) {
+      return "LONG";
+    } else if (allBoolean) {
+      return "BOOLEAN";
+    } else if (allNumber) {
+      return "FLOAT";
+    }
+    return "STRING";
+  }
+
+  private boolean isTimestampCandidate(List<List<String>> rows, int columnIndex, CsvImportConfiguration config) {
+    var hasValue = false;
+    for (var row : rows) {
+      var value = row.get(columnIndex);
+      if (value == null || value.isBlank()) {
+        continue;
+      }
+      hasValue = true;
+      if (!canParseTimestamp(value, config)) {
+        return false;
+      }
+    }
+    return hasValue;
+  }
+
+  private boolean canParseTimestamp(String value, CsvImportConfiguration config) {
+    if (isLong(value, config)) {
+      return true;
+    }
+    var timestampFormat = config == null ? null : config.getTimestampFormat();
+    if (timestampFormat == null || timestampFormat.isBlank()) {
+      return false;
+    }
+    try {
+      DateTimeFormatter.ofPattern(timestampFormat, Locale.ENGLISH).parse(value.trim());
+      return true;
+    } catch (DateTimeParseException e) {
+      return false;
+    }
+  }
+
+  private Object convertValue(
+      String rawValue,
+      CsvImportColumn column,
+      CsvImportConfiguration config,
+      String timestampColumn
+  ) {
+    if (rawValue == null || rawValue.isBlank()) {
+      return null;
+    }
+    var trimmed = rawValue.trim();
+    if (Objects.equals(column.getRuntimeName(), timestampColumn)) {
+      return parseTimestamp(trimmed, config);
+    }
+
+    return switch (finalRuntimeType(column, timestampColumn)) {
+      case "BOOLEAN" -> Boolean.parseBoolean(trimmed.toLowerCase(Locale.ENGLISH));
+      case "LONG" -> Long.parseLong(normalizeNumber(trimmed, config));
+      case "FLOAT" -> Double.parseDouble(normalizeNumber(trimmed, config));
+      default -> trimmed;
+    };
+  }
+
+  private long parseTimestamp(String value, CsvImportConfiguration config) {
+    if (isLong(value, config)) {
+      return Long.parseLong(normalizeNumber(value, config));
+    }
+
+    var formatter = DateTimeFormatter.ofPattern(config.getTimestampFormat(), Locale.ENGLISH);
+    try {
+      return LocalDateTime.parse(value, formatter).toInstant(ZoneOffset.UTC).toEpochMilli();
+    } catch (DateTimeParseException e) {
+      return Instant.from(formatter.parse(value)).toEpochMilli();
+    }
+  }
+
+  private boolean isBoolean(String value) {
+    return "true".equalsIgnoreCase(value.trim()) || "false".equalsIgnoreCase(value.trim());
+  }
+
+  private boolean isNumber(String value, CsvImportConfiguration config) {
+    try {
+      Double.parseDouble(normalizeNumber(value, config));
+      return true;
+    } catch (NumberFormatException e) {
+      return false;
+    }
+  }
+
+  private boolean isLong(String value, CsvImportConfiguration config) {
+    try {
+      var normalized = normalizeNumber(value, config);
+      if (normalized.contains(".")) {
+        return false;
+      }
+      Long.parseLong(normalized);
+      return true;
+    } catch (NumberFormatException e) {
+      return false;
+    }
+  }
+
+  private String normalizeNumber(String value, CsvImportConfiguration config) {
+    if (config != null && ",".equals(config.getDecimalSeparator())) {
+      return value.replace(".", "").replace(',', '.');
+    }
+    return value.replace(",", "");
+  }
+
+  private String suggestedScope(String inferredType) {
+    return switch (inferredType) {
+      case "LONG", "FLOAT" -> PropertyScope.MEASUREMENT_PROPERTY.name();
+      case "BOOLEAN", "STRING" -> PropertyScope.DIMENSION_PROPERTY.name();
+      default -> PropertyScope.MEASUREMENT_PROPERTY.name();
+    };
+  }
+
+  private String finalRuntimeType(CsvImportColumn column, String timestampColumn) {
+    if (Objects.equals(column.getRuntimeName(), timestampColumn)) {
+      return "LONG";
+    }
+    return Optional.ofNullable(column.getRuntimeType())
+        .orElseGet(column::getInferredType);
+  }
+
+  private String finalPropertyScope(CsvImportColumn column, String timestampColumn) {
+    if (Objects.equals(column.getRuntimeName(), timestampColumn)) {
+      return PropertyScope.HEADER_PROPERTY.name();
+    }
+    return Optional.ofNullable(column.getPropertyScope()).orElse(PropertyScope.MEASUREMENT_PROPERTY.name());
+  }
+
+  private String finalSemanticType(CsvImportColumn column, String timestampColumn) {
+    if (Objects.equals(column.getRuntimeName(), timestampColumn)) {
+      return SO.DATE_TIME;
+    }
+    return column.getSemanticType();
+  }
+
+  private String toRuntimeTypeUri(String runtimeType) {
+    return switch (runtimeType) {
+      case "BOOLEAN" -> XSD.BOOLEAN.toString();
+      case "LONG" -> XSD.LONG.toString();
+      case "FLOAT" -> XSD.FLOAT.toString();
+      default -> XSD.STRING.toString();
+    };
+  }
+
+  private CsvImportValidationMessage message(String field, String message) {
+    return new CsvImportValidationMessage(field, message);
+  }
+
+  private CsvImportSchemaIssue issue(
+      CsvImportSchemaIssueType type,
+      String columnName,
+      String expected,
+      String actual
+  ) {
+    return new CsvImportSchemaIssue(type, columnName, expected, actual);
+  }
+
+  private String normalize(String value) {
+    return value == null ? null : value.trim().toLowerCase(Locale.ENGLISH);
+  }
+
+  private String getRuntimeType(EventProperty property) {
+    if (property instanceof EventPropertyPrimitive primitive) {
+      return primitive.getRuntimeType();
+    }
+    return null;
+  }
+}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvImportValidationException.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvImportValidationException.java
new file mode 100644
index 0000000000..f5574db220
--- /dev/null
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/CsvImportValidationException.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.rest.impl.datalake;
+
+import org.apache.streampipes.model.datalake.importer.CsvImportValidationMessage;
+
+import java.util.List;
+
+public class CsvImportValidationException extends RuntimeException {
+
+  private final List<CsvImportValidationMessage> validationMessages;
+
+  public CsvImportValidationException(List<CsvImportValidationMessage> validationMessages) {
+    super(validationMessages.isEmpty() ? "CSV import validation failed" : validationMessages.get(0).getMessage());
+    this.validationMessages = validationMessages;
+  }
+
+  public List<CsvImportValidationMessage> getValidationMessages() {
+    return validationMessages;
+  }
+}
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeDataWriter.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeDataWriter.java
index 5bbdaa8bd6..a722b28484 100644
--- a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeDataWriter.java
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeDataWriter.java
@@ -49,6 +49,10 @@ public class DataLakeDataWriter {
     if (measure == null) {
       throw new SpRuntimeException("Measure \"" + measureName + "\" not found");
     }
+    writeData(measure, queryResult);
+  }
+
+  public void writeData(DataLakeMeasure measure, SpQueryResult queryResult) {
     var dataSeries = getDataSeries(queryResult);
     getTimeSeriesStoreAndPersistQueryResult(dataSeries, measure);
   }
@@ -134,4 +138,3 @@ public class DataLakeDataWriter {
 
 }
 
-
diff --git a/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeImportResource.java b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeImportResource.java
new file mode 100644
index 0000000000..a5cebe0d44
--- /dev/null
+++ b/streampipes-rest/src/main/java/org/apache/streampipes/rest/impl/datalake/DataLakeImportResource.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.rest.impl.datalake;
+
+import org.apache.streampipes.model.datalake.importer.CsvImportPreviewRequest;
+import org.apache.streampipes.model.datalake.importer.CsvImportPreviewResult;
+import org.apache.streampipes.model.datalake.importer.CsvImportRequest;
+import org.apache.streampipes.model.datalake.importer.CsvImportResult;
+import org.apache.streampipes.model.datalake.importer.CsvImportSchemaValidationRequest;
+import org.apache.streampipes.model.datalake.importer.CsvImportSchemaValidationResult;
+import org.apache.streampipes.model.datalake.importer.CsvImportTargetMode;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/api/v4/datalake/import")
+public class DataLakeImportResource extends AbstractDataLakeResource {
+
+  private final CsvDataLakeImportService importService;
+
+  public DataLakeImportResource() {
+    super();
+    this.importService = new CsvDataLakeImportService(this.dataLakeMeasureManagement);
+  }
+
+  @PostMapping(
+      path = "/preview",
+      consumes = MediaType.APPLICATION_JSON_VALUE,
+      produces = MediaType.APPLICATION_JSON_VALUE
+  )
+  @PreAuthorize("this.hasWriteAuthority()")
+  public ResponseEntity<CsvImportPreviewResult> preview(@RequestBody CsvImportPreviewRequest request) {
+    if (request.getTarget() != null
+        && request.getTarget().getMode() == CsvImportTargetMode.EXISTING
+        && this.dataLakeMeasureManagement.getExistingMeasureByName(request.getTarget().getMeasurementName()).isPresent()
+        && !this.checkPermissionByName(request.getTarget().getMeasurementName(), "WRITE")) {
+      return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
+    }
+    return ok(importService.preview(request));
+  }
+
+  @PostMapping(
+      path = "/validate-schema",
+      consumes = MediaType.APPLICATION_JSON_VALUE,
+      produces = MediaType.APPLICATION_JSON_VALUE
+  )
+  @PreAuthorize("this.hasWriteAuthority()")
+  public ResponseEntity<CsvImportSchemaValidationResult> validateSchema(
+      @RequestBody CsvImportSchemaValidationRequest request
+  ) {
+    if (request.getTarget() != null
+        && request.getTarget().getMode() == CsvImportTargetMode.EXISTING
+        && this.dataLakeMeasureManagement.getExistingMeasureByName(request.getTarget().getMeasurementName()).isPresent()
+        && !this.checkPermissionByName(request.getTarget().getMeasurementName(), "WRITE")) {
+      return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
+    }
+    return ok(importService.validateSchema(request));
+  }
+
+  @PostMapping(
+      consumes = MediaType.APPLICATION_JSON_VALUE,
+      produces = MediaType.APPLICATION_JSON_VALUE
+  )
+  @PreAuthorize("this.hasWriteAuthority()")
+  public ResponseEntity<CsvImportResult> importData(@RequestBody CsvImportRequest request) {
+    if (request.getTarget() != null
+        && request.getTarget().getMode() == CsvImportTargetMode.EXISTING
+        && this.dataLakeMeasureManagement.getExistingMeasureByName(request.getTarget().getMeasurementName()).isPresent()
+        && !this.checkPermissionByName(request.getTarget().getMeasurementName(), "WRITE")) {
+      return ResponseEntity.status(HttpStatus.FORBIDDEN).build();
+    }
+
+    try {
+      return ok(importService.importData(request, getAuthenticatedUserSid()));
+    } catch (CsvImportValidationException e) {
+      var result = new CsvImportResult();
+      result.setValidationMessages(e.getValidationMessages());
+      return ResponseEntity.badRequest().body(result);
+    }
+  }
+}
diff --git a/streampipes-rest/src/test/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportServiceTest.java b/streampipes-rest/src/test/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportServiceTest.java
new file mode 100644
index 0000000000..9224094a7f
--- /dev/null
+++ b/streampipes-rest/src/test/java/org/apache/streampipes/rest/impl/datalake/CsvDataLakeImportServiceTest.java
@@ -0,0 +1,219 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.streampipes.rest.impl.datalake;
+
+import org.apache.streampipes.dataexplorer.api.IDataExplorerSchemaManagement;
+import org.apache.streampipes.model.datalake.DataLakeMeasure;
+import org.apache.streampipes.model.datalake.importer.CsvImportColumn;
+import org.apache.streampipes.model.datalake.importer.CsvImportConfiguration;
+import org.apache.streampipes.model.datalake.importer.CsvImportPreviewRequest;
+import org.apache.streampipes.model.datalake.importer.CsvImportRequest;
+import org.apache.streampipes.model.datalake.importer.CsvImportSchemaIssueType;
+import org.apache.streampipes.model.datalake.importer.CsvImportSchemaValidationRequest;
+import org.apache.streampipes.model.datalake.importer.CsvImportTarget;
+import org.apache.streampipes.model.datalake.importer.CsvImportTargetMode;
+import org.apache.streampipes.model.schema.EventPropertyPrimitive;
+import org.apache.streampipes.model.schema.EventSchema;
+import org.apache.streampipes.vocabulary.SO;
+import org.apache.streampipes.vocabulary.XSD;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.Optional;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+class CsvDataLakeImportServiceTest {
+
+  @Test
+  void shouldInferTypesAndRejectDuplicateNewMeasurementNames() {
+    var schemaManagement = mock(IDataExplorerSchemaManagement.class);
+    var dataWriter = mock(DataLakeDataWriter.class);
+    var service = new CsvDataLakeImportService(schemaManagement, dataWriter);
+
+    var existingMeasure = new DataLakeMeasure();
+    existingMeasure.setMeasureName("existing-measure");
+    when(schemaManagement.getExistingMeasureByName("existing-measure"))
+        .thenReturn(Optional.of(existingMeasure));
+
+    var result = service.preview(makePreviewRequest("existing-measure"));
+
+    assertFalse(result.isValid());
+    assertEquals("LONG", result.getColumns().get(0).getInferredType());
+    assertEquals("FLOAT", result.getColumns().get(1).getInferredType());
+    assertTrue(result.getValidationMessages()
+        .stream()
+        .anyMatch(message -> message.getMessage().contains("already exists")));
+  }
+
+  @Test
+  void shouldReportSchemaMismatchInDedicatedValidationCall() {
+    var schemaManagement = mock(IDataExplorerSchemaManagement.class);
+    var dataWriter = mock(DataLakeDataWriter.class);
+    var service = new CsvDataLakeImportService(schemaManagement, dataWriter);
+
+    var existingMeasure = new DataLakeMeasure();
+    existingMeasure.setMeasureName("existing-measure");
+    existingMeasure.setTimestampField("s0::timestamp");
+    existingMeasure.setEventSchema(makeExistingSchema());
+
+    when(schemaManagement.getExistingMeasureByName("existing-measure"))
+        .thenReturn(Optional.of(existingMeasure));
+
+    var request = new CsvImportSchemaValidationRequest();
+    request.setTarget(makeTarget(CsvImportTargetMode.EXISTING, "existing-measure"));
+    request.setTimestampColumn("timestamp");
+    request.setColumns(makeImportRequest(CsvImportTargetMode.EXISTING, "existing-measure").getColumns());
+    request.getColumns().get(1).setRuntimeType("STRING");
+
+    var result = service.validateSchema(request);
+
+    assertFalse(result.isValid());
+    assertTrue(result.getIssues()
+        .stream()
+        .anyMatch(issue -> issue.getType() == CsvImportSchemaIssueType.COLUMN_TYPE_MISMATCH));
+  }
+
+  @Test
+  void shouldCreateNewMeasurementAndReuseSharedWriter() {
+    var schemaManagement = mock(IDataExplorerSchemaManagement.class);
+    var dataWriter = mock(DataLakeDataWriter.class);
+    var service = new CsvDataLakeImportService(schemaManagement, dataWriter);
+
+    when(schemaManagement.getExistingMeasureByName("new-measure"))
+        .thenReturn(Optional.empty());
+    when(schemaManagement.createOrUpdateMeasurement(any(DataLakeMeasure.class), any()))
+        .thenAnswer(invocation -> {
+          var measure = invocation.getArgument(0, DataLakeMeasure.class);
+          measure.setElementId("measure-id");
+          return measure;
+        });
+
+    var result = service.importData(makeImportRequest(CsvImportTargetMode.NEW, "new-measure"), "sid");
+
+    assertTrue(result.isCreatedNewMeasurement());
+    assertEquals(2, result.getImportedRowCount());
+    assertEquals("new-measure", result.getMeasurementName());
+    verify(dataWriter).writeData(any(DataLakeMeasure.class), any());
+  }
+
+  @Test
+  void shouldRejectSchemaMismatchForExistingMeasurement() {
+    var schemaManagement = mock(IDataExplorerSchemaManagement.class);
+    var dataWriter = mock(DataLakeDataWriter.class);
+    var service = new CsvDataLakeImportService(schemaManagement, dataWriter);
+
+    var existingMeasure = new DataLakeMeasure();
+    existingMeasure.setMeasureName("existing-measure");
+    existingMeasure.setTimestampField("s0::timestamp");
+    existingMeasure.setEventSchema(makeExistingSchema());
+
+    when(schemaManagement.getExistingMeasureByName("existing-measure"))
+        .thenReturn(Optional.of(existingMeasure));
+
+    var request = makeImportRequest(CsvImportTargetMode.EXISTING, "existing-measure");
+    request.getColumns().get(1).setRuntimeType("STRING");
+
+    var exception = assertThrows(
+        CsvImportValidationException.class,
+        () -> service.importData(request, "sid")
+    );
+
+    assertTrue(exception.getValidationMessages()
+        .stream()
+        .anyMatch(message -> message.getMessage().contains("exactly match")));
+  }
+
+  private CsvImportPreviewRequest makePreviewRequest(String measurementName) {
+    var request = new CsvImportPreviewRequest();
+    request.setCsvConfig(makeCsvConfig());
+    request.setHeaders(List.of("timestamp", "temperature"));
+    request.setRows(List.of(
+        List.of("1710000000000", "21.3"),
+        List.of("1710000060000", "22.1")
+    ));
+    request.setTarget(makeTarget(CsvImportTargetMode.NEW, measurementName));
+    return request;
+  }
+
+  private CsvImportRequest makeImportRequest(CsvImportTargetMode mode, String measurementName) {
+    var timestampColumn = new CsvImportColumn();
+    timestampColumn.setCsvColumn("timestamp");
+    timestampColumn.setRuntimeName("timestamp");
+    timestampColumn.setRuntimeType("LONG");
+    timestampColumn.setPropertyScope("HEADER_PROPERTY");
+    timestampColumn.setSemanticType(SO.DATE_TIME);
+
+    var measurementColumn = new CsvImportColumn();
+    measurementColumn.setCsvColumn("temperature");
+    measurementColumn.setRuntimeName("temperature");
+    measurementColumn.setRuntimeType("FLOAT");
+    measurementColumn.setPropertyScope("MEASUREMENT_PROPERTY");
+
+    var request = new CsvImportRequest();
+    request.setCsvConfig(makeCsvConfig());
+    request.setHeaders(List.of("timestamp", "temperature"));
+    request.setRows(List.of(
+        List.of("1710000000000", "21.3"),
+        List.of("1710000060000", "22.1")
+    ));
+    request.setTarget(makeTarget(mode, measurementName));
+    request.setTimestampColumn("timestamp");
+    request.setColumns(List.of(timestampColumn, measurementColumn));
+    return request;
+  }
+
+  private CsvImportTarget makeTarget(CsvImportTargetMode mode, String measurementName) {
+    var target = new CsvImportTarget();
+    target.setMode(mode);
+    target.setMeasurementName(measurementName);
+    return target;
+  }
+
+  private CsvImportConfiguration makeCsvConfig() {
+    var config = new CsvImportConfiguration();
+    config.setDelimiter(";");
+    config.setDecimalSeparator(".");
+    config.setHasHeader(true);
+    return config;
+  }
+
+  private EventSchema makeExistingSchema() {
+    var timestamp = new EventPropertyPrimitive();
+    timestamp.setRuntimeName("timestamp");
+    timestamp.setRuntimeType(XSD.LONG.toString());
+    timestamp.setPropertyScope("HEADER_PROPERTY");
+    timestamp.setSemanticType(SO.DATE_TIME);
+
+    var temperature = new EventPropertyPrimitive();
+    temperature.setRuntimeName("temperature");
+    temperature.setRuntimeType(XSD.FLOAT.toString());
+    temperature.setPropertyScope("MEASUREMENT_PROPERTY");
+
+    return new EventSchema(List.of(timestamp, temperature));
+  }
+}
diff --git a/ui/cypress/fixtures/datalake/machine-data-simulator-import-later-timestamps.csv b/ui/cypress/fixtures/datalake/machine-data-simulator-import-later-timestamps.csv
new file mode 100644
index 0000000000..ffebf58cdb
--- /dev/null
+++ b/ui/cypress/fixtures/datalake/machine-data-simulator-import-later-timestamps.csv
@@ -0,0 +1,8 @@
+timestamp,density,mass_flow,sensorId,sensor_fault_flags,temperature,volume_flow
+1773332612874,45.09791564941406,5.38472843170166,flowrate01,false,48.357521057128906,7.121278285980225
+1773332613877,45.41450881958008,3.8461437225341797,flowrate01,false,45.560585021972656,2.3554582595825195
+1773332614881,43.88202667236328,8.558311462402344,flowrate01,false,48.41770935058594,10.315744400024414
+1773332615891,41.70826721191406,9.090323448181152,flowrate01,false,43.636566162109375,3.0096521377563477
+1773332616893,45.57435607910156,6.7500104904174805,flowrate01,false,46.06317138671875,5.4591851234436035
+1773332617898,50.77702331542969,0.3111061155796051,flowrate01,false,41.02153396606445,8.603775024414062
+1773332618901,41.054115295410156,3.339233160018921,flowrate01,false,47.03628158569336,9.04764461517334
diff --git a/ui/cypress/fixtures/datalake/machine-data-simulator-import-mismatched-timestamp.csv b/ui/cypress/fixtures/datalake/machine-data-simulator-import-mismatched-timestamp.csv
new file mode 100644
index 0000000000..bbdca87e6c
--- /dev/null
+++ b/ui/cypress/fixtures/datalake/machine-data-simulator-import-mismatched-timestamp.csv
@@ -0,0 +1,8 @@
+event_time,density,mass_flow,sensorId,sensor_fault_flags,temperature,volume_flow
+1773332622874,45.09791564941406,5.38472843170166,flowrate01,false,48.357521057128906,7.121278285980225
+1773332623877,45.41450881958008,3.8461437225341797,flowrate01,false,45.560585021972656,2.3554582595825195
+1773332624881,43.88202667236328,8.558311462402344,flowrate01,false,48.41770935058594,10.315744400024414
+1773332625891,41.70826721191406,9.090323448181152,flowrate01,false,43.636566162109375,3.0096521377563477
+1773332626893,45.57435607910156,6.7500104904174805,flowrate01,false,46.06317138671875,5.4591851234436035
+1773332627898,50.77702331542969,0.3111061155796051,flowrate01,false,41.02153396606445,8.603775024414062
+1773332628901,41.054115295410156,3.339233160018921,flowrate01,false,47.03628158569336,9.04764461517334
diff --git a/ui/cypress/fixtures/datalake/machine-data-simulator-import-string-timestamp.csv b/ui/cypress/fixtures/datalake/machine-data-simulator-import-string-timestamp.csv
new file mode 100644
index 0000000000..f753413777
--- /dev/null
+++ b/ui/cypress/fixtures/datalake/machine-data-simulator-import-string-timestamp.csv
@@ -0,0 +1,8 @@
+timestamp_string,density,mass_flow,sensorId,sensor_fault_flags,temperature,volume_flow
+2026-03-11 12:23:22,45.09791564941406,5.38472843170166,flowrate01,false,48.357521057128906,7.121278285980225
+2026-03-11 12:23:23,45.41450881958008,3.8461437225341797,flowrate01,false,45.560585021972656,2.3554582595825195
+2026-03-11 12:23:24,43.88202667236328,8.558311462402344,flowrate01,false,48.41770935058594,10.315744400024414
+2026-03-11 12:23:25,41.70826721191406,9.090323448181152,flowrate01,false,43.636566162109375,3.0096521377563477
+2026-03-11 12:23:26,45.57435607910156,6.7500104904174805,flowrate01,false,46.06317138671875,5.4591851234436035
+2026-03-11 12:23:27,50.77702331542969,0.3111061155796051,flowrate01,false,41.02153396606445,8.603775024414062
+2026-03-11 12:23:28,41.054115295410156,3.339233160018921,flowrate01,false,47.03628158569336,9.04764461517334
diff --git a/ui/cypress/fixtures/datalake/machine-data-simulator-import.csv b/ui/cypress/fixtures/datalake/machine-data-simulator-import.csv
new file mode 100644
index 0000000000..b78fdbe7e1
--- /dev/null
+++ b/ui/cypress/fixtures/datalake/machine-data-simulator-import.csv
@@ -0,0 +1,8 @@
+timestamp,density,mass_flow,sensorId,sensor_fault_flags,temperature,volume_flow
+1773332602874,45.09791564941406,5.38472843170166,flowrate01,false,48.357521057128906,7.121278285980225
+1773332603877,45.41450881958008,3.8461437225341797,flowrate01,false,45.560585021972656,2.3554582595825195
+1773332604881,43.88202667236328,8.558311462402344,flowrate01,false,48.41770935058594,10.315744400024414
+1773332605891,41.70826721191406,9.090323448181152,flowrate01,false,43.636566162109375,3.0096521377563477
+1773332606893,45.57435607910156,6.7500104904174805,flowrate01,false,46.06317138671875,5.4591851234436035
+1773332607898,50.77702331542969,0.3111061155796051,flowrate01,false,41.02153396606445,8.603775024414062
+1773332608901,41.054115295410156,3.339233160018921,flowrate01,false,47.03628158569336,9.04764461517334
diff --git a/ui/cypress/support/utils/dataset/DatasetBtns.ts b/ui/cypress/support/utils/dataset/DatasetBtns.ts
index 36985d2541..670f5f34fb 100644
--- a/ui/cypress/support/utils/dataset/DatasetBtns.ts
+++ b/ui/cypress/support/utils/dataset/DatasetBtns.ts
@@ -20,4 +20,101 @@ export class DatasetBtns {
     public static datasetTable() {
         return cy.dataCy('datalake-settings', { timeout: 10000 });
     }
+
+    public static openCsvImportDialog() {
+        return cy.dataCy('open-csv-import-dialog', { timeout: 10000 });
+    }
+
+    public static csvImportFileInput() {
+        return cy.dataCy('csv-import-file-input', { timeout: 10000 });
+    }
+
+    public static csvImportTargetMode() {
+        return cy.dataCy('csv-import-target-mode', { timeout: 10000 });
+    }
+
+    public static csvImportTargetModeNew() {
+        return cy.dataCy('csv-import-target-mode-new', { timeout: 10000 });
+    }
+
+    public static csvImportTargetModeExisting() {
+        return cy.dataCy('csv-import-target-mode-existing', { timeout: 10000 });
+    }
+
+    public static csvImportNewMeasurement() {
+        return cy.dataCy('csv-import-new-measurement', { timeout: 10000 });
+    }
+
+    public static csvImportExistingMeasurement() {
+        return cy.dataCy('csv-import-existing-measurement', { timeout: 10000 });
+    }
+
+    public static csvImportExistingMeasurementOption(measurementName: string) {
+        return cy.dataCy(
+            `csv-import-existing-measurement-option-${measurementName}`,
+            { timeout: 10000 },
+        );
+    }
+
+    public static csvImportDelimiter() {
+        return cy.dataCy('csv-import-delimiter', { timeout: 10000 });
+    }
+
+    public static csvImportDelimiterComma() {
+        return cy.dataCy('csv-import-delimiter-comma', { timeout: 10000 });
+    }
+
+    public static csvImportNextBtn() {
+        return cy.dataCy('csv-import-next-btn', { timeout: 10000 });
+    }
+
+    public static csvImportUploadBtn() {
+        return cy.dataCy('csv-import-upload-btn', { timeout: 10000 });
+    }
+
+    public static csvImportCloseBtn() {
+        return cy.dataCy('csv-import-close-btn', { timeout: 10000 });
+    }
+
+    public static csvImportSuccessTitle() {
+        return cy.dataCy('csv-import-success-title', { timeout: 10000 });
+    }
+
+    public static csvImportColumnScope(index: number) {
+        return cy
+            .dataCy('csv-import-column-scope', { timeout: 10000 })
+            .eq(index);
+    }
+
+    public static csvImportColumnScopeTimestamp() {
+        return cy.dataCy('csv-import-column-scope-timestamp', {
+            timeout: 10000,
+        });
+    }
+
+    public static csvImportTimestampFormat() {
+        return cy.dataCy('csv-import-timestamp-format', { timeout: 10000 });
+    }
+
+    public static csvImportSchemaMismatch() {
+        return cy.dataCy('csv-import-schema-mismatch', { timeout: 10000 });
+    }
+
+    public static csvImportSchemaMismatchList() {
+        return cy.dataCy('csv-import-schema-mismatch-list', {
+            timeout: 10000,
+        });
+    }
+
+    public static csvImportSchemaMismatchItems() {
+        return cy.dataCy('csv-import-schema-mismatch-item', {
+            timeout: 10000,
+        });
+    }
+
+    public static datasetRow(name: string) {
+        return cy.contains('[data-cy="datalake-settings"] tbody tr', name, {
+            timeout: 10000,
+        });
+    }
 }
diff --git a/ui/cypress/support/utils/dataset/DatasetUtils.ts b/ui/cypress/support/utils/dataset/DatasetUtils.ts
index fbda2e8b20..f9513e29ce 100644
--- a/ui/cypress/support/utils/dataset/DatasetUtils.ts
+++ b/ui/cypress/support/utils/dataset/DatasetUtils.ts
@@ -20,6 +20,8 @@ import { PermissionUtils } from '../user/PermissionUtils';
 import { DatasetBtns } from './DatasetBtns';
 
 export class DatasetUtils {
+    private static readonly CSV_IMPORT_FIXTURE_PREFIX = 'cypress/fixtures/';
+
     public static goToDatasets() {
         cy.visit('#/datasets');
     }
@@ -41,4 +43,110 @@ export class DatasetUtils {
         DatasetUtils.goToDatasets();
         PermissionUtils.authorizeUser(datasetname, email);
     }
+
+    public static openCsvImportDialog() {
+        this.goToDatasets();
+        DatasetBtns.openCsvImportDialog().click();
+    }
+
+    public static uploadCsvImportFile(filePath: string) {
+        DatasetBtns.csvImportFileInput().selectFile(
+            this.CSV_IMPORT_FIXTURE_PREFIX + filePath,
+            { force: true },
+        );
+    }
+
+    public static createNewDatasetFromCsv(datasetName: string) {
+        DatasetBtns.csvImportTargetMode().click();
+        DatasetBtns.csvImportTargetModeNew().click();
+        DatasetBtns.csvImportNewMeasurement().clear().type(datasetName);
+    }
+
+    public static useExistingDatasetForCsvImport(datasetName: string) {
+        DatasetBtns.csvImportTargetMode().click();
+        DatasetBtns.csvImportTargetModeExisting().click();
+        DatasetBtns.csvImportExistingMeasurement().click();
+        DatasetBtns.csvImportExistingMeasurementOption(datasetName).click();
+    }
+
+    public static selectCsvImportDelimiterComma() {
+        DatasetBtns.csvImportDelimiter().click();
+        DatasetBtns.csvImportDelimiterComma().click();
+        cy.dataCy('csv-import-column-scope', { timeout: 10000 }).should(
+            'have.length',
+            7,
+        );
+    }
+
+    public static continueCsvImportToPreview() {
+        DatasetBtns.csvImportNextBtn().click();
+        cy.dataCy('csv-import-preview', { timeout: 10000 }).should(
+            'be.visible',
+        );
+    }
+
+    public static selectCsvImportTimestampColumn(columnIndex: number) {
+        DatasetBtns.csvImportColumnScope(columnIndex).click();
+        DatasetBtns.csvImportColumnScopeTimestamp().click();
+    }
+
+    public static setCsvImportTimestampFormat(format: string) {
+        DatasetBtns.csvImportTimestampFormat().clear().type(format);
+    }
+
+    public static uploadCsvImport() {
+        DatasetBtns.csvImportUploadBtn().click();
+        DatasetBtns.csvImportSuccessTitle().should('be.visible');
+        DatasetBtns.csvImportCloseBtn().click();
+    }
+
+    public static expectCsvImportSchemaMismatch(
+        summary: string,
+        detailText?: string,
+    ) {
+        DatasetBtns.csvImportSchemaMismatch().should('be.visible');
+        cy.dataCy('exception-message-title').should('contain.text', summary);
+        if (detailText) {
+            DatasetBtns.csvImportSchemaMismatchList().should('be.visible');
+            DatasetBtns.csvImportSchemaMismatchItems().should(
+                'contain.text',
+                detailText,
+            );
+        }
+    }
+
+    public static expectDatasetTotalEventCount(
+        datasetName: string,
+        expectedCount: string,
+    ) {
+        DatasetBtns.datasetRow(datasetName)
+            .should('be.visible')
+            .find('[data-cy="datalake-total-count-button"]')
+            .then($button => {
+                if ($button.length > 0) {
+                    cy.wrap($button).click({ force: true });
+                }
+            });
+
+        DatasetBtns.datasetRow(datasetName)
+            .find('[data-cy="datalake-number-of-events"]', {
+                timeout: 10000,
+            })
+            .should($element => {
+                const text = $element.text().trim();
+                expect(text).to.equal(expectedCount);
+            });
+    }
+
+    public static expectDatasetSevenDayEventCount(
+        datasetName: string,
+        expectedCount: string,
+    ) {
+        DatasetBtns.datasetRow(datasetName)
+            .should('be.visible')
+            .should($row => {
+                const text = $row.children().eq(2).text().trim();
+                expect(text).to.contain(expectedCount);
+            });
+    }
 }
diff --git a/ui/cypress/tests/dataset/csvImport.spec.ts b/ui/cypress/tests/dataset/csvImport.spec.ts
new file mode 100644
index 0000000000..63f7a9f9c9
--- /dev/null
+++ b/ui/cypress/tests/dataset/csvImport.spec.ts
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import { DatasetUtils } from '../../support/utils/dataset/DatasetUtils';
+
+describe('CSV import happy path', () => {
+    const datasetName = 'csv_machine_data_import';
+    const stringTimestampDatasetName = 'csv_machine_data_import_string_ts';
+    const existingDatasetName = 'csv_machine_data_existing_import';
+
+    beforeEach('Setup Test', () => {
+        cy.initStreamPipesTest();
+    });
+
+    it('Uploads a CSV file into a new dataset and shows the imported event count', () => {
+        DatasetUtils.openCsvImportDialog();
+        DatasetUtils.uploadCsvImportFile(
+            'datalake/machine-data-simulator-import.csv',
+        );
+        DatasetUtils.createNewDatasetFromCsv(datasetName);
+        DatasetUtils.continueCsvImportToPreview();
+        DatasetUtils.selectCsvImportDelimiterComma();
+        DatasetUtils.selectCsvImportTimestampColumn(0);
+        DatasetUtils.uploadCsvImport();
+        DatasetUtils.expectDatasetTotalEventCount(datasetName, '7');
+    });
+
+    it('Uploads a CSV file with string timestamps and transforms them during import', () => {
+        DatasetUtils.openCsvImportDialog();
+        DatasetUtils.uploadCsvImportFile(
+            'datalake/machine-data-simulator-import-string-timestamp.csv',
+        );
+        DatasetUtils.createNewDatasetFromCsv(stringTimestampDatasetName);
+        DatasetUtils.continueCsvImportToPreview();
+        DatasetUtils.selectCsvImportDelimiterComma();
+        DatasetUtils.selectCsvImportTimestampColumn(0);
+        DatasetUtils.setCsvImportTimestampFormat('yyyy-MM-dd HH:mm:ss');
+        DatasetUtils.uploadCsvImport();
+        DatasetUtils.expectDatasetTotalEventCount(
+            stringTimestampDatasetName,
+            '7',
+        );
+    });
+
+    it('Appends matching data to an existing dataset and warns on mismatched timestamp schema', () => {
+        DatasetUtils.openCsvImportDialog();
+        DatasetUtils.uploadCsvImportFile(
+            'datalake/machine-data-simulator-import.csv',
+        );
+        DatasetUtils.createNewDatasetFromCsv(existingDatasetName);
+        DatasetUtils.continueCsvImportToPreview();
+        DatasetUtils.selectCsvImportDelimiterComma();
+        DatasetUtils.selectCsvImportTimestampColumn(0);
+        DatasetUtils.uploadCsvImport();
+        DatasetUtils.expectDatasetSevenDayEventCount(existingDatasetName, '7');
+
+        DatasetUtils.openCsvImportDialog();
+        DatasetUtils.uploadCsvImportFile(
+            'datalake/machine-data-simulator-import-later-timestamps.csv',
+        );
+        DatasetUtils.useExistingDatasetForCsvImport(existingDatasetName);
+        DatasetUtils.continueCsvImportToPreview();
+        DatasetUtils.selectCsvImportDelimiterComma();
+        DatasetUtils.selectCsvImportTimestampColumn(0);
+        DatasetUtils.uploadCsvImport();
+        DatasetUtils.expectDatasetSevenDayEventCount(existingDatasetName, '14');
+
+        DatasetUtils.openCsvImportDialog();
+        DatasetUtils.uploadCsvImportFile(
+            'datalake/machine-data-simulator-import-mismatched-timestamp.csv',
+        );
+        DatasetUtils.useExistingDatasetForCsvImport(existingDatasetName);
+        DatasetUtils.continueCsvImportToPreview();
+        DatasetUtils.selectCsvImportDelimiterComma();
+        DatasetUtils.selectCsvImportTimestampColumn(0);
+        DatasetUtils.expectCsvImportSchemaMismatch(
+            'Imported columns must exactly match the existing measurement schema.',
+            'Timestamp column must be "timestamp" but is "event_time".',
+        );
+    });
+});
diff --git a/ui/projects/streampipes/platform-services/src/lib/apis/datalake-rest.service.ts b/ui/projects/streampipes/platform-services/src/lib/apis/datalake-rest.service.ts
index c7f8aeec7a..cd92d0362c 100644
--- a/ui/projects/streampipes/platform-services/src/lib/apis/datalake-rest.service.ts
+++ b/ui/projects/streampipes/platform-services/src/lib/apis/datalake-rest.service.ts
@@ -29,6 +29,14 @@ import { DataLakeMeasure, SpQueryResult } from '../model/gen/streampipes-model';
 import { map } from 'rxjs/operators';
 import { DatalakeQueryParameters } from '../model/datalake/DatalakeQueryParameters';
 import { NGX_LOADING_BAR_IGNORED } from '@ngx-loading-bar/http-client';
+import {
+    CsvImportPreviewRequest,
+    CsvImportPreviewResult,
+    CsvImportRequest,
+    CsvImportResult,
+    CsvImportSchemaValidationRequest,
+    CsvImportSchemaValidationResult,
+} from '../model/datalake/csv-import.model';
 
 @Injectable({
     providedIn: 'root',
@@ -48,6 +56,10 @@ export class DatalakeRestService {
         return this.baseUrl + '/api/v4/datalake/measure';
     }
 
+    public get dataLakeImportUrl() {
+        return this.baseUrl + '/api/v4/datalake/import';
+    }
+
     getMeasurementEntryCounts(
         measurementNames: string[],
         daysBack = -1,
@@ -233,6 +245,28 @@ export class DatalakeRestService {
         return this.http.delete(url);
     }
 
+    previewImport(
+        request: CsvImportPreviewRequest,
+    ): Observable<CsvImportPreviewResult> {
+        return this.http.post<CsvImportPreviewResult>(
+            `${this.dataLakeImportUrl}/preview`,
+            request,
+        );
+    }
+
+    validateImportSchema(
+        request: CsvImportSchemaValidationRequest,
+    ): Observable<CsvImportSchemaValidationResult> {
+        return this.http.post<CsvImportSchemaValidationResult>(
+            `${this.dataLakeImportUrl}/validate-schema`,
+            request,
+        );
+    }
+
+    importCsvData(request: CsvImportRequest): Observable<CsvImportResult> {
+        return this.http.post<CsvImportResult>(this.dataLakeImportUrl, request);
+    }
+
     dropSingleMeasurementSeries(index: string) {
         const url = this.dataLakeUrl + '/measurements/' + index + '/drop';
         return this.http.delete(url);
diff --git a/ui/projects/streampipes/platform-services/src/lib/model/datalake/csv-import.model.ts b/ui/projects/streampipes/platform-services/src/lib/model/datalake/csv-import.model.ts
new file mode 100644
index 0000000000..00f058fca2
--- /dev/null
+++ b/ui/projects/streampipes/platform-services/src/lib/model/datalake/csv-import.model.ts
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import { EventSchema } from '../gen/streampipes-model';
+
+export type CsvImportTargetMode = 'NEW' | 'EXISTING';
+export type CsvRuntimeType = 'STRING' | 'BOOLEAN' | 'LONG' | 'FLOAT';
+
+export interface CsvImportConfiguration {
+    delimiter: string;
+    decimalSeparator: '.' | ',';
+    hasHeader: boolean;
+    timestampFormat?: string;
+}
+
+export interface CsvImportTarget {
+    mode: CsvImportTargetMode;
+    measurementName: string;
+}
+
+export interface CsvImportColumn {
+    csvColumn: string;
+    runtimeName: string;
+    runtimeType: CsvRuntimeType;
+    propertyScope?: string;
+    semanticType?: string;
+    label?: string;
+    description?: string;
+    inferredType?: CsvRuntimeType;
+    timestampCandidate?: boolean;
+}
+
+export interface CsvImportValidationMessage {
+    field: string;
+    message: string;
+}
+
+export interface CsvImportPreviewRequest {
+    fileName?: string;
+    csvConfig: CsvImportConfiguration;
+    headers: string[];
+    rows: string[][];
+    target?: CsvImportTarget;
+}
+
+export interface CsvImportPreviewResult {
+    headers: string[];
+    previewRows: string[][];
+    columns: CsvImportColumn[];
+    guessedEventSchema: EventSchema;
+    timestampCandidates: string[];
+    valid: boolean;
+    validationMessages: CsvImportValidationMessage[];
+}
+
+export interface CsvImportSchemaValidationRequest {
+    target: CsvImportTarget;
+    timestampColumn: string;
+    columns: CsvImportColumn[];
+}
+
+export type CsvImportSchemaIssueType =
+    | 'TIMESTAMP_COLUMN_MISMATCH'
+    | 'COLUMN_NAME_MISMATCH'
+    | 'COLUMN_TYPE_MISMATCH'
+    | 'COLUMN_SCOPE_MISMATCH';
+
+export interface CsvImportSchemaIssue {
+    type: CsvImportSchemaIssueType;
+    columnName?: string;
+    expected?: string | null;
+    actual?: string | null;
+}
+
+export interface CsvImportSchemaValidationResult {
+    valid: boolean;
+    validationMessages: CsvImportValidationMessage[];
+    issues: CsvImportSchemaIssue[];
+}
+
+export interface CsvImportRequest {
+    csvConfig: CsvImportConfiguration;
+    headers: string[];
+    rows: string[][];
+    target: CsvImportTarget;
+    timestampColumn: string;
+    columns: CsvImportColumn[];
+}
+
+export interface CsvImportResult {
+    measurementName: string;
+    measurementId: string;
+    createdNewMeasurement: boolean;
+    importedRowCount: number;
+    validationMessages: CsvImportValidationMessage[];
+}
diff --git a/ui/projects/streampipes/platform-services/src/public-api.ts b/ui/projects/streampipes/platform-services/src/public-api.ts
index 3754b801ed..732732d5d7 100644
--- a/ui/projects/streampipes/platform-services/src/public-api.ts
+++ b/ui/projects/streampipes/platform-services/src/public-api.ts
@@ -62,6 +62,7 @@ export * from './lib/apis/export-provider.service';
 
 export * from './lib/model/datalake/DateRange';
 export * from './lib/model/datalake/DatalakeQueryParameters';
+export * from './lib/model/datalake/csv-import.model';
 export * from './lib/model/dashboard/dashboard.model';
 export * from './lib/model/config/email-config.model';
 export * from './lib/model/config/general-config.model';
diff --git a/ui/src/app/dataset/components/datalake-configuration/datalake-configuration.component.html b/ui/src/app/dataset/components/datalake-configuration/datalake-configuration.component.html
index db6509a8b5..1c4f55be91 100644
--- a/ui/src/app/dataset/components/datalake-configuration/datalake-configuration.component.html
+++ b/ui/src/app/dataset/components/datalake-configuration/datalake-configuration.component.html
@@ -28,6 +28,15 @@
                 [title]="'Datasets' | translate"
             ></sp-basic-header-title-component>
             <span fxFlex></span>
+            <button
+                *ngIf="writeAccess"
+                color="accent"
+                mat-flat-button
+                data-cy="open-csv-import-dialog"
+                (click)="openCsvImportDialog()"
+            >
+                {{ 'Import CSV' | translate }}
+            </button>
             <button
                 color="accent"
                 mat-icon-button
diff --git a/ui/src/app/dataset/components/datalake-configuration/datalake-configuration.component.ts b/ui/src/app/dataset/components/datalake-configuration/datalake-configuration.component.ts
index 8e8e8b61b0..e79a4cf609 100644
--- a/ui/src/app/dataset/components/datalake-configuration/datalake-configuration.component.ts
+++ b/ui/src/app/dataset/components/datalake-configuration/datalake-configuration.component.ts
@@ -73,6 +73,7 @@ import { ExportProviderConnectionTestComponent } from '../../dialog/export-provi
 import { DataRetentionLogDialogComponent } from '../../dialog/data-retention-log-dialog/data-retention-log-dialog.component';
 import { UserPrivilege } from '../../../core/auth/user-privilege.enum';
 import { UserRole } from '../../../core/auth/user-role.enum';
+import { CsvImportDialogComponent } from '../../dialog/csv-import-dialog/csv-import-dialog.component';
 import {
     FlexDirective,
     FlexOrderDirective,
@@ -443,6 +444,26 @@ export class DatalakeConfigurationComponent implements OnInit, AfterViewInit {
         });
     }
 
+    openCsvImportDialog() {
+        const dialogRef: DialogRef<CsvImportDialogComponent> =
+            this.dialogService.open(CsvImportDialogComponent, {
+                panelType: PanelType.SLIDE_IN_PANEL,
+                title: this.translateService.instant('Import CSV'),
+                width: '60vw',
+                data: {
+                    measurementNames: this.availableMeasurements.map(
+                        measurement => measurement.name,
+                    ),
+                },
+            });
+
+        dialogRef.afterClosed().subscribe(refresh => {
+            if (refresh) {
+                this.loadAvailableMeasurements();
+            }
+        });
+    }
+
     queryEntryCounts(
         measurements: string[],
         targetField: string,
diff --git a/ui/src/app/dataset/dialog/csv-import-dialog/csv-import-dialog.component.html b/ui/src/app/dataset/dialog/csv-import-dialog/csv-import-dialog.component.html
new file mode 100644
index 0000000000..92b33e8de6
--- /dev/null
+++ b/ui/src/app/dataset/dialog/csv-import-dialog/csv-import-dialog.component.html
@@ -0,0 +1,523 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  ~
+  -->
+
+<div class="sp-dialog-container csv-import-shell">
+    <div class="sp-dialog-content p-15 csv-import-content">
+        @if (topMessages.length > 0) {
+            <div class="message-box" data-cy="csv-import-messages">
+                @for (message of topMessages; track message.message) {
+                    <div class="message-line">{{ message.message }}</div>
+                }
+            </div>
+        }
+
+        <mat-horizontal-stepper #csvImportStepper>
+            <mat-step>
+                <sp-split-section
+                    [level]="3"
+                    [title]="'Upload CSV file' | translate"
+                >
+                    <div class="upload-row">
+                        <label
+                            class="file-label"
+                            data-cy="csv-import-file-label"
+                        >
+                            <span>{{
+                                fileName || ('Select CSV file' | translate)
+                            }}</span>
+                            <input
+                                type="file"
+                                accept=".csv,text/csv"
+                                (change)="onFileSelected($event)"
+                                data-cy="csv-import-file-input"
+                            />
+                        </label>
+                        @if (fileName) {
+                            <div class="file-name">{{ fileName }}</div>
+                        }
+                    </div>
+                </sp-split-section>
+
+                <sp-split-section
+                    [level]="3"
+                    [title]="'Choose target dataset' | translate"
+                >
+                    <div class="grid">
+                        <sp-form-field
+                            [level]="3"
+                            [label]="'Import target' | translate"
+                        >
+                            <mat-form-field appearance="outline" class="w-100">
+                                <mat-select
+                                    [formControl]="targetForm.controls.mode"
+                                    data-cy="csv-import-target-mode"
+                                >
+                                    <mat-option
+                                        value="NEW"
+                                        data-cy="csv-import-target-mode-new"
+                                    >
+                                        {{ 'Create new dataset' | translate }}
+                                    </mat-option>
+                                    <mat-option
+                                        value="EXISTING"
+                                        data-cy="csv-import-target-mode-existing"
+                                    >
+                                        {{ 'Use existing dataset' | translate }}
+                                    </mat-option>
+                                </mat-select>
+                            </mat-form-field>
+                        </sp-form-field>
+
+                        @if (targetMode === 'NEW') {
+                            <sp-form-field
+                                [level]="3"
+                                [label]="'Dataset name' | translate"
+                            >
+                                <mat-form-field
+                                    appearance="outline"
+                                    class="w-100"
+                                >
+                                    <input
+                                        matInput
+                                        [formControl]="
+                                            targetForm.controls
+                                                .newMeasurementName
+                                        "
+                                        data-cy="csv-import-new-measurement"
+                                    />
+                                </mat-form-field>
+                            </sp-form-field>
+                        } @else {
+                            <sp-form-field
+                                [level]="3"
+                                [label]="'Existing dataset' | translate"
+                            >
+                                <mat-form-field
+                                    appearance="outline"
+                                    class="w-100"
+                                >
+                                    <mat-select
+                                        [formControl]="
+                                            targetForm.controls
+                                                .existingMeasurementName
+                                        "
+                                        data-cy="csv-import-existing-measurement"
+                                    >
+                                        @for (
+                                            measurementName of measurementNames;
+                                            track measurementName
+                                        ) {
+                                            <mat-option
+                                                [value]="measurementName"
+                                                [attr.data-cy]="
+                                                    'csv-import-existing-measurement-option-' +
+                                                    measurementName
+                                                "
+                                            >
+                                                {{ measurementName }}
+                                            </mat-option>
+                                        }
+                                    </mat-select>
+                                </mat-form-field>
+                            </sp-form-field>
+                        }
+                    </div>
+                </sp-split-section>
+
+                <ng-template matStepLabel>{{
+                    'Input' | translate
+                }}</ng-template>
+            </mat-step>
+
+            <mat-step>
+                <sp-split-section
+                    [level]="3"
+                    [title]="'CSV configuration' | translate"
+                >
+                    @if (previewLoading) {
+                        <div section-actions>
+                            <mat-spinner [diameter]="24"></mat-spinner>
+                        </div>
+                    }
+
+                    <div class="grid">
+                        <sp-form-field
+                            [level]="3"
+                            [label]="'Delimiter' | translate"
+                        >
+                            <mat-form-field appearance="outline" class="w-100">
+                                <mat-select
+                                    [formControl]="parseForm.controls.delimiter"
+                                    data-cy="csv-import-delimiter"
+                                >
+                                    <mat-option
+                                        value=";"
+                                        data-cy="csv-import-delimiter-semicolon"
+                                        >;</mat-option
+                                    >
+                                    <mat-option
+                                        value=","
+                                        data-cy="csv-import-delimiter-comma"
+                                        >,</mat-option
+                                    >
+                                    <mat-option
+                                        value="|"
+                                        data-cy="csv-import-delimiter-pipe"
+                                        >|</mat-option
+                                    >
+                                    <mat-option
+                                        value="\t"
+                                        data-cy="csv-import-delimiter-tab"
+                                        >Tab</mat-option
+                                    >
+                                </mat-select>
+                            </mat-form-field>
+                        </sp-form-field>
+
+                        <sp-form-field
+                            [level]="3"
+                            [label]="'Decimal separator' | translate"
+                        >
+                            <mat-form-field appearance="outline" class="w-100">
+                                <mat-select
+                                    [formControl]="
+                                        parseForm.controls.decimalSeparator
+                                    "
+                                    data-cy="csv-import-decimal-separator"
+                                >
+                                    <mat-option
+                                        value=","
+                                        data-cy="csv-import-decimal-separator-comma"
+                                        >,</mat-option
+                                    >
+                                    <mat-option
+                                        value="."
+                                        data-cy="csv-import-decimal-separator-dot"
+                                        >.</mat-option
+                                    >
+                                </mat-select>
+                            </mat-form-field>
+                        </sp-form-field>
+                    </div>
+
+                    <mat-checkbox
+                        [formControl]="parseForm.controls.hasHeader"
+                        data-cy="csv-import-has-header"
+                    >
+                        {{ 'First row contains headers' | translate }}
+                    </mat-checkbox>
+                </sp-split-section>
+
+                <sp-split-section
+                    [level]="3"
+                    [title]="'Live preview' | translate"
+                >
+                    @if (currentTarget) {
+                        <div section-actions class="target-pill">
+                            {{ currentTargetLabel }}
+                        </div>
+                    }
+
+                    @if (hasSchemaMismatch) {
+                        <sp-alert-banner
+                            type="error"
+                            data-cy="csv-import-schema-mismatch"
+                            [title]="'Error' | translate"
+                            [description]="schemaMismatchSummary"
+                        ></sp-alert-banner>
+
+                        @if (schemaMismatchDetails.length > 0) {
+                            <ul
+                                class="schema-mismatch-list"
+                                data-cy="csv-import-schema-mismatch-list"
+                            >
+                                @for (
+                                    detail of schemaMismatchDetails;
+                                    track detail
+                                ) {
+                                    <li
+                                        class="schema-mismatch-item"
+                                        data-cy="csv-import-schema-mismatch-item"
+                                    >
+                                        {{ detail }}
+                                    </li>
+                                }
+                            </ul>
+                        }
+                    }
+
+                    @if (hasPreview) {
+                        <div
+                            class="preview-table-wrapper"
+                            data-cy="csv-import-preview"
+                        >
+                            <table class="preview-table preview-config-table">
+                                <thead>
+                                    <tr>
+                                        @for (
+                                            model of columnModels;
+                                            track model.column.csvColumn
+                                        ) {
+                                            <th>
+                                                <div class="header-cell">
+                                                    <div class="header-title">
+                                                        {{
+                                                            model.column
+                                                                .csvColumn
+                                                        }}
+                                                    </div>
+                                                    @if (
+                                                        isTimestampColumn(model)
+                                                    ) {
+                                                        <mat-form-field
+                                                            appearance="outline"
+                                                            class="w-100"
+                                                        >
+                                                            <input
+                                                                matInput
+                                                                [(ngModel)]="
+                                                                    timestampFormat
+                                                                "
+                                                                [ngModelOptions]="{
+                                                                    standalone: true,
+                                                                }"
+                                                                placeholder="yyyy-MM-dd HH:mm:ss"
+                                                                data-cy="csv-import-timestamp-format"
+                                                            />
+                                                        </mat-form-field>
+                                                    }
+                                                    <mat-form-field
+                                                        appearance="outline"
+                                                        class="w-100"
+                                                    >
+                                                        <mat-select
+                                                            [value]="
+                                                                model.column
+                                                                    .runtimeType ||
+                                                                model.column
+                                                                    .inferredType ||
+                                                                'STRING'
+                                                            "
+                                                            [disabled]="
+                                                                isTimestampColumn(
+                                                                    model
+                                                                )
+                                                            "
+                                                            (selectionChange)="
+                                                                setColumnType(
+                                                                    model,
+                                                                    $event.value
+                                                                )
+                                                            "
+                                                            data-cy="csv-import-column-type"
+                                                        >
+                                                            <mat-option
+                                                                value="STRING"
+                                                                >STRING</mat-option
+                                                            >
+                                                            <mat-option
+                                                                value="BOOLEAN"
+                                                                >BOOLEAN</mat-option
+                                                            >
+                                                            <mat-option
+                                                                value="LONG"
+                                                                >LONG</mat-option
+                                                            >
+                                                            <mat-option
+                                                                value="FLOAT"
+                                                                >FLOAT</mat-option
+                                                            >
+                                                        </mat-select>
+                                                    </mat-form-field>
+                                                    <mat-form-field
+                                                        appearance="outline"
+                                                        class="w-100"
+                                                    >
+                                                        <mat-select
+                                                            [value]="
+                                                                getColumnRole(
+                                                                    model
+                                                                )
+                                                            "
+                                                            (selectionChange)="
+                                                                setColumnRole(
+                                                                    model,
+                                                                    $event.value
+                                                                )
+                                                            "
+                                                            data-cy="csv-import-column-scope"
+                                                        >
+                                                            <mat-option
+                                                                value="TIMESTAMP"
+                                                                [disabled]="
+                                                                    isTimestampSelectionDisabled(
+                                                                        model
+                                                                    )
+                                                                "
+                                                                data-cy="csv-import-column-scope-timestamp"
+                                                            >
+                                                                {{
+                                                                    'Timestamp'
+                                                                        | translate
+                                                                }}
+                                                            </mat-option>
+                                                            <mat-option
+                                                                value="DIMENSION_PROPERTY"
+                                                                data-cy="csv-import-column-scope-dimension"
+                                                            >
+                                                                {{
+                                                                    'Dimension'
+                                                                        | translate
+                                                                }}
+                                                            </mat-option>
+                                                            <mat-option
+                                                                value="MEASUREMENT_PROPERTY"
+                                                                data-cy="csv-import-column-scope-measurement"
+                                                            >
+                                                                {{
+                                                                    'Measurement'
+                                                                        | translate
+                                                                }}
+                                                            </mat-option>
+                                                        </mat-select>
+                                                    </mat-form-field>
+                                                </div>
+                                            </th>
+                                        }
+                                    </tr>
+                                </thead>
+                                <tbody>
+                                    @for (row of previewRows; track $index) {
+                                        <tr>
+                                            @for (cell of row; track $index) {
+                                                <td>{{ cell }}</td>
+                                            }
+                                        </tr>
+                                    }
+                                </tbody>
+                            </table>
+                        </div>
+                    } @else {
+                        <div class="empty-state">
+                            {{
+                                'Preview is being prepared from the current CSV configuration.'
+                                    | translate
+                            }}
+                        </div>
+                    }
+                </sp-split-section>
+
+                <ng-template matStepLabel>{{
+                    'Preview' | translate
+                }}</ng-template>
+            </mat-step>
+
+            <mat-step>
+                <sp-split-section [level]="3" [title]="'Upload' | translate">
+                    <div class="upload-state">
+                        @if (importLoading) {
+                            <mat-spinner [diameter]="56"></mat-spinner>
+                            <div class="upload-title">
+                                {{ 'Uploading CSV data' | translate }}
+                            </div>
+                            <div class="upload-copy">
+                                {{
+                                    'The data is currently being written to the data lake.'
+                                        | translate
+                                }}
+                            </div>
+                        } @else if (hasImportResult) {
+                            <mat-icon class="success-icon"
+                                >check_circle</mat-icon
+                            >
+                            <div
+                                class="upload-title"
+                                data-cy="csv-import-success-title"
+                            >
+                                {{ 'Import completed' | translate }}
+                            </div>
+                            <div class="result-name">
+                                {{ importResult?.measurementName }}
+                            </div>
+                            <div class="result-meta">
+                                {{ importResult?.importedRowCount }}
+                                {{ 'rows imported' | translate }}
+                            </div>
+                        }
+                    </div>
+                </sp-split-section>
+
+                <ng-template matStepLabel>{{
+                    'Upload' | translate
+                }}</ng-template>
+            </mat-step>
+        </mat-horizontal-stepper>
+    </div>
+
+    <mat-divider></mat-divider>
+
+    <div class="sp-dialog-actions actions-align-right">
+        <button
+            mat-button
+            mat-flat-button
+            class="mat-basic"
+            style="margin-right: 10px"
+            (click)="close(hasImportResult)"
+            data-cy="csv-import-close-btn"
+        >
+            {{
+                hasImportResult ? ('Close' | translate) : ('Cancel' | translate)
+            }}
+        </button>
+        @if (csvImportStepper.selectedIndex === 1 && !importLoading) {
+            <button
+                mat-button
+                mat-flat-button
+                class="mat-basic"
+                style="margin-right: 10px"
+                (click)="previousStep()"
+            >
+                {{ 'Previous' | translate }}
+            </button>
+        }
+        @if (csvImportStepper.selectedIndex === 0) {
+            <button
+                mat-button
+                mat-flat-button
+                color="accent"
+                (click)="nextStep()"
+                [disabled]="!canProceedToConfiguration"
+                data-cy="csv-import-next-btn"
+            >
+                {{ 'Next' | translate }}
+            </button>
+        }
+        @if (csvImportStepper.selectedIndex === 1) {
+            <button
+                mat-button
+                mat-flat-button
+                color="accent"
+                (click)="startUpload()"
+                [disabled]="!canImport || importLoading"
+                data-cy="csv-import-upload-btn"
+            >
+                {{ 'Upload' | translate }}
+            </button>
+        }
+    </div>
+</div>
diff --git a/ui/src/app/dataset/dialog/csv-import-dialog/csv-import-dialog.component.scss b/ui/src/app/dataset/dialog/csv-import-dialog/csv-import-dialog.component.scss
new file mode 100644
index 0000000000..c598628067
--- /dev/null
+++ b/ui/src/app/dataset/dialog/csv-import-dialog/csv-import-dialog.component.scss
@@ -0,0 +1,236 @@
+.csv-import-shell {
+    min-height: 0;
+}
+
+.csv-import-content {
+    display: flex;
+    flex-direction: column;
+    gap: 18px;
+    max-height: 78vh;
+    overflow: auto;
+}
+
+.section-disabled {
+    opacity: 0.65;
+}
+
+.section-header {
+    display: flex;
+    align-items: flex-start;
+    justify-content: space-between;
+    gap: 16px;
+}
+
+.section-eyebrow {
+    color: var(--color-text-200, #5a6673);
+    font-size: 14px;
+    font-weight: 700;
+}
+
+.section-title {
+    font-size: 24px;
+    font-weight: 700;
+    line-height: 1.2;
+}
+
+.upload-row {
+    display: flex;
+    align-items: center;
+    gap: 12px;
+    flex-wrap: wrap;
+}
+
+.file-label {
+    display: inline-flex;
+    align-items: center;
+    justify-content: center;
+    min-height: 48px;
+    padding: 0 16px;
+    border: 1px dashed var(--color-primary, #24176e);
+    border-radius: 8px;
+    cursor: pointer;
+    font-weight: 500;
+}
+
+.file-label input {
+    display: none;
+}
+
+.file-name {
+    color: var(--color-text-200, #5a6673);
+    font-size: 14px;
+}
+
+.grid {
+    display: grid;
+    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
+    gap: 16px;
+}
+
+.inline-hint {
+    color: var(--color-text-200, #5a6673);
+    font-size: 14px;
+}
+
+.inline-actions {
+    display: flex;
+    justify-content: flex-end;
+}
+
+.preview-meta {
+    display: flex;
+    gap: 16px;
+    flex-wrap: wrap;
+    color: var(--color-text-200, #5a6673);
+    font-size: 13px;
+}
+
+.preview-table-wrapper {
+    overflow: auto;
+    border: 1px solid var(--color-border, #d8dee4);
+    border-radius: 14px;
+}
+
+.preview-table {
+    width: 100%;
+    border-collapse: collapse;
+    min-width: 900px;
+}
+
+.preview-table th,
+.preview-table td {
+    padding: 10px 12px;
+    border-bottom: 1px solid var(--color-border, #d8dee4);
+    text-align: left;
+    vertical-align: top;
+    white-space: nowrap;
+    font-size: 13px;
+}
+
+.preview-table th {
+    position: sticky;
+    top: 0;
+    background: #f8fafc;
+    z-index: 1;
+}
+
+.header-cell {
+    display: flex;
+    flex-direction: column;
+    gap: 10px;
+    min-width: 220px;
+}
+
+.header-title {
+    font-weight: 700;
+    font-size: 14px;
+    color: #111827;
+}
+
+.header-field {
+    width: 100%;
+}
+
+.header-hint {
+    color: var(--color-text-200, #5a6673);
+    font-size: 12px;
+}
+
+.target-pill {
+    display: inline-flex;
+    align-items: center;
+    padding: 4px 10px;
+    border-radius: 999px;
+    background: #eef4ff;
+    color: #1849a9;
+    font-size: 12px;
+    font-weight: 600;
+}
+
+.message-box {
+    border-radius: 12px;
+    background: #fff4e5;
+    color: #8a4b00;
+    padding: 12px 14px;
+}
+
+.message-line + .message-line {
+    margin-top: 6px;
+}
+
+.schema-mismatch-list {
+    margin: 10px 0 0;
+    padding-left: 20px;
+    color: var(--color-text-200, #5a6673);
+}
+
+.schema-mismatch-item + .schema-mismatch-item {
+    margin-top: 6px;
+}
+
+.empty-state {
+    padding: 20px;
+    border-radius: 12px;
+    background: #f8fafc;
+    color: var(--color-text-200, #5a6673);
+    font-size: 14px;
+}
+
+.result-card {
+    align-items: center;
+    text-align: center;
+}
+
+.upload-state {
+    min-height: 280px;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+    gap: 14px;
+    text-align: center;
+}
+
+.upload-title {
+    font-size: 20px;
+    font-weight: 600;
+}
+
+.upload-copy {
+    color: var(--color-text-200, #5a6673);
+    max-width: 420px;
+}
+
+.success-icon {
+    color: var(--color-success, #2e7d32);
+    font-size: 48px;
+    width: 48px;
+    height: 48px;
+}
+
+.result-name {
+    font-weight: 600;
+}
+
+.result-meta {
+    color: var(--color-text-200, #5a6673);
+}
+
+@media (max-width: 900px) {
+    .section-header {
+        flex-direction: column;
+        align-items: flex-start;
+    }
+
+    .section-title {
+        font-size: 20px;
+    }
+
+    .inline-actions {
+        justify-content: stretch;
+    }
+
+    .inline-actions button {
+        width: 100%;
+    }
+}
diff --git a/ui/src/app/dataset/dialog/csv-import-dialog/csv-import-dialog.component.ts b/ui/src/app/dataset/dialog/csv-import-dialog/csv-import-dialog.component.ts
new file mode 100644
index 0000000000..aa98238d6c
--- /dev/null
+++ b/ui/src/app/dataset/dialog/csv-import-dialog/csv-import-dialog.component.ts
@@ -0,0 +1,854 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import { Component, inject, Input, ViewChild } from '@angular/core';
+import {
+    FormBuilder,
+    FormsModule,
+    ReactiveFormsModule,
+    Validators,
+} from '@angular/forms';
+import {
+    CsvImportColumn,
+    CsvImportConfiguration,
+    CsvImportPreviewRequest,
+    CsvImportPreviewResult,
+    CsvImportRequest,
+    CsvImportResult,
+    CsvImportSchemaIssue,
+    CsvImportSchemaValidationRequest,
+    CsvImportSchemaValidationResult,
+    CsvImportTarget,
+    CsvImportValidationMessage,
+    DataType,
+    DatalakeRestService,
+    EventPropertyPrimitive,
+    SemanticType,
+} from '@streampipes/platform-services';
+import {
+    DialogRef,
+    FormFieldComponent,
+    SpAlertBannerComponent,
+    SplitSectionComponent,
+} from '@streampipes/shared-ui';
+import { CommonModule } from '@angular/common';
+import { MatButton } from '@angular/material/button';
+import { MatCheckbox } from '@angular/material/checkbox';
+import { MatFormField } from '@angular/material/form-field';
+import { MatInput } from '@angular/material/input';
+import { MatOption, MatSelect } from '@angular/material/select';
+import { MatDivider } from '@angular/material/divider';
+import { MatProgressSpinner } from '@angular/material/progress-spinner';
+import { MatIcon } from '@angular/material/icon';
+import { MatStep, MatStepLabel, MatStepper } from '@angular/material/stepper';
+import { TranslatePipe } from '@ngx-translate/core';
+
+interface CsvImportColumnModel {
+    column: CsvImportColumn;
+    eventProperty: EventPropertyPrimitive;
+}
+
+@Component({
+    selector: 'sp-csv-import-dialog',
+    templateUrl: './csv-import-dialog.component.html',
+    styleUrls: ['./csv-import-dialog.component.scss'],
+    imports: [
+        CommonModule,
+        FormsModule,
+        ReactiveFormsModule,
+        MatButton,
+        MatCheckbox,
+        FormFieldComponent,
+        SpAlertBannerComponent,
+        SplitSectionComponent,
+        MatFormField,
+        MatInput,
+        MatSelect,
+        MatOption,
+        MatDivider,
+        MatProgressSpinner,
+        MatIcon,
+        MatStepper,
+        MatStep,
+        MatStepLabel,
+        TranslatePipe,
+    ],
+})
+export class CsvImportDialogComponent {
+    @Input()
+    measurementNames: string[] = [];
+
+    @ViewChild('csvImportStepper', { static: true })
+    csvImportStepper: MatStepper;
+
+    private fb = inject(FormBuilder);
+    private dialogRef = inject(DialogRef<CsvImportDialogComponent>);
+    private datalakeRestService = inject(DatalakeRestService);
+    private previewReloadTimeout?: ReturnType<typeof setTimeout>;
+    private schemaValidationTimeout?: ReturnType<typeof setTimeout>;
+
+    fileName = '';
+    rawFileContent = '';
+    timestampFormat = '';
+    parsedHeaders: string[] = [];
+    parsedRows: string[][] = [];
+    previewResult?: CsvImportPreviewResult;
+    schemaValidationResult?: CsvImportSchemaValidationResult;
+    importResult?: CsvImportResult;
+    columnModels: CsvImportColumnModel[] = [];
+    previewLoading = false;
+    importLoading = false;
+    localMessages: CsvImportValidationMessage[] = [];
+
+    parseForm = this.fb.group({
+        delimiter: [';', Validators.required],
+        decimalSeparator: [',' as ',' | '.', Validators.required],
+        hasHeader: [true, Validators.required],
+    });
+
+    targetForm = this.fb.group({
+        mode: ['NEW', Validators.required],
+        newMeasurementName: [''],
+        existingMeasurementName: [''],
+    });
+
+    constructor() {
+        this.parseForm.valueChanges.subscribe(() => {
+            this.invalidatePreview();
+            if (this.csvImportStepper?.selectedIndex === 1) {
+                this.schedulePreviewReload();
+            }
+        });
+        this.targetForm.controls.mode.valueChanges.subscribe(mode => {
+            if (mode === 'NEW') {
+                this.targetForm.controls.existingMeasurementName.setValue('');
+            } else {
+                this.targetForm.controls.newMeasurementName.setValue('');
+            }
+            this.invalidatePreview();
+        });
+        this.targetForm.controls.newMeasurementName.valueChanges.subscribe(
+            () => {
+                this.invalidatePreview();
+            },
+        );
+        this.targetForm.controls.existingMeasurementName.valueChanges.subscribe(
+            () => {
+                this.invalidatePreview();
+            },
+        );
+    }
+
+    get topMessages(): CsvImportValidationMessage[] {
+        return [
+            ...(this.previewResult?.validationMessages?.filter(
+                message =>
+                    message.field !== 'columns' &&
+                    message.field !== 'timestampColumn' &&
+                    message.field !== 'schemaDetails',
+            ) ?? []),
+            ...this.localMessages,
+            ...(this.importResult?.validationMessages?.filter(
+                message =>
+                    message.field !== 'columns' &&
+                    message.field !== 'timestampColumn' &&
+                    message.field !== 'schemaDetails',
+            ) ?? []),
+        ];
+    }
+
+    get hasPreview(): boolean {
+        return !!this.previewResult;
+    }
+
+    get hasImportResult(): boolean {
+        return !!this.importResult?.measurementName;
+    }
+
+    get previewColumns(): string[] {
+        return this.previewResult?.headers ?? [];
+    }
+
+    get previewRows(): string[][] {
+        return this.previewResult?.previewRows ?? [];
+    }
+
+    get targetMode(): 'NEW' | 'EXISTING' {
+        return this.targetForm.get('mode')?.value as 'NEW' | 'EXISTING';
+    }
+
+    get selectedTimestampColumn(): string | undefined {
+        return this.columnModels.find(model =>
+            SemanticType.isTimestamp(model.eventProperty),
+        )?.column.runtimeName;
+    }
+
+    get canConfigureColumns(): boolean {
+        return this.hasPreview;
+    }
+
+    get canConfigureParse(): boolean {
+        return this.isTargetValid;
+    }
+
+    get canProceedToConfiguration(): boolean {
+        return this.isTargetValid && !!this.rawFileContent;
+    }
+
+    get canImport(): boolean {
+        return (
+            this.previewResult?.valid === true &&
+            !!this.currentTarget &&
+            !!this.selectedTimestampColumn &&
+            (this.targetMode !== 'EXISTING' ||
+                this.schemaValidationResult?.valid === true)
+        );
+    }
+
+    get selectedTimestampColumnModel(): CsvImportColumnModel | undefined {
+        return this.columnModels.find(model => this.isTimestampColumn(model));
+    }
+
+    isTimestampSelectionDisabled(model: CsvImportColumnModel): boolean {
+        return (
+            !!this.selectedTimestampColumnModel &&
+            !this.isTimestampColumn(model)
+        );
+    }
+
+    getColumnRole(
+        model: CsvImportColumnModel,
+    ): 'TIMESTAMP' | 'DIMENSION_PROPERTY' | 'MEASUREMENT_PROPERTY' {
+        if (this.isTimestampColumn(model)) {
+            return 'TIMESTAMP';
+        } else if (model.column.propertyScope === 'DIMENSION_PROPERTY') {
+            return 'DIMENSION_PROPERTY';
+        }
+        return 'MEASUREMENT_PROPERTY';
+    }
+
+    get isTargetValid(): boolean {
+        return this.validateLocalTarget().length === 0;
+    }
+
+    get hasSchemaMismatch(): boolean {
+        return (
+            this.targetMode === 'EXISTING' &&
+            !!this.schemaValidationResult?.issues?.length
+        );
+    }
+
+    get schemaMismatchSummary(): string {
+        return 'Imported columns must exactly match the existing measurement schema.';
+    }
+
+    get schemaMismatchDetails(): string[] {
+        return (this.schemaValidationResult?.issues ?? []).map(issue =>
+            this.toSchemaIssueText(issue),
+        );
+    }
+
+    get currentTargetLabel(): string {
+        if (!this.currentTarget) {
+            return '-';
+        }
+        return this.currentTarget.measurementName;
+    }
+
+    onFileSelected(event: Event): void {
+        const input = event.target as HTMLInputElement;
+        const file = input.files?.[0];
+        if (!file) {
+            return;
+        }
+
+        this.fileName = file.name;
+        this.timestampFormat = '';
+        const reader = new FileReader();
+        reader.onload = () => {
+            this.rawFileContent = `${reader.result ?? ''}`;
+            this.invalidatePreview();
+        };
+        reader.readAsText(file);
+    }
+
+    nextStep(): void {
+        if (this.csvImportStepper.selectedIndex === 0) {
+            if (!this.canProceedToConfiguration) {
+                this.localMessages = this.validateLocalTarget();
+                if (!this.rawFileContent) {
+                    this.localMessages.push({
+                        field: 'file',
+                        message: 'Please select a CSV file first.',
+                    });
+                }
+                return;
+            }
+            this.csvImportStepper.next();
+            this.loadPreview();
+        }
+    }
+
+    previousStep(): void {
+        this.csvImportStepper.previous();
+    }
+
+    startUpload(): void {
+        this.localMessages = this.validateLocalTarget();
+        if (!this.selectedTimestampColumn) {
+            this.localMessages.push({
+                field: 'timestampColumn',
+                message: 'Please select exactly one timestamp column.',
+            });
+        }
+        if (this.localMessages.length > 0 || !this.canImport) {
+            return;
+        }
+
+        this.csvImportStepper.next();
+        this.importData();
+    }
+
+    loadPreview(): void {
+        this.localMessages = [];
+        this.clearImportResult();
+
+        if (!this.isTargetValid || !this.currentTarget) {
+            this.localMessages = [
+                {
+                    field: 'target.measurementName',
+                    message:
+                        'Please complete the target dataset selection first.',
+                },
+            ];
+            return;
+        }
+
+        if (!this.rawFileContent) {
+            this.localMessages = [
+                { field: 'file', message: 'Please select a CSV file first.' },
+            ];
+            return;
+        }
+
+        try {
+            const { headers, rows } = this.parseCsv();
+            this.parsedHeaders = headers;
+            this.parsedRows = rows;
+        } catch (error) {
+            this.localMessages = [
+                {
+                    field: 'file',
+                    message:
+                        'The CSV file could not be parsed with the current settings.',
+                },
+            ];
+            return;
+        }
+
+        this.previewLoading = true;
+        this.datalakeRestService
+            .previewImport(this.buildPreviewRequest(this.currentTarget))
+            .subscribe({
+                next: preview => {
+                    this.previewResult = preview;
+                    this.columnModels = preview.columns.map(column =>
+                        this.toColumnModel(column),
+                    );
+                    this.schemaValidationResult = undefined;
+                    this.previewLoading = false;
+                    this.validateSchema();
+                },
+                error: error => {
+                    this.previewLoading = false;
+                    this.previewResult = undefined;
+                    this.schemaValidationResult = undefined;
+                    this.localMessages = [
+                        {
+                            field: 'preview',
+                            message:
+                                error?.error?.message ??
+                                'Preview could not be generated.',
+                        },
+                    ];
+                },
+            });
+    }
+
+    setColumnType(
+        model: CsvImportColumnModel,
+        type: 'STRING' | 'BOOLEAN' | 'LONG' | 'FLOAT',
+    ): void {
+        model.eventProperty.runtimeType = this.toRuntimeType(type);
+        model.column.runtimeType = type;
+        if (this.isTimestampColumn(model)) {
+            model.eventProperty.runtimeType = DataType.LONG;
+            model.column.runtimeType = 'LONG';
+        }
+        this.syncColumn(model);
+        this.scheduleSchemaValidation();
+    }
+
+    setColumnRole(
+        model: CsvImportColumnModel,
+        role: 'TIMESTAMP' | 'DIMENSION_PROPERTY' | 'MEASUREMENT_PROPERTY',
+    ): void {
+        if (role === 'TIMESTAMP') {
+            this.columnModels.forEach(other => {
+                if (SemanticType.isTimestamp(other.eventProperty)) {
+                    other.eventProperty.semanticType = undefined;
+                    if (
+                        other.eventProperty.propertyScope === 'HEADER_PROPERTY'
+                    ) {
+                        other.eventProperty.propertyScope =
+                            'MEASUREMENT_PROPERTY';
+                    }
+                    if (other.column.inferredType) {
+                        other.eventProperty.runtimeType = this.toRuntimeType(
+                            other.column.inferredType,
+                        );
+                    }
+                    this.syncColumn(other);
+                }
+            });
+            model.eventProperty.semanticType = SemanticType.TIMESTAMP;
+            model.eventProperty.propertyScope = 'HEADER_PROPERTY';
+            model.eventProperty.runtimeType = DataType.LONG;
+            model.column.runtimeType = 'LONG';
+        } else {
+            model.eventProperty.semanticType = undefined;
+            model.eventProperty.propertyScope = role;
+            model.eventProperty.runtimeType = this.toRuntimeType(
+                model.column.runtimeType ||
+                    model.column.inferredType ||
+                    'STRING',
+            );
+        }
+        this.syncColumn(model);
+        this.scheduleSchemaValidation();
+    }
+
+    isTimestampColumn(model: CsvImportColumnModel): boolean {
+        return SemanticType.isTimestamp(model.eventProperty);
+    }
+
+    importData(): void {
+        this.localMessages = this.validateLocalTarget();
+        if (!this.selectedTimestampColumn) {
+            this.localMessages.push({
+                field: 'timestampColumn',
+                message: 'Please select exactly one timestamp column.',
+            });
+        }
+        if (this.localMessages.length > 0) {
+            return;
+        }
+
+        this.importLoading = true;
+        this.datalakeRestService
+            .importCsvData(this.buildImportRequest())
+            .subscribe({
+                next: result => {
+                    this.importResult = result;
+                    this.importLoading = false;
+                },
+                error: error => {
+                    this.importLoading = false;
+                    this.importResult = error?.error as CsvImportResult;
+                    if (!this.hasImportResult) {
+                        this.csvImportStepper.previous();
+                    }
+                },
+            });
+    }
+
+    close(refresh = false): void {
+        this.dialogRef.close(refresh);
+    }
+
+    private parseCsv(): { headers: string[]; rows: string[][] } {
+        const delimiter = this.normalizeDelimiter(
+            this.parseForm.get('delimiter')?.value ?? ';',
+        );
+        const parsed = this.parseCsvContent(this.rawFileContent, delimiter);
+        const rows = parsed.filter(row =>
+            row.some(cell => `${cell}`.trim() !== ''),
+        );
+        if (rows.length === 0) {
+            throw new Error('CSV contains no rows');
+        }
+
+        const hasHeader = this.parseForm.get('hasHeader')?.value ?? true;
+        let headers: string[];
+        let contentRows: string[][];
+
+        if (hasHeader) {
+            headers = rows[0].map((header, index) =>
+                this.normalizeHeader(
+                    index === 0 ? this.stripBom(header) : header,
+                    index,
+                ),
+            );
+            contentRows = rows.slice(1);
+        } else {
+            headers = rows[0].map((_, index) => `column_${index + 1}`);
+            contentRows = rows;
+        }
+
+        return { headers, rows: contentRows };
+    }
+
+    private normalizeDelimiter(value: string): string {
+        return value === '\\t' ? '\t' : value;
+    }
+
+    private stripBom(value: string): string {
+        return value.replace(/^\uFEFF/, '');
+    }
+
+    private normalizeHeader(value: string, index: number): string {
+        const trimmed = value?.trim();
+        return trimmed ? trimmed : `column_${index + 1}`;
+    }
+
+    private parseCsvContent(content: string, delimiter: string): string[][] {
+        const rows: string[][] = [];
+        let currentRow: string[] = [];
+        let currentValue = '';
+        let inQuotes = false;
+
+        for (let i = 0; i < content.length; i++) {
+            const char = content[i];
+            const nextChar = content[i + 1];
+
+            if (char === '"') {
+                if (inQuotes && nextChar === '"') {
+                    currentValue += '"';
+                    i += 1;
+                } else {
+                    inQuotes = !inQuotes;
+                }
+            } else if (!inQuotes && char === delimiter) {
+                currentRow.push(currentValue);
+                currentValue = '';
+            } else if (!inQuotes && (char === '\n' || char === '\r')) {
+                if (char === '\r' && nextChar === '\n') {
+                    i += 1;
+                }
+                currentRow.push(currentValue);
+                rows.push(currentRow);
+                currentRow = [];
+                currentValue = '';
+            } else {
+                currentValue += char;
+            }
+        }
+
+        currentRow.push(currentValue);
+        rows.push(currentRow);
+        return rows;
+    }
+
+    private buildPreviewRequest(
+        target?: CsvImportTarget,
+    ): CsvImportPreviewRequest {
+        return {
+            fileName: this.fileName,
+            csvConfig: this.currentCsvConfig,
+            headers: this.parsedHeaders,
+            rows: this.parsedRows,
+            target,
+        };
+    }
+
+    private buildImportRequest(): CsvImportRequest {
+        return {
+            csvConfig: this.currentCsvConfig,
+            headers: this.parsedHeaders,
+            rows: this.parsedRows,
+            target: this.currentTarget!,
+            timestampColumn: this.selectedTimestampColumn!,
+            columns: this.columnModels.map(model => model.column),
+        };
+    }
+
+    private buildSchemaValidationRequest():
+        | CsvImportSchemaValidationRequest
+        | undefined {
+        if (!this.currentTarget || !this.selectedTimestampColumn) {
+            return undefined;
+        }
+
+        return {
+            target: this.currentTarget,
+            timestampColumn: this.selectedTimestampColumn,
+            columns: this.columnModels.map(model => model.column),
+        };
+    }
+
+    private validateLocalTarget(): CsvImportValidationMessage[] {
+        const messages: CsvImportValidationMessage[] = [];
+        if (this.targetMode === 'NEW') {
+            const name = this.targetForm
+                .get('newMeasurementName')
+                ?.value?.trim();
+            if (!name) {
+                messages.push({
+                    field: 'target.measurementName',
+                    message: 'Please provide a new dataset name.',
+                });
+            } else if (this.measurementNames.includes(name)) {
+                messages.push({
+                    field: 'target.measurementName',
+                    message: 'A dataset with this name already exists.',
+                });
+            }
+        } else if (!this.targetForm.get('existingMeasurementName')?.value) {
+            messages.push({
+                field: 'target.measurementName',
+                message: 'Please select an existing dataset.',
+            });
+        }
+        return messages;
+    }
+
+    private get currentCsvConfig(): CsvImportConfiguration {
+        return {
+            delimiter: this.parseForm.get('delimiter')?.value ?? ';',
+            decimalSeparator:
+                (this.parseForm.get('decimalSeparator')?.value as ',' | '.') ??
+                ',',
+            hasHeader: this.parseForm.get('hasHeader')?.value ?? true,
+            timestampFormat: this.timestampFormat.trim() || undefined,
+        };
+    }
+
+    get currentTarget(): CsvImportTarget | undefined {
+        if (this.targetMode === 'NEW') {
+            const measurementName = this.targetForm
+                .get('newMeasurementName')
+                ?.value?.trim();
+            return measurementName
+                ? { mode: 'NEW', measurementName }
+                : undefined;
+        }
+
+        const measurementName = this.targetForm.get('existingMeasurementName')
+            ?.value as string;
+        return measurementName
+            ? { mode: 'EXISTING', measurementName }
+            : undefined;
+    }
+
+    private toColumnModel(column: CsvImportColumn): CsvImportColumnModel {
+        const initialType = this.toDefaultColumnType(
+            column.runtimeType || column.inferredType || 'STRING',
+        );
+        const property = new EventPropertyPrimitive();
+        property['@class'] =
+            'org.apache.streampipes.model.schema.EventPropertyPrimitive';
+        property.runtimeName = column.runtimeName;
+        property.runtimeType = this.toRuntimeType(initialType);
+        property.propertyScope = 'MEASUREMENT_PROPERTY';
+        property.semanticType = undefined;
+        property.label = column.label || '';
+        property.description = column.description || '';
+        property.additionalMetadata = {};
+        return {
+            column: {
+                ...column,
+                runtimeType: initialType,
+                propertyScope: 'MEASUREMENT_PROPERTY',
+                semanticType: undefined,
+            },
+            eventProperty: property,
+        };
+    }
+
+    private syncColumn(model: CsvImportColumnModel): void {
+        model.column.runtimeName = model.eventProperty.runtimeName;
+        model.column.runtimeType = this.fromRuntimeType(
+            model.eventProperty.runtimeType,
+        );
+        model.column.propertyScope = model.eventProperty.propertyScope;
+        model.column.semanticType = model.eventProperty.semanticType;
+        model.column.label = model.eventProperty.label;
+        model.column.description = model.eventProperty.description;
+    }
+
+    private toRuntimeType(type: string): string {
+        switch (type) {
+            case 'BOOLEAN':
+                return DataType.BOOLEAN;
+            case 'LONG':
+                return DataType.LONG;
+            case 'FLOAT':
+                return DataType.FLOAT;
+            default:
+                return DataType.STRING;
+        }
+    }
+
+    private fromRuntimeType(
+        type: string,
+    ): 'STRING' | 'BOOLEAN' | 'LONG' | 'FLOAT' {
+        if (type === DataType.BOOLEAN) {
+            return 'BOOLEAN';
+        } else if (type === DataType.LONG || type === DataType.INTEGER) {
+            return 'LONG';
+        } else if (type === DataType.FLOAT || type === DataType.DOUBLE) {
+            return 'FLOAT';
+        }
+        return 'STRING';
+    }
+
+    private toDefaultColumnType(
+        type: string,
+    ): 'STRING' | 'BOOLEAN' | 'LONG' | 'FLOAT' {
+        if (type === 'BOOLEAN') {
+            return 'BOOLEAN';
+        } else if (type === 'STRING') {
+            return 'STRING';
+        }
+        return 'FLOAT';
+    }
+
+    private invalidatePreview(): void {
+        if (this.previewReloadTimeout) {
+            clearTimeout(this.previewReloadTimeout);
+        }
+        if (this.schemaValidationTimeout) {
+            clearTimeout(this.schemaValidationTimeout);
+        }
+        this.previewResult = undefined;
+        this.schemaValidationResult = undefined;
+        this.columnModels = [];
+        this.clearImportResult();
+    }
+
+    private clearImportResult(): void {
+        this.importResult = undefined;
+    }
+
+    private schedulePreviewReload(): void {
+        if (!this.canProceedToConfiguration || this.previewLoading) {
+            return;
+        }
+
+        if (this.previewReloadTimeout) {
+            clearTimeout(this.previewReloadTimeout);
+        }
+
+        this.previewReloadTimeout = setTimeout(() => {
+            this.loadPreview();
+        }, 250);
+    }
+
+    private validateSchema(): void {
+        const request = this.buildSchemaValidationRequest();
+        if (!request) {
+            this.schemaValidationResult = undefined;
+            return;
+        }
+
+        this.datalakeRestService.validateImportSchema(request).subscribe({
+            next: result => {
+                this.schemaValidationResult = result;
+            },
+            error: error => {
+                this.schemaValidationResult =
+                    error?.error as CsvImportSchemaValidationResult;
+                if (
+                    !this.schemaValidationResult?.validationMessages?.length &&
+                    !this.schemaValidationResult?.issues?.length
+                ) {
+                    this.schemaValidationResult = {
+                        valid: false,
+                        validationMessages: [
+                            {
+                                field: 'columns',
+                                message:
+                                    'Schema validation could not be completed.',
+                            },
+                        ],
+                        issues: [],
+                    };
+                }
+            },
+        });
+    }
+
+    private scheduleSchemaValidation(): void {
+        if (
+            !this.hasPreview ||
+            this.targetMode !== 'EXISTING' ||
+            !this.selectedTimestampColumn
+        ) {
+            this.schemaValidationResult = undefined;
+            return;
+        }
+
+        if (this.schemaValidationTimeout) {
+            clearTimeout(this.schemaValidationTimeout);
+        }
+
+        this.schemaValidationTimeout = setTimeout(() => {
+            this.validateSchema();
+        }, 250);
+    }
+
+    private toSchemaIssueText(issue: CsvImportSchemaIssue): string {
+        switch (issue.type) {
+            case 'TIMESTAMP_COLUMN_MISMATCH':
+                return `Timestamp column must be "${issue.expected}" but is "${issue.actual}".`;
+            case 'COLUMN_NAME_MISMATCH':
+                return `Column "${issue.actual || issue.columnName}" is not part of the existing measurement schema.`;
+            case 'COLUMN_TYPE_MISMATCH':
+                return `Column "${issue.columnName}" must use type "${this.formatSchemaValue(issue.expected)}" instead of "${this.formatSchemaValue(issue.actual)}".`;
+            case 'COLUMN_SCOPE_MISMATCH':
+                return `Column "${issue.columnName}" must use role "${this.formatScope(issue.expected)}" instead of "${this.formatScope(issue.actual)}".`;
+            default:
+                return 'Imported columns must exactly match the existing measurement schema.';
+        }
+    }
+
+    private formatSchemaValue(value?: string | null): string {
+        if (!value) {
+            return '-';
+        }
+
+        if (value.includes('#')) {
+            return value.substring(value.lastIndexOf('#') + 1).toUpperCase();
+        }
+
+        return value;
+    }
+
+    private formatScope(value?: string | null): string {
+        switch (value) {
+            case 'HEADER_PROPERTY':
+                return 'Header';
+            case 'DIMENSION_PROPERTY':
+                return 'Dimension';
+            case 'MEASUREMENT_PROPERTY':
+                return 'Measurement';
+            default:
+                return value || '-';
+        }
+    }
+}