【问题标题】:NIFI Insert CSV File into Postgres Database with date fieldsNIFI 使用日期字段将 CSV 文件插入 Postgres 数据库
【发布时间】:2019-11-08 13:31:20
【问题描述】:

我想将 csv 文件插入我的 postgres 数据库。我使用处理器:

Getfiles -> 
Split (cause files are big) ->
UpdateAttribute (to add avro.schema) ->
ConvertCSvToAvro ->
Putdatabaserecord.

如果我只使用字符串/文本字段(在我的 avro 模式和列 postgres 数据库中),结果是可以的。 但是当我尝试格式化日期字段时,我遇到了错误。

我的原始数据(CSV)是:

date_export|num_etiquette|key
07/11/2019 01:36:00|BAROMETRExxxxx|BAROMETRE-xxxxx

我的 avro 架构是:

{
"type":"record",
"name":"public.data_scope_gp_temp",
"fields":[
{"name":"date_export","type":{ "type": "int", "logicalType": "date"}},
{"name":"num_etiquette","type":"string"},
{"name":"cle_scope","type":"string"}
]}

我的 postgres 架构是:

date_export date,
num_etiquette text COLLATE pg_catalog."default",
key text COLLATE pg_catalog."default"

任何想法?问候

【问题讨论】:

    标签: postgresql csv apache-nifi avro


    【解决方案1】:

    您不需要 UpdateAttribute 或 ConvertCsvToAvro 即可使用 PutDatabaseRecord。您可以在 PutDatabaseRecord 中指定一个 CSVReader,并且您的 CSVReader 可以在 Schema Text 属性中提供 Avro 架构(不要忘记将您的架构策略设置为使用架构文本)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-12
      • 2011-08-08
      • 1970-01-01
      • 1970-01-01
      • 2022-11-29
      相关资源
      最近更新 更多