You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Motivation

In our production, we create Flink Session Cluster and users can perform OLAP query in it. Users like to use Jdbc Driver in their applications to submit queries and get results. Currently we use the old flink-sql-gateway[1] and flink-jdbc-driver[2],  but when we try to upgrade our Flink Session Cluster, We meet compatibility problem. Flink Sql Gateway has been a submodule in Flink code base, and the API has been greatly optimized. The old Flink JDBC Driver cannot connect to the new Gateway directly which cause we cannot upgrade our Flink version. In this FLIP, I'd like to introduce Flink Jdbc Driver module in Flink to connect Gateway, users can use Jdbc Driver to submit their queries and get results like a database in their applications.

Proposal

Currently users can use Flink Sql Client to connect Sql Gateway as followed

SqlGateway starts Rest Service, and SqlClient can connect to it. Executor creates RestClient according to the address of Rest Service, then it can create Session, Submit Sql and Fetch Result according to RestClient.

We propose Flink Jdbc Driver interacts with SqlGateway through Executor too.

There are four main classes in Flink Jdbc Driver: FlinkDriver, FlinkConnection, FlinkStatement and FlinkResultSet which implement jdbc interface Driver, Connection, Statement and Result.

  1. FlinkDriver parses gateway address from url, and creates FlinkConnection
  2. FlinkConnection creates Executor according to gateway address. When the Connections is closed, it can close the connection with gateway by Executor
  3. FlinkStatement can get Executor from FlinkConnection, and submit sql query to it. After query is executed, FlinkStatement can get StatementResult from Executor, and create FlinkResultSet
  4. FlinkResultSet is an iterator, it gets results from StatementResult and return them to users

The call relationship between them are as followed.


[1] https://github.com/ververica/flink-sql-gateway

[2] https://github.com/ververica/flink-jdbc-driver

  • No labels