我试图通过jdbc转换器将postresql数据加载到geomesa(带有cassandra数据存储)。
从形状加载工作正常,所以Cassandra和geomesa设置是好的
接下来,我尝试从postgresql加载数据
命令:
echo“选择年份、geom、grondgebruik、作物代码、作物名称、fieldid、全局id、面积、周长、geohash from v|u Gewspercelen2018”| bin/geomesa cassandra ingest-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
有人知道这里怎么了吗?
2条答案
按热度按时间zphenhs41#
你可以在旅馆登记
logs
文件夹中查找更详细的错误。然而,乍一看,jdbc转换器遵循标准的结果集编号,这意味着第一个字段是$1
(不是$0
). 此外,可能需要使用变换函数变换几何体,即。geometry($2)
.oknwwptz2#
谢谢埃米利奥,两个建议都很有意义!
使转换器字段计数从1开始
转换器定义文件内部已更改
{name=“geom”,transform=“$2”}
进入
{name=“geom”,transform=“geometry($2)”}
sql select命令应为:
选择年份、标准文本(geom)。。。。来自vëu gewaspercelen2018
顺便说一下,用户名和密码是连接字符串的一部分(在geomesa.converters.parcel文件中):
连接=“dbc:postgresql://postgresserver:5432/agrodatacube?user=username&password=password"
因此-u和-p标志不会出现在最终命令中:
echo“选择年份,stèastext(geom),grondgebruik,作物代码,作物名称,fieldid,全局id,面积,周长,geohash from vèu Gewspercelen2018”| bin/geomesa cassandra ingest-c目录-p cassandraserver:9042 -k agrodatacube-f地块-c geomesa.converters.parcel
有了这些变化,它就可以工作了。
再次感谢!
雨果