nebula-exchange导入neo4j数据类型问题,Cannot coerce INTEGER to Java int without losing precision

  • nebula 版本:3.0.1
  • 部署方式:分布式
  • 安装方式:RPM
  • 是否为线上版本:Y
  • 硬件信息
    • 磁盘:SSD
    • CPU、内存信息
  • 问题的具体描述
    使用nebula-exchange导入neo4j的数据时,出现数据格式转换问题。使用的是nebula-exchange 3.0.0版本,spark 2.4, scala 2.11.12
    neo4j中name设置为long,nebula中设置为int64
  • 相关的 meta / storage / graph info 日志信息(尽量使用文本形式方便检索)
    报错截图:

    nebula图空间:
    vid_type设置为fixed_string(64)
    nebula表结构:
    image
**配置文件:**
tags: [
    # uid
    {
      name: uid
      type: {
        source: neo4j
        sink: client
      }
      server: "bolt://192.168.1.101:7687"
      user: neo4j
      password: admin
      exec: "match (n:uid) with n,reduce(tagString = '', word IN n.tag | tagString + word + ',') as tagsString, reduce(uniqueKeyString = '', word IN n.unique_keys | uniqueKeyString + word + ',') as uniqueKeysString return toString(n.name) as vid, n.name as name, n.type as type, n.is_black as is_black, n.is_black_v2 as is_black_v2, left(tagsString, size(tagsString)-1) as tags, n.level as level, n.risk_level as risk_level, n.repay_date as repay_date, n.first_repay_date as first_repay_date, left(uniqueKeysString, size(uniqueKeysString)-1) as unique_keys, n.status as status, n.max_hdpd as max_hdpd order by n.name"
      fields: [name, type, is_black, is_black_v2, tags, level, risk_level, repay_date, first_repay_date, unique_keys, status, max_hdpd]
      nebula.fields: [name, type, is_black, is_black_v2, tags, level, risk_level, repay_date, first_repay_date, unique_keys, status, max_hdpd]
      vertex: {
        field:vid
      }
      partition: 10
      batch: 1000
      check_point_path: /tmp/test/uid
   }
]

代码:
package com.vesoft.nebula.exchange.utils

import org.neo4j.driver.Value

object Neo4jUtils {

  def convertNeo4jData(value: Value): String = {
    value.`type`().name() match {
      case "NULL" => {
        null
      }
      case "STRING" => {
        value.asString()
      }
      case "INTEGER" => {
        value.asInt().toString
      }
      case "FLOAT" | "DOUBLE" => {
        value.asDouble().toString
      }
      case "BOOLEAN" => {
        value.asBoolean().toString
      }
      case "DATE" | "LOCAL_DATE" => {
        value.asLocalDate().toString
      }
      case "DATE_TIME" | "LOCAL_DATE_TIME" => {
        value.asLocalDateTime().toString
      }
      case "TIME" | "LOCAL_TIME" => {
        value.asLocalTime().toString
      }
      case "BYTES" => {
        new String(value.asByteArray())
      }
      case "LIST" => {
        value.asList().toString
      }
      case "MAP" => {
        value.asMap().toString
      }
      case _ => {
        value.toString
      }
    }
  }
}

报错信息是将neo4j的INTEGER类型转换为Int时报出来的,如下是neo4j driver中的类型转换代码:

感谢反馈,Integer数据可以直接使用neo4j的asLong进行转换,我们会尽快fix。

1 个赞

此话题已在最后回复的 7 天后被自动关闭。不再允许新回复。

浙ICP备20010487号