Hi,
DDL 是定义了元数据,首先你需要先在 Flink SQL 中用 DDL 定义你在 mysql 中的 student 表。比如
CREATE TABLE student (
id BIGINT,
score INT
) WITH (
'connector.type' = 'jdbc',
'connector.url' = 'jdbc:mysql://localhost:3306/flink-test',
'connector.table' = 'student',
...
)
然后,如果你想要查询数据,可以通过 Flink SQL query 来查询,如:
SELECT * from student WHERE score > 60
注:以上命令都可以在 Flink SQL CLI 中运行 [1]。
Best,
Jark
[1]:
https://ci.apache.org/projects/flink/flink-docs-release-1.10/dev/table/sqlClient.htmlOn Mon, 23 Mar 2020 at 16:30, 烟虫李彦卓 <
[hidden email]> wrote:
> hi,All请问,在blink planner的batch mode下,读取mysql数据,依照官网的JDBC Connector的操作:
> CREATE TABLE MyUserTable ( ... ) WITH ( 'connector.type' = 'jdbc', --
> required: specify this table type is jdbc 'connector.url' =
> 'jdbc:mysql://localhost:3306/flink-test', -- required: JDBC DB url
> 'connector.table' = 'jdbc_table_name', -- required: jdbc table name
> 'connector.driver' = 'com.mysql.jdbc.Driver', -- optional: the class name
> of the JDBC driver to use to connect to this URL.
> -- If not set, it will automatically be derived
> from the URL. 'connector.username' = 'name', -- optional: jdbc user name
> and password 'connector.password' = 'password',
> 'connector.write.flush.max-rows' = '5000'
>
>
> 我理解的是创建一个名字叫“ MyUserTable”的临时表,这个表是属于flink env的。但是从MySQL读取的sql(比如说“select
> * from student where score >
> 60")在哪儿能体现呢?看上面的用法好像是把全部的数据都取出来或者取多少条?这是让我困惑的地方,另外blink planner 的batch
> mode读取JDBC有别的方法吗?Thanks!