Flink SQL 数据类型
Flink JDBC Driver | Apache Flink https://nightlies.apache.org/flink/flink-docs-master/docs/dev/table/jdbcdriver/
Sample.java
public class Sample {
public static void main(String[] args) throws Exception {
try (Connection connection = DriverManager.getConnection("jdbc:flink://localhost:8083")) {
try (Statement statement = connection.createStatement()) {
statement.execute("CREATE TABLE T(\n" +
" a INT,\n" +
" b VARCHAR(10)\n" +
") WITH (\n" +
" 'connector' = 'filesystem',\n" +
" 'path' = 'file:///tmp/T.csv',\n" +
" 'format' = 'csv'\n" +
")");
statement.execute("INSERT INTO T VALUES (1, 'Hi'), (2, 'Hello')");
try (ResultSet rs = statement.executeQuery("SELECT * FROM T")) {
while (rs.next()) {
System.out.println(rs.getInt(1) + ", " + rs.getString(2));
}
}
}
}
}
}
Output
1, Hi
2, Hello
Besides DriverManager
, Flink JDBC driver supports DataSource
and you can also create connection from it.
Flink SQL 为用户提供了一系列丰富的原始数据类型。
数据类型 | Apache Flink https://nightlies.apache.org/flink/flink-docs-master/zh/docs/dev/table/types/