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

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

amansinha100 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_r189022846
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/DrillFuncHolder.java
 ##########
 @@ -186,12 +191,35 @@ protected void addProtectedBlock(ClassGenerator<?> g, 
JBlock sub, String body, H
 
         ValueReference parameter = attributes.getParameters()[i];
         HoldingContainer inputVariable = inputVariables[i];
-        if (parameter.isFieldReader() && ! inputVariable.isReader() && ! 
Types.isComplex(inputVariable.getMajorType()) && inputVariable.getMinorType() 
!= MinorType.UNION) {
+        if (parameter.isFieldReader() && ! inputVariable.isReader()
+            && ! Types.isComplex(inputVariable.getMajorType()) && 
inputVariable.getMinorType() != MinorType.UNION) {
           JType singularReaderClass = 
g.getModel()._ref(TypeHelper.getHolderReaderImpl(inputVariable.getMajorType().getMinorType(),
               inputVariable.getMajorType().getMode()));
           JType fieldReadClass = g.getModel()._ref(FieldReader.class);
           sub.decl(fieldReadClass, parameter.getName(), 
JExpr._new(singularReaderClass).arg(inputVariable.getHolder()));
-        } else {
+        } else if (!parameter.isFieldReader() && inputVariable.isReader() && 
Types.isComplex(parameter.getType())) {
+          // For complex data-types (repeated maps/lists) the input to the 
aggregate will be a FieldReader. However, aggregate
+          // functions like ANY_VALUE, will assume the input to be a 
RepeatedMapHolder etc. Generate boilerplate code, to map
+          // from FieldReader to respective Holder.
+          if (parameter.getType().getMinorType() == MinorType.MAP) {
+            JType holderClass;
+            if (parameter.getType().getMode() == TypeProtos.DataMode.REPEATED) 
{
+              holderClass = g.getModel()._ref(RepeatedMapHolder.class);
+              JVar holderVar = sub.decl(holderClass, parameter.getName(), 
JExpr._new(holderClass));
+              sub.assign(holderVar.ref("reader"), inputVariable.getHolder());
+            } else {
+              holderClass = g.getModel()._ref(MapHolder.class);
+              JVar holderVar = sub.decl(holderClass, parameter.getName(), 
JExpr._new(holderClass));
+              sub.assign(holderVar.ref("reader"), inputVariable.getHolder());
+            }
+          } else if (parameter.getType().getMinorType() == MinorType.LIST) {
+            //TODO: Add support for REPEATED LISTs
 
 Review comment:
   I am guessing this TODO is because Drill has some limitations in handling 
lists of type [ [1, 2, 3], [4, 5, 6] ] and not as much about the limitations of 
ANY_VALUE itself ?  

----------------------------------------------------------------
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:
[email protected]


> 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