使用DataX 的hivewriter 配置:set hive.exec.dynamic.partition=true 开启动态分区
问题1:开启动态分区是DataX写入hive中自己去按照数据做分区 还是只是开启可以动态分区的功能?
问题2:使用DataX hivewriter 怎么编写脚本来设置一个字段为分区字段,来实现根据查询出来字段的值来进行动态分区
各位big old 帮忙讲一件 (最好可以帮忙提供一下问题2的模块 )
基于Monster 组和GPT的调写:
问题2:要将某个字段设置为分区字段,需要在DataX的HiveWriter中进行如下配置:
{
"name": "hiveWriter",
"parameter": {
"writeMode": "nonConflict",
"partition": {
"dynamic": true,
"partitionColumns": [
"partition_col"
]
},
"column": [
"col1",
"col2",
...
"partition_col"
],
"connection": [
{
"jdbcUrl": "jdbc:hive2://yourhivehost:10000",
"table": "yourtable",
"username": "yourusername",
"password": "yourpassword"
}
]
}
}
上述配置中,要设置"dynamic": true来开启动态分区。然后,在"partitionColumns"中设置要用来分区的字段,这里假设分区字段为"partition_col"。