使用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;

相关推荐
XDHCOM21 小时前
ORA-32484重复列名错误,ORACLE数据库CYCLE子句故障修复与远程处理方案
数据库·oracle
翻斗包菜21 小时前
PostgreSQL 日常维护完全指南:从基础操作到高级运维
运维·数据库·postgresql
呆瑜nuage21 小时前
MySQL表约束详解:8大核心约束实战指南
数据库·mysql
liliangcsdn21 小时前
Agent Memory智能体记忆系统的示例分析
数据库·人工智能·全文检索
那个失眠的夜21 小时前
Mybatis延迟加载策略
xml·java·数据库·maven·mybatis
Rick199321 小时前
SQL 执行流程
数据库·sql
M--Y21 小时前
Redis常用数据类型
数据结构·数据库·redis
元宝骑士1 天前
FIND_IN_SET使用指南:场景、优缺点与MySQL优化策略
后端·mysql
猿小喵1 天前
MySQL慢查询分析与处理-第二篇
数据库·mysql·性能优化
Y001112361 天前
MySQL-进阶
开发语言·数据库·sql·mysql