我试图通过JDBC转换器将Postresql数据加载到Geomesa(带有Cassandra数据存储)中。
从形状加载效果很好,因此可以进行Cassandra和GeoMesa设置
接下来,我尝试从PostgreSQL加载数据
命令:
回显“选择年份,geom,grondgebruik,crop_code,crop_name,fieldid,global_id,区域,周长,geohash来自v_gewaspercelen2018” | bin / geomesa-cassandra摄取-c目录-P cassandraserver:9042 -k agrodatacube -f包裹-C geomesa.converters.parcel -u -p
转换器定义文件 geomesa.converters.parcel 如下所示:
geomesa.converters.parcel = {
type = "jdbc"
connection = "dbc:postgresql://postgresserver:5432/agrodatacube"
id-field="toString($5)"
fields = [
{ name = "fieldid", transform = "$5" }
{ name = "global_id", transform = "$6" }
{ name = "year", transform = "$0" }
{ name = "area", transform = "$7" }
{ name = "perimeter", transform = "$8" }
{ name = "grondgebruik", transform = "$2" }
{ name = "crop_code", transform = "$3" }
{ name = "crop_name", transform = "$4" }
{ name = "geohash", transform = "$9" }
{ name = "geom", transform = "$1" }
]
}
geomesa输出为:
INFO Schema 'parcel' exists
INFO Running ingestion in local mode
INFO Ingesting from stdin with 1 thread
[ ] 0% complete 0 i[ ] 0% complete 0 ingested 0 failed in 00:00:01
ERROR Fatal error running local ingest worker on <stdin>
[ ] 0% complete 0 i[ ] 0% complete 0 ingested 0 failed in 00:00:01
INFO Local ingestion complete in 00:00:01
INFO Ingested 0 features with no failures for file: <stdin>
WARN Some files caused errors, ingest counts may not be accurate
有人知道这里出了什么问题吗?
答案 0 :(得分:2)
您可以在logs
文件夹中查看更多详细的错误。但是,乍一看,JDBC转换器跟随standard result set numbering,这意味着第一个字段是$1
(不是$0
)。另外,您可能需要使用转换功能,即geometry($2)
来转换几何。
答案 1 :(得分:0)
感谢Emilio,这两个建议都已提出!
{name =“ geom”,transform =“ $ 2”}
进入
{name =“ geom”,transform =“ geometry($ 2)”}
SELECT年, ST_AsText(geom),...。来自v_gewaspercelen2018
顺便说一句,用户名和密码是连接字符串的一部分(位于文件geomesa.converters.parcel中):
连接= “ dbc:postgresql:// postgresserver:5432 / agrodatacube?user = username&password = password”
因此-u和-p标志不会出现在最终命令中:
回显“ SELECT年,ST_AsText(geom),grondgebruik,crop_code, crop_name,fieldid,global_id,区域,周长,geohash FROM v_gewaspercelen2018” | bin / geomesa-cassandra摄取-c目录-P cassandraserver:9042 -k agrodatacube -f包裹-C geomesa.converters.parcel
通过这些更改,它可以工作。
再次感谢!
雨果