tristaZero edited a comment on issue #8284:
URL: https://github.com/apache/shardingsphere/issues/8284#issuecomment-737131692


   My greetings for @junwen12221 @guimingyue .
   
   
   Based on the points @junwen12221 gave before, I write a 
[demo](https://github.com/tristaZero/federatedSQL) for this issue, i.e., SQL 
federation and SQL query optimization (**Looking forward to your collaborative 
effort**).
   
   In this demo, SQL federation using Calcite JDBC driver can work well. 
Nonetheless,  I also write a raw executor (As 3 mentioned above) with parsing, 
validating, optimizing and executing, which you can view as a custom executor 
driver. Supposing this custom executor driver has a run-through process, we can 
replace Calcite parser with our SQL parser and add more plan rules to 
`findBestExp`.   @guimingyue 's expectation, right?
   
   Unfortunately, this `CalciteRawExecutor` succeeded in parsing, validating, 
optimizing SQLs but is blocked in executing. :( 
   
   I tried any method I can, but failed, **so I sincerely seek your any kind 
help and point!** The exception info is presented later, also you can run 
`assertSingleExecute()` in `CalciteRawExecutorTest` to make it recurred.
   
   **The reason, I guess**, is related to [using the custom 
schema](https://github.com/tristaZero/federatedSQL/blob/ce71c8fa6e7b09e7d11dce660980c3a9922e1a97/src/main/java/federated/sql/executor/CalciteRawExecutor.java#L95)
 since it is different from [this example new 
ReflectiveSchema()](https://github.com/zabetak/calcite/blob/c7646fa6d3054b9e6b9a800e08d18f3cc89922e4/core/src/test/java/org/apache/calcite/examples/foodmart/java/EndToEndExampleEnumerable.java#L117).
 But I have no approaches to debug or figure out the corresponding solutions. 
   
   ```java
   15:01:08.019 [main] DEBUG org.apache.calcite.plan.RelOptPlanner - Provenance:
   
rel#19:EnumerableCalc.ENUMERABLE(input=EnumerableCalc#18,expr#0..2={inputs},0=$t0)
     direct
       
rel#17:EnumerableCalc.ENUMERABLE(input=RelSubset#16,expr#0..2={inputs},0=$t0)
         call#9 rule [EnumerableCalcRule(in:NONE,out:ENUMERABLE)]
           rel#14:LogicalCalc.NONE(input=RelSubset#6,expr#0..2={inputs},0=$t0)
             call#5 rule [ProjectToCalcRule]
               rel#7:LogicalProject.NONE(input=RelSubset#6,inputs=0)
                 no parent
   
rel#18:EnumerableCalc.ENUMERABLE(input=EnumerableTableScan#11,expr#0..2={inputs},expr#3=10,expr#4=<($t0,
 $t3),proj#0..2={exprs},$condition=$t4)
     direct
       
rel#15:EnumerableCalc.ENUMERABLE(input=RelSubset#12,expr#0..2={inputs},expr#3=10,expr#4=<($t0,
 $t3),proj#0..2={exprs},$condition=$t4)
         call#7 rule [EnumerableCalcRule(in:NONE,out:ENUMERABLE)]
           
rel#13:LogicalCalc.NONE(input=RelSubset#4,expr#0..2={inputs},expr#3=10,expr#4=<($t0,
 $t3),proj#0..2={exprs},$condition=$t4)
             call#3 rule [FilterToCalcRule]
               rel#5:LogicalFilter.NONE(input=RelSubset#4,condition=<($0, 10))
                 no parent
   rel#11:EnumerableTableScan.ENUMERABLE(table=[sharding, t_order])
     call#1 rule [EnumerableTableScanRule(in:NONE,out:ENUMERABLE)]
       rel#1:LogicalTableScan.NONE(table=[sharding, t_order])
         no parent
   
   
   java.lang.NullPointerException
        at Baz.bind(Unknown Source)
        at 
federated.sql.executor.CalciteRawExecutor.execute(CalciteRawExecutor.java:184)
        at 
federated.sql.executor.CalciteRawExecutor.execute(CalciteRawExecutor.java:173)
        at 
federated.sql.executor.CalciteRawExecutorTest.assertSingleExecute(CalciteRawExecutorTest.java:61)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
        at 
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
        at 
com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
        at 
com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
        at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
   ```
   


----------------------------------------------------------------
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]


Reply via email to