使用datax将mysql数据抽取到hive分区表无数据

今天遇到一个问题,使用datax将mysql数据抽取到hive的分区表中,抽取完后没有数据,也不报错

具体是这样的,先常见ods层的表

sql 复制代码
create table ods.sms_coupon_full(
	`id`               string,
	`type`             string,
	`name`             string,
	`platform`         string,
	`count`            string,
	`amount`           string,
	`per_limit`        string,
	`min_point`        string,
	`start_time`       string,
	`end_time`         string,
	`use_type`         string,
	`note`             string,
	`publish_count`    string,
	`use_count`        string,
	`receive_count`    string,
	`enable_time`      string,
	`code`             string,
	`member_level`     string
)partitioned by (dt string)
stored as orc;

接着创建分区:

sql 复制代码
alter table ods.sms_coupon_full add partition (dt='2023-09-25');

使用datax抽取数据到hdfs(其实就是hive)

sql 复制代码
{
  "job": {
    "setting": {
      "speed": {
        "channel": 3
      },
      "errorLimit": {
        "record": 0,
        "percentage": 0.02
      }
    },
    "content": [
      {
        "reader": {
          "name": "mysqlreader",
          "parameter": {
            "username": "root",
            "password": "123456",
            "connection": [
              {
                "querySql": [
                  "select id,type,name,platform,count,amount,per_limit,min_point,start_time,end_time,use_type,note,publish_count,use_count,receive_count,enable_time,code,member_level from sms_coupon"
                ],
                "jdbcUrl": [
                  "jdbc:mysql://bigdata01:3306/spark_project"
                ]
              }
            ]
          }
        },
        "writer": {
          "name": "hdfswriter",
          "parameter": {
            "defaultFS": "hdfs://bigdata01:9820",
            "fileType": "orc",
            "path": "/user/hive/warehouse/ods.db/sms_coupon_full/dt=${dtime}",
            "fileName": "sms_coupon",
            "writeMode": "append",
            "column": [
              {
                "name": "id",
                "type": "bigint"
              },
              {
                "name": "type",
                "type": "int"
              },
              {
                "name": "name",
                "type": "string"
              },
              {
                "name": "platform",
                "type": "int"
              },
              {
                "name": "count",
                "type": "int"
              },
              {
                "name": "amount",
                "type": "string"
              },
              {
                "name": "per_limit",
                "type": "int"
              },
              {
                "name": "min_point",
                "type": "string"
              },
              {
                "name": "start_time",
                "type": "string"
              },
              {
                "name": "end_time",
                "type": "string"
              },
              {
                "name": "use_type",
                "type": "int"
              },
              {
                "name": "note",
                "type": "string"
              },
              {
                "name": "publish_count",
                "type": "int"
              },
              {
                "name": "use_count",
                "type": "int"
              },
              {
                "name": "receive_count",
                "type": "int"
              },
              {
                "name": "enable_time",
                "type": "string"
              },
              {
                "name": "code",
                "type": "string"
              },
              {
                "name": "member_level",
                "type": "int"
              }
            ],
            "fieldDelimiter": "\x01",
            "partition": "dt"
          }
        }
      }
    ]
  }
}

导入之后,假如查询没有数据,使用修复语句修复这个表

msck repair table ods.sms_coupon_history_incr;

然后再查询。

假如是一个普通表,没有分区,查询没有数据,可以通过如下修复:

refresh table dws.new_mid_day;

相关推荐
百***81273 小时前
【HTML+CSS】使用HTML与后端技术连接数据库
css·数据库·html
yumgpkpm3 小时前
数据可视化AI、BI工具,开源适配 Cloudera CMP 7.3(或类 CDP 的 CMP 7.13 平台,如华为鲲鹏 ARM 版)值得推荐?
人工智能·hive·hadoop·信息可视化·kafka·开源·hbase
6***3493 小时前
MySQL项目
数据库·mysql
木井巳3 小时前
【MySQL数据库】数据库基础
数据库·mysql
Wang's Blog3 小时前
MySQL: 查询全流程深度解析与性能优化实践指南
数据库·mysql·性能优化
一 乐3 小时前
宠物管理|宠物共享|基于Java+vue的宠物共享管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·springboot·宠物
Wang's Blog4 小时前
MongoDB小课堂: 高级查询操作符与游标管理综合指南之深度整合逻辑操作符、字段处理、数组查询与游标控制的最佳实践
数据库·mongodb
垂金烟柳4 小时前
MongoDB GridFS 历史数据自动化清理实践
数据库·mongodb·自动化
白露与泡影4 小时前
MySQL中的12个良好SQL编写习惯
java·数据库·面试
foundbug9994 小时前
配置Spring框架以连接SQL Server数据库
java·数据库·spring