orientechnologies / orientdb-docs

Repository of the entire OrientDB documentation.
Apache License 2.0
57 stars 167 forks source link

A Question About Import CSV to OrientDB #340

Open ASXHOLE opened 5 years ago

ASXHOLE commented 5 years ago

Hi. Currently,i have imported some Vertex into OrientDB .The Class of this Vertex is Con and Org . Con has one property:CON_NO Org has one property:ORG_ID Now,i want to create the Edge between Con and Org by importing CSV file: "CON_NO","ORG_ID" "0320003598025860","33401300120" "063401216000900","33401300151" "0320009900472364","334013001" "065859001565252","334013001" "063493094536700","33401300151" "063465260717100","33401300130"

I built a Json file like this: { "source": { "file": { "path": "/home/Tag_data/bdatag_tag_result.csv" } }, "extractor": { "csv": {"columns":["CON_NO","ORG_ID"]} }, "transformers": [ { "vertex": { "class": "Org" } }, { "edge": { "class": "Consume_in", "joinFieldName": "CON_NO", "lookup": "Con.CON_NO", "direction": "in", "targetVertexFields": { "ORG_ID": "ORG_ID" } } } ], "loader": { "orientdb": { "dbURL": "plocal:/home/orientdb/databases/tagdb", "dbType": "graph", "classes": [ {"name": "Org", "extends": "V"}, {"name": "Con", "extends": "V"}, {"name": "Consume_in", "extends": "E"} ], "indexes": [ {"class":"Org", "fields":["ORG_ID:String"], "type":"UNIQUE" } ] } } }

but it failed when running OETL.sh “ 2018-11-20 22:38:28:995 SEVER {db=tagdb} Error in Pipeline execution: java.lang.NumberFormatException: For input string: "33401300120" [OETLPipeline] ” So ,How should i modify my file?


目前我已经在OrientDB中通过CSV导入了2种Vertex节点,对应的Class分别为,Con有和Org.分别含有CON_NO和ORG_IG两个属性。 现在我想通过导入CSV建立Con和Org节点的Edge边,Org与Con的关系为一对多的关系,CSV部分内容如下: "CON_NO","ORG_ID" "0320003598025860","33401300120" "063401216000900","33401300151" "0320009900472364","334013001" "065859001565252","334013001" "063493094536700","33401300151" "063465260717100","33401300130" 我的OrientDB ETL 的Json文件如下,但是在运行OETL.sh的时候出错了 { "source": { "file": { "path": "/home/Tag_data/bdatag_tag_result.csv" } }, "extractor": { "csv": {"columns":["CON_NO","ORG_ID"]} }, "transformers": [ { "vertex": { "class": "Org" } }, { "edge": { "class": "Consume_in", "joinFieldName": "CON_NO", "lookup": "Con.CON_NO", "direction": "in", "targetVertexFields": { "ORG_ID": "ORG_ID" } } } ], "loader": { "orientdb": { "dbURL": "plocal:/home/orientdb/databases/tagdb", "dbType": "graph", "classes": [ {"name": "Org", "extends": "V"}, {"name": "Con", "extends": "V"}, {"name": "Consume_in", "extends": "E"} ], "indexes": [ {"class":"Org", "fields":["ORG_ID:String"], "type":"UNIQUE" } ] } } } 出错信息如下: 2018-11-20 22:38:28:995 SEVER {db=tagdb} Error in Pipeline execution: java.lang.NumberFormatException: For input string: "33401300120" [OETLPipeline]

我应该如何修改我的Json文件呢?

ASXHOLE commented 5 years ago

I have solved this problem by using COMMAND in transformers.

"transformers": [ {"command": { "command": "create edge Consume_in from (select from Con where CON_NO = '${input.CON_NO}') to (select from Org where ORG_ID = '${input.ORG_ID}') " } } ],