You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Kuldeep Bora <ku...@gmail.com> on 2015/01/15 08:02:29 UTC

Implementing ODBC Drivers

Hello,

Is it possible to enable ODBC support using Calcite currently? Quick google
search shows that Avatica a subproject of calcite can be used to do that.

Could you please point me to an existing implementation or examples?

Thanks

Re: Implementing ODBC Drivers

Posted by "Han, Luke" <lu...@ebay.com>.
Kylin has one ODBC implementation based on REST Service and Calcite. The
odbc driver now works with Tableau well.
Source code : https://github.com/KylinOLAP/odbc-driver

It could be your reference also.

Thanks
Luke

On 1/16/15, 2:07 AM, "Ted Dunning" <te...@gmail.com> wrote:

>Drill uses ODBC and Calcite.  That might or might not be what you want.
>
>
>
>On Wed, Jan 14, 2015 at 11:02 PM, Kuldeep Bora <ku...@gmail.com>
>wrote:
>
>> Hello,
>>
>> Is it possible to enable ODBC support using Calcite currently? Quick
>>google
>> search shows that Avatica a subproject of calcite can be used to do
>>that.
>>
>> Could you please point me to an existing implementation or examples?
>>
>> Thanks
>>


Re: Implementing ODBC Drivers

Posted by Ted Dunning <te...@gmail.com>.
Drill uses ODBC and Calcite.  That might or might not be what you want.



On Wed, Jan 14, 2015 at 11:02 PM, Kuldeep Bora <ku...@gmail.com>
wrote:

> Hello,
>
> Is it possible to enable ODBC support using Calcite currently? Quick google
> search shows that Avatica a subproject of calcite can be used to do that.
>
> Could you please point me to an existing implementation or examples?
>
> Thanks
>

Re: Implementing ODBC Drivers

Posted by "Hartman, Trevor" <th...@ebay.com>.
Ah, I just realized my local git repo was out-of-date!

Re: Implementing ODBC Drivers

Posted by "Hartman, Trevor" <th...@ebay.com>.
Thanks, Jay. Very helpful!

Trevor


On January 19, 2015 at 11:40:57 PM, Jiunn Jye Ng (jiunnjye@gmail.com<ma...@gmail.com>) wrote:

Hi,

I happened to be playing with the this. Sharing some information I have so
far.

For the architecture view of the avatica server implementation, found this
diagram
=>
https://raw.githubusercontent.com/julianhyde/share/master/slides/avatica-architecture.png

1) The JSON is how the remote communicate talk to server. The
implementation is in org.apache.calcite.avatica.remote.RemoteService.java.

2) I haven't try with this url jdbc:avatica:remote:factory=...

3) The ConnectionFactory is where the jdbc connection is being created on
the server side.

On not able to access CalciteConnectionImpl,
you can resolve that by having your implementation of ConnectionFactory in
org.apache.calcite.jdbc package.

Below are my working project in scala based on csv example

A) CsvConnectionFactory.scala
---------------------------------------------------------------------------------------------
package org.apache.calcite.jdbc
import org.apache.calcite.avatica.Meta.Factory
import java.sql.DriverManager
class CsvConnectionFactory extends Factory {
def create(x$1: java.util.List[String]): org.apache.calcite.avatica.Meta
= {
val connection = DriverManager.getConnection(
"jdbc:calcite:model=/model.json",
"admin", "admin");
return new
CalciteMetaImpl(connection.asInstanceOf[CalciteConnectionImpl])
}
}
---------------------------------------------------------------------------------------------

B) To start csv example as Server
run org.apache.calcite.avatica.server.Main with argument
"org.apache.calcite.jdbc.CsvConnectionFactory"



C) JDBC Client Code for connecting
---------------------------------------------------------------------------------------------
package org.apache.calcite.jdbc

import java.sql.Connection
import java.sql.DriverManager

object HelloWorld {
def main(args: Array[String]) {
val port = 8765
val connection: Connection =
DriverManager.getConnection("jdbc:avatica:remote:url=http://localhost:" +
port)
val rs = connection.createStatement().executeQuery("select * from
EMPS")
while (rs.next){
println(rs.getString("NAME"))
}
}
}
---------------------------------------------------------------------------------------------

Hope this help.

Rgds,
jay


On Tue, Jan 20, 2015 at 5:34 AM, Hartman, Trevor <th...@ebay.com> wrote:

> Running on latest sources now. My questions still remain. Also, I tried
> implementing a Meta.Factory based on CalciteRemoteDriverTest.Factory, but
> org.apache.calcite.jdbc.CalciteConnectionImpl is not accessible. How do I
> provide an instance of Meta?
>
> Thanks,
> Trevor
>

Re: Implementing ODBC Drivers

Posted by Jiunn Jye Ng <ji...@gmail.com>.
Hi,

I happened to be playing with the this. Sharing some information I have so
far.

For the architecture view of the avatica server implementation, found this
diagram
=>
https://raw.githubusercontent.com/julianhyde/share/master/slides/avatica-architecture.png

1) The JSON is how the remote communicate talk to server. The
implementation is in org.apache.calcite.avatica.remote.RemoteService.java.

2) I haven't try with this url jdbc:avatica:remote:factory=...

3) The ConnectionFactory is where the jdbc connection is being created on
the server side.

On not able to access CalciteConnectionImpl,
you can resolve that by having your implementation of ConnectionFactory in
org.apache.calcite.jdbc package.

