跳转至
开发版采用单机部署,无需产品 License 文件。需要多机部署或大规模性能测试? 了解企业版

Hive 配置

本文介绍从 Hive 数据源导入数据的配置项。关于完整配置文件和配置项的信息,请参见数据导入配置。

数据源配置

下表列出了 Hive 数据源特定的配置项:

选项 描述 类型 是否必选 默认值
type 数据源的类型。设置为"hive"。 String 是 无
uris 远程 Metastore 服务的 Thrift URI。可以从文件hive-site.xml的属性hive.metastore.uris中获取 URI。 若您的 Spark 环境集成了 Hive,则此项可选。 String 否 无
defaultFS 存储 Hive 数据的默认文件系统的 URI。若您的 Spark 环境集成了 Hive,则此项可选。 String 否 无
statement 用于从 Hive 检索数据的 HiveQL 语句。 String 是 无

通用源配置

下列配置项也可以作为全局设置在配置文件的sourcesCommon一节指定:

  • type
  • uris
  • defaultFS

请注意,针对特定数据源的配置会覆盖全局设置。

数据源配置示例

Hive 源配置
sources: [
  {
      type:"hive"
      uris:"thrift://192.168.8.149:9083"
      defaultFS:"hdfs://192.168.8.149:9000"
      statement:"select people_id,name,birth_date from movie.actor"
//      nodetypes: []
//      edgetypes: []
  }
]    

完整配置示例

将<current-password>替换为登录账号的当前密码。若已修改密码,请使用修改后的密码。

{
  taskType: import
  nebula: {
    graphAddr: "127.0.0.1:9669"
    graphName: "movie"
    user: "root"
    passwd: "<current-password>"
  }
  error: {
    path: "/tmp/errors"
    maxRecords: 10000
  }
    checkPoint: {
    path: "/tmp/checkpoint"
    resume: false
  } 
  sourcesCommon:{
    type:"hive"
    uris:"thrift://192.168.8.149:9083"
    defaultFS:"hdfs://192.168.8.149:9000"
  }
  writeCommon:{
    batchSize: 2000 
    enableRealTimeQPSLog: true
    mode: "INSERT IGNORE"
  }
  sources: [
    # node type Actor
    {
      statement:"select people_id,name,birth_date from movie.actor"
      pre_processes: {
          filter: ["birth_date!='\\N'"]
          concatConstant: [
            {
              field: "name"
              prefixValue: "test_"
              suffixValue: ""
            }
          ]
      }
      nodetypes: [
        {
          name: "Actor"
          sourceFields: [people_id,name,birth_date]
          nebulaFields: [id,name,birthDate]
        }
      ]
    }
    # node type Movie
    {
      statement:"select movie_id,name from movie.movie"
      nodetypes: [
        {
          name: "Movie"
          sourceFields: [movie_id,name]
          nebulaFields: [id,name]
        }
      ]
    }
   # edge type Act
    {
      statement:"select people_id,movie_id from movie.act"
      edgetypes: [
        {
          name: "Act"
          sourceKeys: [people_id]
          nebulaSrcKeys: [id]
          targetKeys: [movie_id]
          nebulaDstKeys: [id]
          sourceFields: []
          nebulaFields: []
        }
      ]
    }

  ]
}