This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch
4101-precision-loss-in-correctionvaluetransformationruledescription-migration
in repository https://gitbox.apache.org/repos/asf/streampipes.git
The following commit(s) were added to
refs/heads/4101-precision-loss-in-correctionvaluetransformationruledescription-migration
by this push:
new 0b04771663 fix(#4101): Increase precision for correction value
transformation migration
0b04771663 is described below
commit 0b0477166339a827d99e48c74a3de6aba53a58de
Author: Philipp Zehnder <[email protected]>
AuthorDate: Fri Jan 16 10:10:47 2026 +0100
fix(#4101): Increase precision for correction value transformation migration
---
.../migrations/v099/connect/AdapterRuleConverter.java | 2 +-
.../v099/MigrateAdaptersToUseScriptTest.java | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v099/connect/AdapterRuleConverter.java
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v099/connect/AdapterRuleConverter.java
index 193a712d1d..d964ae32ed 100644
---
a/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v099/connect/AdapterRuleConverter.java
+++
b/streampipes-service-core/src/main/java/org/apache/streampipes/service/core/migrations/v099/connect/AdapterRuleConverter.java
@@ -130,7 +130,7 @@ public class AdapterRuleConverter {
}
var symbols = new DecimalFormatSymbols(Locale.US);
- var df = new DecimalFormat("0.###", symbols);
+ var df = new DecimalFormat("0.########################", symbols);
var formattedValue = df.format(rule.getCorrectionValue());
scriptBuilder.appendLine(String.format("event['%s'] = Number(event['%s'])
%s %s;",
diff --git
a/streampipes-service-core/src/test/java/org/apache/streampipes/service/core/migrations/v099/MigrateAdaptersToUseScriptTest.java
b/streampipes-service-core/src/test/java/org/apache/streampipes/service/core/migrations/v099/MigrateAdaptersToUseScriptTest.java
index b12978ec67..4d816d9432 100644
---
a/streampipes-service-core/src/test/java/org/apache/streampipes/service/core/migrations/v099/MigrateAdaptersToUseScriptTest.java
+++
b/streampipes-service-core/src/test/java/org/apache/streampipes/service/core/migrations/v099/MigrateAdaptersToUseScriptTest.java
@@ -189,6 +189,24 @@ class MigrateAdaptersToUseScriptTest {
assertTrue(adapter.getTransformationConfig().isScriptActive());
}
+ @Test
+ void executeMigration_TransformsCorrectionValueRuleWithVerySmallNumber()
throws IOException {
+ CorrectionValueTransformationRuleDescription rule = new
CorrectionValueTransformationRuleDescription();
+ rule.setRuntimeKey("temperature");
+ rule.setOperator("MULTIPLY");
+ rule.setCorrectionValue(0.000000000000000000001);
+
+ var adapter = createBaseAdapter(rule);
+ when(mockStorage.findAll()).thenReturn(List.of(adapter));
+
+ migration.executeMigration();
+
+ var script = adapter.getTransformationConfig().getScript();
+ assertTrue(script.contains("event['temperature'] =
Number(event['temperature']) * 0.000000000000000000001"));
+ assertTrue(adapter.getTransformationConfig().isScriptActive());
+ }
+
+
@Test
void executeMigration_TransformsRegexRule() throws IOException {
RegexTransformationRuleDescription rule = new
RegexTransformationRuleDescription();