Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A Question About Import CSV to OrientDB #340

Open
ASXHOLE opened this issue Nov 21, 2018 · 1 comment
Open

A Question About Import CSV to OrientDB #340

ASXHOLE opened this issue Nov 21, 2018 · 1 comment

Comments

@ASXHOLE
Copy link

ASXHOLE commented Nov 21, 2018

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
Copy link
Author

ASXHOLE commented Nov 22, 2018

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}') "
}
}
],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant