Julian,

I'm not familiar with the optiq inside but seems it has something to do
with your last projection's ref. What's the purpose of  getHolder()?

Maybe not the right thing to do, but the attached patch could produce
output without nesting(but throws exceptions in some test...).




On Tue, May 7, 2013 at 1:06 PM, Julian Hyde <[email protected]> wrote:

> Hi Drillers,
>
> I am having problems integrating the logical plan reference interpreter
> with the Optiq plans that I generate to implement SQL. Specifically with
> which "wrapper" elements I should expect to wrap the rows that come out of
> the reference interpreter.
>
> I'd appreciate if another Drill developer could run my code in a debugger
> and see whether I am generating the wrong logical plan, or interpreting its
> results wrongly, or whether the reference interpreter is broken. In other
> words, I'd like to borrow another pair of eyes. Any volunteers?
>
> Download the "optiq" branch from my github fork:
>
> $ git clone [email protected]:julianhyde/incubator-drill.git
> $ cd incubator-drill
> $ git checkout optiq
>
> Then run the "testCount" method of
> sandbox/prototype/sqlparser/src/test/java/org/apache/drill/jdbc/test/JdbcTest.java.
> It ought to return something like this:
>
> C=1; DEPTID=null
> C=2; DEPTID=34
> C=2; DEPTID=33
> C=1; DEPTID=31
>
> but actually returns this:
>
> C=1; DEPTID={DEPTID=null, LASTNAME=John}
> C=1; DEPTID={DEPTID=34, LASTNAME=Robinson}
> C=1; DEPTID={DEPTID=33, LASTNAME=Steinburg}
> C=1; DEPTID={DEPTID=31, LASTNAME=Rafferty}
> C=1; DEPTID={DEPTID=33, LASTNAME=Jones}
> C=1; DEPTID={DEPTID=34, LASTNAME=Smith}
>
> As you can see, the DEPTID column has an extra level of nesting. I print
> the logical plan to stdout, so see whether that makes sense.
>
> Julian
diff --git 
a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillOptiq.java
 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillOptiq.java
index 0a12fc3..a3d72c8 100644
--- 
a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillOptiq.java
+++ 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillOptiq.java
@@ -51,6 +51,9 @@ public class DrillOptiq {
     final RexToDrill visitor = new RexToDrill(inputName);
     expr.accept(visitor);
     String s = visitor.buf.toString();
+    if("".equals(s)){
+      s = "im";
+    }
     return s;
   }
 
diff --git 
a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillProjectRel.java
 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillProjectRel.java
index 33ffec7..a12adbf 100644
--- 
a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillProjectRel.java
+++ 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillProjectRel.java
@@ -49,7 +49,7 @@ public class DrillProjectRel extends ProjectRelBase 
implements DrillRel {
 
   @Override
   public String getHolder() {
-    return "xxx"; //projects().size() == 1 ? "xxx" : null;
+    return null; //projects().size() == 1 ? "xxx" : null;
   }
 
   @Override
@@ -87,7 +87,8 @@ public class DrillProjectRel extends ProjectRelBase 
implements DrillRel {
     }
     final String prefix = "output."
                           + (getHolder() == null ? "" : getHolder() + ".");
-    for (Pair<RexNode, String> pair : projects()) {
+    List<Pair<RexNode, String>> ps = projects();
+    for (Pair<RexNode, String> pair : ps) {
       final ObjectNode objectNode = implementor.mapper.createObjectNode();
       transforms.add(objectNode);
       String expr = DrillOptiq.toDrill(pair.left, childHolder);
diff --git 
a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillScan.java
 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillScan.java
index 966e485..f36aee0 100644
--- 
a/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillScan.java
+++ 
b/sandbox/prototype/sqlparser/src/main/java/org/apache/drill/optiq/DrillScan.java
@@ -36,7 +36,7 @@ public class DrillScan extends TableAccessRelBase implements 
DrillRel {
   }
 
   public String getHolder() {
-    return holder;
+    return null;
   }
 
   public void implement(DrillImplementor implementor) {

Reply via email to