2

The following code snippet is taken from this blog post:

val sensorTable = ??? // can be a CSV file, Kafka topic, database, or ...

// register the table source
tEnv.registerTableSource("sensors", sensorTable)

I would like to read data from a relational database. Does Flink have a TableSource for JDBC databases?

1 Answer 1

5

In its current version (1.4.0, Dec. 2017), Flink does not provide a built-in TableSource to ingest data from a relational database.

However, there is a JDBCInputFormat that can be used. You can either

  • use it to read the data from the database using the DataSet API and register the DataSet as a Table or
  • implement a JdbcTableSource that wraps the JdbcInputFormat. A simple implementation of a JdbcTableSource should be easy to achieve. Implementing support for parallel reads, projection or filter push-down, requires more effort.
Sign up to request clarification or add additional context in comments.

2 Comments

Please share if any scala reference code for this . I am using Flink 1.3 version .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.