By the way, credit where it is due - most of the work on the HTTP adapter was by Henry Olson in the optiq-web project [1]. I have simply upgraded it for recent Calcite.
Julian [1] https://github.com/HenryOlson/optiq-web On Mon, Feb 20, 2017 at 5:40 PM, Julian Hyde <[email protected]> wrote: > Can you log a JIRA case for the REST adapter, and post your work as a > pull request? Then I will take a look and try to debug it. > > I have been interested for some time in creating a REST adapter. I > think it should be an evolution of the CSV adapter to work over other > file formats and via protocols such as HTTP in addition to files. I > have been working on https://issues.apache.org/jira/browse/CALCITE-884 > for some time, and my work in progress [ > https://github.com/julianhyde/calcite/tree/884-file-adapter ] almost > passes all tests. It might be worth basing your adapter on that. > > Julian > > On Sun, Feb 19, 2017 at 7:55 PM, ravi katkar <[email protected]> wrote: >> Hi, >> >> I am trying to write adapter for rest data source, where I have a >> requirement to fetch where clause filters and selected column as query >> parameters to rest resources. >> >> I have gone through adapters examples like web adapter, CSV adapter. >> >> >> >> I have created a table which implements TranslatableTable, FilterableTable >> >> >> >> >> >> *public class REST*TranslatableTable *extends REST*Table >> >> *implements *TranslatableTable, FilterableTable {… >> >> >> >> in scan method I could able to read the filters in where clause >> >> >> >> and >> >> >> >> *public class REST*TableScan *extends *TableScan *implements *EnumerableRel { >> >> >> >> in project method I could able to fetch fields used in the query >> >> *public *RelNode project(ImmutableBitSet fieldsUsed, >> >> Set<RelDataTypeField> extraFields, >> >> RelBuilder relBuilder) { >> >> >> >> *but when I have query without where clause * >> >> *eg: select col1, col2 from table1 *implement method is throwing error. >> >> >> >> I have tried similar approach in CSV adapter , I got same error, I think >> >> *public *Result implement(EnumerableRelImplementor implementor, Prefer >> pref) has to improved , any ideas how to proceed on this blocking >> issue >> >> >> >> >> >> implement method is throwing error. >> >> >> >> java.sql.SQLException: Error while executing SQL "select empno, >> slacker from emps ": while resolving method 'project' in class >> org.apache.calcite.linq4j.Enumerable<java.lang.Object[]> >> >> >> >> at >> org.apache.calcite.avatica.Helper.createException(Helper.java:56) >> >> at >> org.apache.calcite.avatica.Helper.createException(Helper.java:41) >> >> at >> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156) >> >> at >> org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218) >> >> at org.apache.calcite.test.CsvTest.checkSql(CsvTest.java:321) >> >> at org.apache.calcite.test.CsvTest.checkSql(CsvTest.java:291) >> >> at org.apache.calcite.test.CsvTest.testBoolean(CsvTest.java:394) >> >> 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.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:69) >> >> at >> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234) >> >> at >> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74) >> >> Caused by: java.lang.RuntimeException: while resolving method >> 'project' in class >> org.apache.calcite.linq4j.Enumerable<java.lang.Object[]> >> >> at >> org.apache.calcite.linq4j.tree.Expressions.call(Expressions.java:421) >> >> at >> org.apache.calcite.linq4j.tree.Expressions.call(Expressions.java:432) >> >> at >> org.apache.calcite.adapter.csv.CsvTableScan.implement(CsvTableScan.java:100) >> >> at >> org.apache.calcite.adapter.enumerable.EnumerableRelImplementor.implementRoot(EnumerableRelImplementor.java:102) >> >> at >> org.apache.calcite.adapter.enumerable.EnumerableInterpretable.toBindable(EnumerableInterpretable.java:92) >> >> at >> org.apache.calcite.prepare.CalcitePrepareImpl$CalcitePreparingStmt.implement(CalcitePrepareImpl.java:1202) >> >> at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:298) >> >> at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:195) >> >> at >> org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:735) >> >> at >> org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:598) >> >> at >> org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:568) >> >> at >> org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:215) >> >> at >> org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:594) >> >> at >> org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:615) >> >> at >> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:148) >> >> ... 25 more >> >> Caused by: java.lang.NoSuchMethodException: >> org.apache.calcite.linq4j.Enumerable.project(org.apache.calcite.DataContext, >> [I) >> >> at java.lang.Class.getMethod(Class.java:1786) >> >> at >> org.apache.calcite.linq4j.tree.Expressions.call(Expressions.java:418) >> >> ... 39 more >> >> >> >> >> >> >> >> Thanks, >> >> Ravi katkar
