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

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

KazydubB commented on pull request #1974: DRILL-7574: Generalize the projection 
parser
URL: https://github.com/apache/drill/pull/1974#discussion_r377021700
 
 

 ##########
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/physical/resultSet/project/Qualifier.java
 ##########
 @@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.exec.physical.resultSet.project;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import 
org.apache.drill.exec.physical.resultSet.project.RequestedTuple.TupleProjectionType;
+
+/**
+ * Represents one level of qualifier for a column. Analogous to
+ * a {@code SchemaPath}, but represents the result of coalescing
+ * multiple occurrences of the same column.
+ */
+public class Qualifier implements QualifierContainer {
+  /**
+   * Marker to indicate that that a) the item is an
+   * array, and b) that all indexes are to be projected.
+   * Used when seeing both a and a[x].
+   */
+  private static final Set<Integer> ALL_INDEXES = new HashSet<>();
+
+  private Set<Integer> indexes;
+  private RequestedTuple members;
+  private Qualifier child;
+
+  @Override
+  public Qualifier qualifier() { return child; }
+
+  @Override
+  public Qualifier requireQualifier() {
+    if (child == null) {
+      child = new Qualifier();
+    }
+    return child;
+  }
+
+  public boolean isArray() {
+    return indexes != null;
+  }
+
+  public boolean hasIndexes() {
+    return isArray() && indexes != ALL_INDEXES;
+  }
+
+  public boolean hasIndex(int index) {
+    return hasIndexes() && indexes.contains(index);
+  }
+
+  public int maxIndex() {
+    if (! hasIndexes()) {
+      return 0;
 
 Review comment:
   Is it safe to have `0` instead of `-1`, for example? Does it imply that 
there's always `a[0]` selected? (I'm very likely getting this wrong.)
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Generalize projection parser
> ----------------------------
>
>                 Key: DRILL-7574
>                 URL: https://issues.apache.org/jira/browse/DRILL-7574
>             Project: Apache Drill
>          Issue Type: Improvement
>    Affects Versions: 1.17.0
>            Reporter: Paul Rogers
>            Assignee: Paul Rogers
>            Priority: Major
>             Fix For: 1.18.0
>
>
> EVF contains a bit of code called the"projection parser": it takes a 
> projection list and converts it into a form useful for scan projection. The 
> prior version handled single-level arrays, such as needed for the 
> {{`columns`}} column in the text reader. For JSON, we must handle arbitrary 
> column structures such as:
> {noformat}
> a, a.b, a[1], a[1][2], a.[1][2].b
> {noformat}
> Adding the DICT type means that we must be a bit more general in the parser. 
> This ticket fixes these issues.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to