Background
Avatica is a framework for building JDBC and ODBC drivers for databases,and an RPC wire protocol.
Avatica’s Java binding has very few dependencies.Even though it is part of Apache Calcite it does not depend on other parts ofCalcite. It depends only on JDK 8+ and Jackson.
Avatica’s wire protocols are JSON or Protocol Buffers over HTTP. TheJava implementation of the JSON protocol usesJackson to convertrequest/response command objects to/from JSON.
Avatica-Server is a Java implementation of Avatica RPC.
Core concepts:
- Metais a local API sufficient to implement any Avatica provider
- AvaticaFactorycreates implementations of the JDBC classes on top of a
Meta
- Serviceis an interface that implements the functions of
Meta
in termsof request and response command objects
JDBC
Avatica implements JDBC by means ofAvaticaFactory.An implementation of AvaticaFactory
creates implementations of theJDBC classes (Driver,Connection,Statement,ResultSet)on top of a Meta
.
ODBC
Work has not started on Avatica ODBC.
Avatica ODBC would use the same wire protocol and could use the same serverimplementation in Java. The ODBC client would be written in C or C++.
Since the Avatica protocol abstracts many of the differences between providers,the same ODBC client could be used for different databases.
Although the Avatica project does not include an ODBC driver, thereare ODBC drivers written on top of the Avatica protocol, for examplean ODBC driver for Apache Phoenix.
HTTP Server
Avatica-server embeds the Jetty HTTP server, providing a classHttpServerthat implements the Avatica RPC protocoland can be run as a standalone Java application.
Connectors in HTTP server can be configured if needed by extendingHttpServer
class and overriding its configureConnector()
method.For example, user can set requestHeaderSize
to 64K bytes as follows:
HttpServer server = new HttpServer(handler) {
@Override
protected ServerConnector configureConnector(
ServerConnector connector, int port) {
HttpConnectionFactory factory = (HttpConnectionFactory)
connector.getDefaultConnectionFactory();
factory.getHttpConfiguration().setRequestHeaderSize(64 << 10);
return super.configureConnector(connector, port);
}
};
server.start();
Project structure
We know that it is important that client libraries have minimal dependencies.
Avatica is a sub-project of Apache Calcite,maintained in a separate repository.It does not depend upon any other part of Calcite.
Packages:
- org.apache.calcite.avatica Core framework
- org.apache.calcite.avatica.remote JDBC driver that uses remote procedure calls
- org.apache.calcite.avatica.server HTTP server
- org.apache.calcite.avatica.util Utilities
Status
Implemented
- Create connection, create statement, metadata, prepare, bind, execute, fetch
- RPC using JSON over HTTP
- Local implementation
- Implementation over an existing JDBC driver
- Composite RPCs (combining several requests into one round trip)
- Execute-Fetch
- Metadata-Fetch (metadata calls such as getTables return all rows)
Not implemented
- ODBC
- RPCs
- CloseStatement
- CloseConnection
- Composite RPCs
- CreateStatement-Prepare
- CloseStatement-CloseConnection
- Prepare-Execute-Fetch (Statement.executeQuery should fetch first N rows)
- Remove statements from statement table
- DML (INSERT, UPDATE, DELETE)
- Statement.execute applied to SELECT statement
Clients
The following is a list of available Avatica clients. Several describethemselves as adapters forApache Phoenix but also work with otherAvatica back-ends. Contributions for clients in other languages arehighly welcomed!
Microsoft .NET driver for Apache Phoenix Query Server
- Home page
- Language: C#
- License: Apache 2.0
- Avatica version 1.2.0 onwards
- Maintainer: Microsoft Azure
Apache Phoenix/Avatica SQL Driver
- Home page
- Language: Go
- License: Apache 2.0
- Avatica version 1.8.0 onwards
- Maintainer: Boostport and the Apache Calcite community
Avatica thin client
- Home page
- Language: Java
- License: Apache 2.0
- Any Avatica version
- Maintainer: Apache Calcite community
Apache Phoenix database adapter for Python
- Home page
- Language: Python
- License: Apache 2.0
- Avatica version 1.2.0 to 1.6.0
- Maintainer: Lukáš Lalinský