【发布时间】:2018-11-05 03:18:02
【问题描述】:
我使用 flink 1.6,我知道我可以使用自定义 sink 和 hive jdbc 写入 hive,或者使用 JDBCAppendTableSink,但它仍然使用 jdbc。问题是 hive jdbc 不支持 batchExecute 方法。我认为它会是很慢。
然后我想办法,我用writeAsText方法将DataSet写入hdfs,然后从hdfs创建hive表。但是还有一个问题:如何追加增量数据。 WriteMode的api是:
Enum FileSystem.WriteMode
Enum Constant and Description
NO_OVERWRITE
Creates the target file only if no file exists at that path already.
OVERWRITE
Creates a new target file regardless of any existing files or directories.
例如,第一批,我将 9 月的数据写入 hive,然后我得到 10 月的数据,我想追加它。
但是如果我在同一个hdfs文件中使用OVERWRITE,9月份的数据将不再存在,如果我使用NO_OVERWRITE,我必须将它写入一个新的hdfs文件,然后一个新的hive表,我们需要它们在同一个配置单元表中。我不知道如何将 2 个 hdfs 文件组合到一个配置单元表中。
那么如何使用flink将增量数据写入hive呢?
【问题讨论】:
标签: hadoop hive apache-flink