通用格式
在nodeConfig
、edgeConfig
下配置schema和/或CSV文件夹路径:
nodeConfig:
# 配置一个点schema
# Schema名
- schema:
# (仅mysql/postgresSQL/sqlserver/bigQuery,必填)查询字段的sql语句
sql:
# (仅neo4j,必填)Neo4j数据的label名
label:
# (仅neo4j,选填)使用变量n对该label下的数据进行过滤,如:n.released > 1999;默认不进行过滤
where:
# (仅kafka,必填)Kafka主题名
topic:
# (仅kafka,选填)Kafka消息偏移,格式支持newest、oldest、5、2006-01-02 15:04:05 -0700、2006-01-02 15:04:05;默认为oldest
offset:
# (仅csv/json/jsonl,必填)数据文件路径
file:
# (仅csv,选填)CSV文件是否包含表头;默认为true
head:
# (所有数据源,选填)手动配置字段
properties:
# (所有数据源,选填)从开头需要跳过(即不导入)的数据条数
skip:
# (所有数据源,选填)需要导入的数据条数
limit:
# 配置更多点schema
- schema:
...
# (仅csv文件夹,必填)配置一个点文件夹,其中文件命名规则为<schema>.node.csv,有表头有类型(不支持修改)
# 文件夹路径
- dir:
# 配置更多点文件夹
- dir:
edgeConfig:
# 配置一个边schema
- schema:
...
# 配置更多边schema
- schema:
...
# (仅csv文件夹,必填)配置一个边文件夹,其中文件命名规则为<schema>.edge.csv,有表头有类型(不支持修改)
- dir:
# 配置更多边文件夹
- dir:
properties配置详解
nodeConfig:
- schema:
...
properties:
# 配置一个字段
# 字段名
- name:
# (选填) 配置或修改字段类型
type:
# (选填) 修改字段名
new_name:
# (选填) 附加前缀,仅对_id、_from或_to生效
prefix:
# 配置更多字段
- name:
type:
new_name:
prefix:
skip:
limit:
...
按照是否携带字段名、字段类型将数据源进行分类:
- 无字段名:无表头CSV
- 有字段名:
- 无类型:有表头无类型CSV,JSON,JSONL
- 有类型:有表头有类型CSV,MySQL,PostgreSQL,SQLServer,BigQuery,Neo4j,Kafka
配置properties
的目的是(1)对未携带的字段名、字段类型进行配置,(2)对携带的字段名、字段类型进行修改,(3)给字段值附加前缀。
字段名有效值:
- 合法的字段名请参考属性命名规则
字段类型有效值:
- 系统属性类型:
_id
,_uuid
,_from
,_to
,_from_uuid
,_to_uuid
- 自定义属性类型请参考属性支持的数据类型
- 需要舍弃的字段类型:
_ignore
可以附加前缀的有效类型:_id
,_from
,_to
示例:配置字段名、字段类型
为无表头的CSV文件配置字段名和字段类型时,-name
顺序需与列保持一致。例如:
A2CMX45JPSCTUJ,5,The Best Cable
A3EIML9QZO5NZZ,5,awesome
A3C9F3SZWLWDZF,2,worse than previous one
A1C60KQ8VJZBS5,4,Makes changing strings a breeze
properties:
- name: any # 字段为系统属性时,字段名- name可以随意配置,但不得与其他字段名重复
type: _id
- name: rating
type: _ignore # 字段为_ingore类型时,将不被导入
- name: comment
# 省略type时字段将默认为string类型
当无表头CSV文件配置的
- name
数量少于字段数量时,默认将报错;也可通过设置全局参数fitToHeader忽略末尾几个未进行配置的字段。
为有表头无类型CSV文件配置字段类型时,-name
顺序无需与列保持一致。例如:
_id,rating,comment
A2CMX45JPSCTUJ,5,The Best Cable
A3EIML9QZO5NZZ,5,awesome
A3C9F3SZWLWDZF,2,worse than previous one
A1C60KQ8VJZBS5,4,Makes changing strings a breeze
properties:
- name: rating
type: int32
- name: _id
type: _id
# 对于字段comment:省略配置type或省略配置该字段时,该字段将默认为string类型
为JSON、JSONL文件配置字段类型时,省略type
和省略- name
的处理逻辑不同。例如:
[
{"_id":"A2CMX45JPSCTUJ", "rating":5, "comment":"The Best Cable"},
{"_id":"A3EIML9QZO5NZZ", "rating":5, "comment":"awesome"},
{"_id":"A3C9F3SZWLWDZF", "rating":2, "comment":"worse than previous one"},
{"_id":"A1C60KQ8VJZBS5", "rating":4, "comment":"Makes changing strings a breeze"}
]
properties:
- name: rating
type: int32
- name: _id
type: _id
# 对于字段comment:省略配置type,该字段将默认为string类型;省略配置该字段时,该字段将不被导入
示例:修改字段名、字段类型
如果数据源的字段名、字段类型在嬴图系统中无效,或是与目标图集中的属性不一致时,需使用new_name
、type
进行修改。此时,即使目标属性的类型是string也不能省略type
。例如:
_id:_id,rating:int32,comment:string
A2CMX45JPSCTUJ,5,The Best Cable
A3EIML9QZO5NZZ,5,awesome
A3C9F3SZWLWDZF,2,worse than previous one
A1C60KQ8VJZBS5,4,Makes changing strings a breeze
properties:
- name: rating
type: string # 此处不可省略配置type,否则Transporter会延用表头中的int32作为字段rating的类型
- name: comment
new_name: content
由于各类数据库、数仓所支持的数据类型有所不同,Transporter会将数据源的字段类型自动映射为嬴图所支持的类型,个别无法对应的类型将报警并自动忽略。
示例:给字段值附加前缀
如果数据源中的点ID无法达到全图唯一,需使用prefix
进行前缀处理。仅支持给_id
,_from
,_to
类型的字段添加前缀。例如:
id,name
1,Hubert Pirtle
2,John Fowler
3,Christopher Sanzot
id,name
1,VoxelCloud
2,Lifeforce Ventures
3,Dentsu Ventures
personID,companyID,shareInt
1,3,59
2,1,10
3,1,23
3,2,47
...
nodeConfig:
- schema: "person"
file: /Data/person.csv
head: true
properties:
- name: id
type: _id
prefix: person_ # 给person.csv的id字段值附加前缀person_
- schema: "company"
file: /Data/company.csv
head: true
properties:
- name: id
type: _id
prefix: company_ # 给company.csv的id字段值附加前缀company_
edgeConfig:
- schema: "holding"
file: /Data/holding.csv
head: true
properties:
- name: personID
type: _from
prefix: person_ # 给holding.csv的personID字段值附加前缀person_
- name: companyID
type: _to
prefix: company_ # 给holding.csv的companyID字段值附加前缀company_
- name: shareInt
type: int32
...
属性类型在CSV中的有效写法
string、text
- 当全局参数
quotes
设置为false(默认值)时,单个双引号被识别为字段首、尾的边界,相邻两个双引号被识别为字段内容中的一个双引号。例如:
field1:string,field2:text,field3:string
abc,"a,b,c",no double quotation in this field
def,"d,e,f","a double quotation "" in this field"
ghi,"g,h,i",quotes set to false
- 当全局参数
quotes
设置为true时,任意位置、任意个数的双引号均被识别为字段内容中的双引号,此时无法使用双引号包裹含有逗号的字段。例如:
field1:string,field2:text,field3:string
abc,"a",no double quotation in this field
def,"d",a double quotation " in this field
ghi,"g",quotes set to true
decimal
"decimal:decimal(5,3)"
99.999
0.999
0.001
-99.000
-99.999
0.000
datetime、timestamp
time1:datetime,time2:datetime,time3:timestamp,time4:timestamp
1987-11-02,1987-11-02 01:25:52,1987-11-02T01:25:52+0400,562785952000
2001-08-14,2001-08-14 13:43:16,2001-08-14T13:43:16-1100,997767796000
1998-02-19,1998-02-19 16:15:03,1998-02-19T16:15:03+0200,887876103000
更多可选的时间格式如下,注意格式中的时区信息将被datetime类型忽略:
[YY]YY-MM-DD HH:MM:SS
[YY]YY-MM-DD HH:MM:SSZ
[YY]YY-MM-DDTHH:MM:SSZ
[YY]YY-MM-DDTHH:MM:SS[+/-]0x00
[YY]YYMMDDHH:MM:SS[+/-]0x00
[YY]YY/MM/DD HH:MM:SS
[YY]YY/MM/DD HH:MM:SSZ
[YY]YY/MM/DDTHH:MM:SSZ
[YY]YY/MM/DDTHH:MM:SS[+/-]0x00
[YY]YYYY-MM-DD
[YY]YYYY/MM/DD
[YY]YYYYMMDD
list
list1:int32[],list2:string[]
"[1,3,3]","[possitive,rebuy]"
"[2,1,4]","[negative]"
"[3,1,2]","[negative,rebuy]"
"[4,2,4]","[possitive]"
列表中的某元素有占位但无值时表示空值null,如[1,,3]中的第二个元素为null。
set
set1:set(int32),set2:set(string)
"[1,3]","[possitive,rebuy]"
"[2,1,4]","[negative]"
"[3,1,2]","[negative,rebuy]"
"[4,2]","[possitive]"
point
point1:point,point2:point,point3:point,point4:point
POINT(39.9 116.3),"{latitude:39.9,longitude:116.3}","[39.9,116.3]","39.9,116.3"
POINT(40.7 -74),"{latitude:40.7,longitude:-74}","[40.7,-74]","40.7,-74"
POINT(48.5 2.2),"{latitude:48.5,longitude:2.2}","[48.5,2.2]","48.5,2.2"