[ 
https://issues.apache.org/jira/browse/DRILL-6375?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16495661#comment-16495661
 ] 

ASF GitHub Bot commented on DRILL-6375:
---------------------------------------

gparai commented on a change in pull request #1256: DRILL-6375 : Support for 
ANY_VALUE aggregate function
URL: https://github.com/apache/drill/pull/1256#discussion_r191920153
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/vector/complex/MapUtility.java
 ##########
 @@ -228,11 +228,301 @@ public static void writeToMapFromReader(FieldReader 
fieldReader, BaseWriter.MapW
           
fieldReader.copyAsValue(mapWriter.list(MappifyUtility.fieldValue).list());
           break;
         default:
-          throw new DrillRuntimeException(String.format("kvgen does not 
support input of type: %s", valueMinorType));
+          throw new DrillRuntimeException(String.format(caller
+              + " does not support input of type: %s", valueMinorType));
       }
     } catch (ClassCastException e) {
       final MaterializedField field = fieldReader.getField();
-      throw new DrillRuntimeException(String.format(TYPE_MISMATCH_ERROR, 
field.getName(), field.getType()));
+      throw new DrillRuntimeException(String.format(caller + 
TYPE_MISMATCH_ERROR, field.getName(), field.getType()));
+    }
+  }
+
+  public static void writeToMapFromReader(FieldReader fieldReader, 
BaseWriter.MapWriter mapWriter,
+      String fieldName, String caller) {
+    try {
+      MajorType valueMajorType = fieldReader.getType();
+      MinorType valueMinorType = valueMajorType.getMinorType();
+      boolean repeated = false;
+
+      if (valueMajorType.getMode() == TypeProtos.DataMode.REPEATED) {
+        repeated = true;
+      }
+
+      switch (valueMinorType) {
+        case TINYINT:
+          if (repeated) {
+            fieldReader.copyAsValue(mapWriter.list(fieldName).tinyInt());
+          } else {
+            fieldReader.copyAsValue(mapWriter.tinyInt(fieldName));
+          }
+          break;
+        case SMALLINT:
+          if (repeated) {
+            fieldReader.copyAsValue(mapWriter.list(fieldName).smallInt());
+          } else {
+            fieldReader.copyAsValue(mapWriter.smallInt(fieldName));
+          }
+          break;
+        case BIGINT:
+          if (repeated) {
+            fieldReader.copyAsValue(mapWriter.list(fieldName).bigInt());
+          } else {
+            fieldReader.copyAsValue(mapWriter.bigInt(fieldName));
+          }
+          break;
+        case INT:
+          if (repeated) {
+            fieldReader.copyAsValue(mapWriter.list(fieldName).integer());
+          } else {
+            fieldReader.copyAsValue(mapWriter.integer(fieldName));
+          }
+          break;
+        case UINT1:
+          if (repeated) {
+            fieldReader.copyAsValue(mapWriter.list(fieldName).uInt1());
+          } else {
+            fieldReader.copyAsValue(mapWriter.uInt1(fieldName));
+          }
+          break;
+        case UINT2:
+          if (repeated) {
+            fieldReader.copyAsValue(mapWriter.list(fieldName).uInt2());
+          } else {
+            fieldReader.copyAsValue(mapWriter.uInt2(fieldName));
+          }
+          break;
+        case UINT4:
+          if (repeated) {
+            fieldReader.copyAsValue(mapWriter.list(fieldName).uInt4());
+          } else {
+            fieldReader.copyAsValue(mapWriter.uInt4(fieldName));
+          }
+          break;
+        case UINT8:
+          if (repeated) {
+            fieldReader.copyAsValue(mapWriter.list(fieldName).uInt8());
+          } else {
+            fieldReader.copyAsValue(mapWriter.uInt8(fieldName));
+          }
+          break;
+        case DECIMAL9:
+          if (repeated) {
+            fieldReader.copyAsValue(mapWriter.list(fieldName).decimal9());
+          } else {
+            fieldReader.copyAsValue(mapWriter.decimal9(fieldName));
+          }
+          break;
+        case DECIMAL18:
+          if (repeated) {
+            fieldReader.copyAsValue(mapWriter.list(fieldName).decimal18());
+          } else {
+            fieldReader.copyAsValue(mapWriter.decimal18(fieldName));
+          }
+          break;
+        case DECIMAL28SPARSE:
+          if (repeated) {
+            
fieldReader.copyAsValue(mapWriter.list(fieldName).decimal28Sparse());
+          } else {
+            fieldReader.copyAsValue(mapWriter.decimal28Sparse(fieldName));
+          }
+          break;
+        case DECIMAL38SPARSE:
 
 Review comment:
   Done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> ANY_VALUE aggregate function
> ----------------------------
>
>                 Key: DRILL-6375
>                 URL: https://issues.apache.org/jira/browse/DRILL-6375
>             Project: Apache Drill
>          Issue Type: New Feature
>          Components: Functions - Drill
>    Affects Versions: 1.13.0
>            Reporter: Gautam Kumar Parai
>            Assignee: Gautam Kumar Parai
>            Priority: Major
>             Fix For: 1.14.0
>
>
> We had discussions on the Apache Calcite [1] and Apache Drill [2] mailing 
> lists regarding an equivalent for DISTINCT ON. The community seems to prefer 
> the ANY_VALUE. This Jira is a placeholder for implementing the ANY_VALUE 
> aggregate function in Apache Drill. We should also eventually contribute it 
> to Apache Calcite.
> [1]https://lists.apache.org/thread.html/f2007a489d3a5741875bcc8a1edd8d5c3715e5114ac45058c3b3a42d@%3Cdev.calcite.apache.org%3E
> [2]https://lists.apache.org/thread.html/2517eef7410aed4e88b9515f7e4256335215c1ad39a2676a08d21cb9@%3Cdev.drill.apache.org%3E



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to