You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2023/03/09 09:10:43 UTC

[hop] branch master updated: Fix conversion mask for the aggregations CountAll, CountAny, CountDistinct of the transform MemoryGroupBy #2474

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

hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/master by this push:
     new 0d3f6e5816 Fix conversion mask for the aggregations CountAll, CountAny, CountDistinct of the transform MemoryGroupBy #2474
     new 139b5cf4ea Merge pull request #2519 from nadment/2474
0d3f6e5816 is described below

commit 0d3f6e58164804a5b757ec44f8df61a2e4aca8c3
Author: Nicolas Adment <39...@users.noreply.github.com>
AuthorDate: Tue Mar 7 21:28:15 2023 +0100

    Fix conversion mask for the aggregations CountAll, CountAny,
    CountDistinct of the transform MemoryGroupBy #2474
---
 .../transforms/memgroupby/MemoryGroupByMeta.java   | 23 +++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/plugins/transforms/memgroupby/src/main/java/org/apache/hop/pipeline/transforms/memgroupby/MemoryGroupByMeta.java b/plugins/transforms/memgroupby/src/main/java/org/apache/hop/pipeline/transforms/memgroupby/MemoryGroupByMeta.java
index dd86a09c4c..8e38d9265a 100644
--- a/plugins/transforms/memgroupby/src/main/java/org/apache/hop/pipeline/transforms/memgroupby/MemoryGroupByMeta.java
+++ b/plugins/transforms/memgroupby/src/main/java/org/apache/hop/pipeline/transforms/memgroupby/MemoryGroupByMeta.java
@@ -136,6 +136,7 @@ public class MemoryGroupByMeta extends BaseTransformMeta<MemoryGroupBy, MemoryGr
         int valueType = IValueMeta.TYPE_NONE;
         int length = -1;
         int precision = -1;
+        String mask = null;
 
         switch (aggregate.getType()) {
           case First:
@@ -145,11 +146,13 @@ public class MemoryGroupByMeta extends BaseTransformMeta<MemoryGroupBy, MemoryGr
           case Minimum:
           case Maximum:
             valueType = subj.getType();
+            mask = subj.getConversionMask();
             break;
           case CountDistinct:
           case CountAll:
           case CountAny:
             valueType = IValueMeta.TYPE_INTEGER;
+            mask = "0";
             break;
           case Sum:
           case Average:
@@ -158,11 +161,13 @@ public class MemoryGroupByMeta extends BaseTransformMeta<MemoryGroupBy, MemoryGr
             } else {
               valueType = IValueMeta.TYPE_NUMBER;
             }
-            break;
+            mask = subj.getConversionMask();
+            break;            
           case Median:
           case Percentile:
           case StandardDeviation:
             valueType = IValueMeta.TYPE_NUMBER;
+            mask = subj.getConversionMask();
             break;
           case ConcatComma:
           case ConcatString:
@@ -183,24 +188,24 @@ public class MemoryGroupByMeta extends BaseTransformMeta<MemoryGroupBy, MemoryGr
         }
 
         if (valueType != IValueMeta.TYPE_NONE) {
-          IValueMeta v;
+          IValueMeta valueMeta;
           try {
-            v = ValueMetaFactory.createValueMeta(valueName, valueType);
+            valueMeta = ValueMetaFactory.createValueMeta(valueName, valueType);
           } catch (HopPluginException e) {
             log.logError(
                 BaseMessages.getString(PKG, "MemoryGroupByMeta.Exception.UnknownValueMetaType"),
                 valueType,
                 e);
-            v = new ValueMetaNone(valueName);
+            valueMeta = new ValueMetaNone(valueName);
           }
-          v.setOrigin(origin);
-          v.setLength(length, precision);
+          valueMeta.setOrigin(origin);
+          valueMeta.setLength(length, precision);
 
-          if (subj != null) {
-            v.setConversionMask(subj.getConversionMask());
+          if (mask != null) {
+            valueMeta.setConversionMask(mask);
           }
 
-          fields.addValueMeta(v);
+          fields.addValueMeta(valueMeta);
         }
       }
     }