【问题标题】:EMR Hudi cannot create hive connection jdbc:hive2://localhost:10000/EMR Hudi 无法创建 hive 连接 jdbc:hive2://localhost:10000/
【发布时间】:2021-11-27 18:28:39
【问题描述】:

尝试在启用 hive-sync 的情况下将 hudi 表保存在 Jupyter 笔记本中。我正在使用 EMR: 5.28.0 并启用 AWS Glue 作为目录:

# Create a DataFrame
inputDF = spark.createDataFrame(
    [
        ("100", "2015-01-01", "2015-01-01T13:51:39.340396Z"),
        ("101", "2015-01-01", "2015-01-01T12:14:58.597216Z"),
        ("102", "2015-01-01", "2015-01-01T13:51:40.417052Z"),
        ("103", "2015-01-01", "2015-01-01T13:51:40.519832Z"),
        ("104", "2015-01-02", "2015-01-01T12:15:00.512679Z"),
        ("105", "2015-01-02", "2015-01-01T13:51:42.248818Z"),
    ],
    ["id", "creation_date", "last_update_time"]
)

# Specify common DataSourceWriteOptions in the single hudiOptions variable
hudiOptions = {
'hoodie.table.name': 'my_hudi_table',
'hoodie.datasource.write.recordkey.field': 'id',
'hoodie.datasource.write.partitionpath.field': 'creation_date',
'hoodie.datasource.write.precombine.field': 'last_update_time',
'hoodie.datasource.hive_sync.enable': 'true',
'hoodie.datasource.hive_sync.table': 'my_hudi_table',
'hoodie.datasource.hive_sync.partition_fields': 'creation_date',
'hoodie.datasource.hive_sync.partition_extractor_class': 'org.apache.hudi.hive.MultiPartKeysValueExtractor'
}

# Write a DataFrame as a Hudi dataset
(inputDF.write
.format('org.apache.hudi')
.option('hoodie.datasource.write.operation', 'insert')
.options(**hudiOptions)
.mode('overwrite')
.save('s3://dytyniak-test-data/myhudidataset/'))

收到以下错误:

An error occurred while calling o309.save.
: org.apache.hudi.hive.HoodieHiveSyncException: Cannot create hive connection jdbc:hive2://localhost:10000/
    

【问题讨论】:

    标签: apache-spark pyspark amazon-emr aws-glue apache-hudi


    【解决方案1】:

    我假设您正在关注 AWS 文档中的 tutorial。我通过在hudiOptions 中将hive_sync.mode 设置为hms 使其使用Hudi 0.9.0 工作(参见hudi docs):

    hudiOptions = {
        'hoodie.table.name': 'my_hudi_table',
        'hoodie.datasource.write.recordkey.field': 'id',
        'hoodie.datasource.write.partitionpath.field': 'creation_date',
        'hoodie.datasource.write.precombine.field': 'last_update_time',
        'hoodie.datasource.hive_sync.enable': 'true',
        'hoodie.datasource.hive_sync.table': 'my_hudi_table',
        'hoodie.datasource.hive_sync.partition_fields': 'creation_date',
        'hoodie.datasource.hive_sync.partition_extractor_class': 
        'org.apache.hudi.hive.MultiPartKeysValueExtractor',
        'hoodie.datasource.hive_sync.mode': 'hms'
    }
    

    【讨论】:

      猜你喜欢
      • 2021-05-19
      • 2021-08-30
      • 2016-08-25
      • 1970-01-01
      • 2011-08-06
      • 1970-01-01
      • 1970-01-01
      • 2013-04-13
      • 2019-10-25
      相关资源
      最近更新 更多