Below are my working project in scala based on csv example

A) CsvConnectionFactory.scala
---------------------------------------------------------------------------------------------
package org.apache.calcite.jdbc
import org.apache.calcite.avatica.Meta.Factory
import java.sql.DriverManager
class CsvConnectionFactory extends Factory {
  def create(x$1: java.util.List[String]): org.apache.calcite.avatica.Meta
= {
     val connection = DriverManager.getConnection(
"jdbc:calcite:model=/model.json",
"admin", "admin");
      return new
CalciteMetaImpl(connection.asInstanceOf[CalciteConnectionImpl])
  }
}
---------------------------------------------------------------------------------------------

B) To start csv example as Server
run org.apache.calcite.avatica.server.Main with argument
"org.apache.calcite.jdbc.CsvConnectionFactory"



C) JDBC Client Code for connecting
---------------------------------------------------------------------------------------------
package org.apache.calcite.jdbc

import java.sql.Connection
import java.sql.DriverManager

object HelloWorld {
  def main(args: Array[String]) {
    val port = 8765
    val connection: Connection  =
DriverManager.getConnection("jdbc:avatica:remote:url=http://localhost:" +
port)
    val rs = connection.createStatement().executeQuery("select * from
EMPS")
    while (rs.next){
      println(rs.getString("NAME"))
    }
  }
}
---------------------------------------------------------------------------------------------

Hope this help.

Rgds,
jay


On Tue, Jan 20, 2015 at 5:34 AM, Hartman, Trevor <th...@ebay.com> wrote:

> Running on latest sources now. My questions still remain. Also, I tried
> implementing a Meta.Factory based on CalciteRemoteDriverTest.Factory, but
> org.apache.calcite.jdbc.CalciteConnectionImpl is not accessible. How do I
> provide an instance of Meta?
>
> Thanks,
> Trevor
>

Re: Implementing ODBC Drivers

Posted by "Hartman, Trevor" <th...@ebay.com>.
Running on latest sources now. My questions still remain. Also, I tried implementing a Meta.Factory based on CalciteRemoteDriverTest.Factory, but org.apache.calcite.jdbc.CalciteConnectionImpl is not accessible. How do I provide an instance of Meta?

Thanks,
Trevor

Re: Implementing ODBC Drivers

Posted by "Hartman, Trevor" <th...@ebay.com>.
I was referring to this line:
https://github.com/apache/incubator-calcite/blob/master/core/src/test/java/org/apache/calcite/jdbc/CalciteRemoteDriverTest.java#L185

Re: Implementing ODBC Drivers

Posted by Vladimir Sitnikov <si...@gmail.com>.
> It seems to pull a connection out of thin air (final Connection connection = CalciteAssert.that().connect();).

It should not.
Can you please pin-point the location of "that().connect()" ?
I see ".hr().connect()", however it is not a thin air.

Vladimir

Re: Implementing ODBC Drivers

Posted by "Hartman, Trevor" <th...@ebay.com>.
Sorry to hijack this thread. I'm having a hard time understanding the individual components with the testing dsl handling so much. A few specific questions:
And HttpServer is a standalone program that uses jetty to listen on a port for JSON requests
1. What role does JSON have in a JDBC server, or is that for something else?
2. I noticed the factory= in the connection string. Is that preferred over the model= param in sqlline examples, e.g. ("jdbc:calcite:model=target/test-classes/model.json")?
3. Assuming factory is the way forward, how do I implement a Meta.Factory without the CalciteAssert testing infrastructure? It seems to pull a connection out of thin air (final Connection connection = CalciteAssert.that().connect();).

Thanks!

Trevor

Re: Implementing ODBC Drivers

Posted by Julian Hyde <ju...@gmail.com>.
Haven't gotten around to writing documentation yet. But you can glean a lot from the commit [ https://github.com/apache/incubator-calcite/commit/94752a6066cd8a379782510a78a885cffb5aadb9 ]. For instance, CalciteRemoteDriverTest has tests that connect to a remote server (albeit running in the same JVM, for testing purposes). And HttpServer is a standalone program that uses jetty to listen on a port for JSON requests.

Julian


> On Jan 15, 2015, at 2:50 PM, Hartman, Trevor <th...@ebay.com> wrote:
> 
> Does this mean I can use Avatica to accept jdbc connections and run queries? If so, are there any docs or examples yet?
> 
> Trevor


Re: Implementing ODBC Drivers

Posted by "Hartman, Trevor" <th...@ebay.com>.
There is now an RPC server based on JSON over HTTP (and we would consider other protocols) and a remote JDBC driver.
Does this mean I can use Avatica to accept jdbc connections and run queries? If so, are there any docs or examples yet?

Trevor

Re: Implementing ODBC Drivers

Posted by Julian Hyde <ju...@gmail.com>.
We've made some progress on Avatica. There is now an RPC server based on JSON over HTTP (and we would consider other protocols) and a remote JDBC driver. But we haven't gotten to ODBC yet.

There aren't many portable open source ODBC drivers, and building/maintaining one is a lot of work. I'm considering joining forces with Kylin, who have such a driver.

Julian


> On Jan 14, 2015, at 11:02 PM, Kuldeep Bora <ku...@gmail.com> wrote:
> 
> Hello,
> 
> Is it possible to enable ODBC support using Calcite currently? Quick google
> search shows that Avatica a subproject of calcite can be used to do that.
> 
> Could you please point me to an existing implementation or examples?
> 
> Thanks