This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new 68779a0de4 fix progress monitor in hop web and default to String
datatypes, fixes #7301 (#7311)
68779a0de4 is described below
commit 68779a0de47123cd5135ab4b9f16398fb88b466f
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Thu Jun 18 15:08:28 2026 +0200
fix progress monitor in hop web and default to String datatypes, fixes
#7301 (#7311)
---
.../pipeline/transforms/csvinput/CsvInputMeta.java | 7 +++--
.../text/TextFileCSVImportProgressDialog.java | 8 +++--
.../transforms/csvinput/CsvInputMetaTest.java | 35 ++++++++++++++++++++++
.../hop/ui/core/dialog/ProgressMonitorDialog.java | 20 ++++++-------
4 files changed, 55 insertions(+), 15 deletions(-)
diff --git
a/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/csvinput/CsvInputMeta.java
b/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/csvinput/CsvInputMeta.java
index f15d4a4560..9fa78c4ee8 100644
---
a/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/csvinput/CsvInputMeta.java
+++
b/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/csvinput/CsvInputMeta.java
@@ -271,8 +271,11 @@ public class CsvInputMeta extends
BaseTransformMeta<CsvInput, CsvInputData>
}
} else {
for (CsvInputField inputField : inputFields) {
- IValueMeta valueMeta =
- ValueMetaFactory.createValueMeta(inputField.getName(),
inputField.getType());
+ int fieldType = inputField.getType();
+ if (fieldType == IValueMeta.TYPE_NONE) {
+ fieldType = IValueMeta.TYPE_STRING;
+ }
+ IValueMeta valueMeta =
ValueMetaFactory.createValueMeta(inputField.getName(), fieldType);
valueMeta.setConversionMask(inputField.getFormat());
valueMeta.setLength(inputField.getLength());
valueMeta.setPrecision(inputField.getPrecision());
diff --git
a/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/fileinput/text/TextFileCSVImportProgressDialog.java
b/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/fileinput/text/TextFileCSVImportProgressDialog.java
index 69245d988b..9f6094a0fd 100644
---
a/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/fileinput/text/TextFileCSVImportProgressDialog.java
+++
b/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/fileinput/text/TextFileCSVImportProgressDialog.java
@@ -24,6 +24,7 @@ import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.apache.hop.core.Const;
@@ -378,14 +379,15 @@ public class TextFileCSVImportProgressDialog<T extends
ITextFileInputField>
for (int i = 0; i < nrFields; i++) {
T field = meta.getInputFields().get(i);
- StringEvaluator evaluator = evaluators.get(i);
- List<StringEvaluationResult> evaluationResults =
evaluator.getStringEvaluationResults();
+ StringEvaluator evaluator = i < evaluators.size() ? evaluators.get(i) :
null;
+ List<StringEvaluationResult> evaluationResults =
+ evaluator == null ? Collections.emptyList() :
evaluator.getStringEvaluationResults();
// If we didn't find any matching result, it's a String...
//
if (evaluationResults.isEmpty()) {
field.setType(IValueMeta.TYPE_STRING);
- field.setLength(evaluator.getMaxLength());
+ field.setLength(evaluator == null ? -1 : evaluator.getMaxLength());
} else {
StringEvaluationResult result = evaluator.getAdvicedResult();
if (result != null) {
diff --git
a/plugins/transforms/textfile/src/test/java/org/apache/hop/pipeline/transforms/csvinput/CsvInputMetaTest.java
b/plugins/transforms/textfile/src/test/java/org/apache/hop/pipeline/transforms/csvinput/CsvInputMetaTest.java
index 3a585c81f0..5b734ab6cf 100644
---
a/plugins/transforms/textfile/src/test/java/org/apache/hop/pipeline/transforms/csvinput/CsvInputMetaTest.java
+++
b/plugins/transforms/textfile/src/test/java/org/apache/hop/pipeline/transforms/csvinput/CsvInputMetaTest.java
@@ -17,10 +17,12 @@
package org.apache.hop.pipeline.transforms.csvinput;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -31,12 +33,14 @@ import org.apache.hop.core.Const;
import org.apache.hop.core.HopClientEnvironment;
import org.apache.hop.core.plugins.PluginRegistry;
import org.apache.hop.core.row.IValueMeta;
+import org.apache.hop.core.row.RowMeta;
import org.apache.hop.core.row.value.ValueMetaDate;
import org.apache.hop.core.row.value.ValueMetaInteger;
import org.apache.hop.core.row.value.ValueMetaNumber;
import org.apache.hop.core.row.value.ValueMetaPlugin;
import org.apache.hop.core.row.value.ValueMetaPluginType;
import org.apache.hop.core.row.value.ValueMetaString;
+import org.apache.hop.core.variables.Variables;
import org.apache.hop.core.xml.XmlHandler;
import org.apache.hop.metadata.inject.HopMetadataInjector;
import org.apache.hop.metadata.serializer.memory.MemoryMetadataProvider;
@@ -130,4 +134,35 @@ class CsvInputMetaTest {
Set<String> fields = map.get("INPUT_FIELDS");
assertEquals(9, fields.size());
}
+
+ /**
+ * Regression test for issue #7301: a field whose type was left undetermined
(None) by "Get
+ * Fields" - typically an all-empty column - must fall back to String when
building the output row
+ * so the data can still be read and previewed. Before the fix, getFields()
produced a None-typed
+ * value which threw "Unknown type None specified" while rendering
(PreviewRowsDialog).
+ */
+ @Test
+ void getFieldsFallsBackToStringForNoneTypedField() throws Exception {
+ HopClientEnvironment.init();
+
+ CsvInputField field = new CsvInputField();
+ field.setName("id_4_name");
+ field.setType(IValueMeta.TYPE_NONE);
+
+ CsvInputMeta meta = new CsvInputMeta();
+ meta.setFields(new CsvInputField[] {field});
+ meta.setLazyConversionActive(true); // matches the <binary-string> storage
in the report
+
+ RowMeta rowMeta = new RowMeta();
+ meta.getFields(rowMeta, "csv", null, null, new Variables(), null);
+
+ IValueMeta valueMeta = rowMeta.getValueMeta(0);
+ assertEquals(IValueMeta.TYPE_STRING, valueMeta.getType());
+
+ // PreviewRowsDialog.getDataForRow() renders each value through
IRowMeta#getString(); a
+ // None-typed value used to throw here.
+ Object[] row = {"abc".getBytes(StandardCharsets.UTF_8)};
+ assertDoesNotThrow(() -> rowMeta.getString(row, 0));
+ assertEquals("abc", rowMeta.getString(row, 0));
+ }
}
diff --git
a/ui/src/main/java/org/apache/hop/ui/core/dialog/ProgressMonitorDialog.java
b/ui/src/main/java/org/apache/hop/ui/core/dialog/ProgressMonitorDialog.java
index 865955ba30..2fb4bb054a 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/dialog/ProgressMonitorDialog.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/dialog/ProgressMonitorDialog.java
@@ -19,14 +19,17 @@ package org.apache.hop.ui.core.dialog;
import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.atomic.AtomicBoolean;
+import lombok.Getter;
import org.apache.hop.core.Const;
import org.apache.hop.core.IProgressMonitor;
import org.apache.hop.core.IRunnableWithProgress;
+import org.apache.hop.core.ProgressNullMonitorListener;
import org.apache.hop.i18n.BaseMessages;
import org.apache.hop.ui.core.PropsUi;
import org.apache.hop.ui.core.gui.GuiResource;
import org.apache.hop.ui.core.gui.WindowProperty;
import org.apache.hop.ui.pipeline.transform.BaseTransformDialog;
+import org.apache.hop.ui.util.EnvironmentUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.layout.FormAttachment;
@@ -45,7 +48,8 @@ public class ProgressMonitorDialog {
protected Shell parent;
protected Shell shell;
private Display display;
- protected IProgressMonitor progressMonitor;
+
+ @Getter protected IProgressMonitor progressMonitor;
private Label wlTask;
private Label wlSubTask;
@@ -59,17 +63,13 @@ public class ProgressMonitorDialog {
this.progressMonitor = new ProgressMonitor();
}
- /**
- * Returns the progress monitor to use for operations run in this progress
dialog.
- *
- * @return the progress monitor
- */
- public IProgressMonitor getProgressMonitor() {
- return progressMonitor;
- }
-
public void run(boolean cancelable, IRunnableWithProgress runnable)
throws InvocationTargetException, InterruptedException {
+ if (EnvironmentUtils.getInstance().isWeb()) {
+ runnable.run(new ProgressNullMonitorListener());
+ return;
+ }
+
createModalShell(cancelable);
int margin = layoutProgressWidgets();
addCancelButtonIfNeeded(cancelable, margin);