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

相关推荐
C++业余爱好者26 分钟前
SQL语言家族入门指南:标准SQL、T-SQL与PL/SQL详解
数据库·sql
白驹过隙^^29 分钟前
OB-USP-AGENT安装使用方法
数据库·经验分享·网络协议·tcp/ip·github·ssl
计算机程序设计小李同学30 分钟前
基于Python的在线零食购物商城系统的设计与实现
数据库·sqlite
Java爱好狂.1 小时前
Java面试Redis核心知识点整理!
java·数据库·redis·分布式锁·java面试·后端开发·java八股文
小程故事多_801 小时前
开源界核弹级输出!蚂蚁 Agentar-Scale-SQL 凭 “编排式扩展” 技术,成为 Text-to-SQL 天花板
数据库·人工智能·sql·开源·aigc·embedding
谷隐凡二1 小时前
etcd在Kubernetes中的作用简单介绍
数据库·kubernetes·etcd
阿杆1 小时前
如何在 Spring Boot 中接入 Amazon ElastiCache
java·数据库·redis
qq_343247031 小时前
单机版认证kafka
数据库·分布式·kafka
2301_800256112 小时前
第十一章 PostgreSQL 服务器编程知识点梳理(1)
服务器·数据库·postgresql
松涛和鸣2 小时前
DAY32 Linux Thread Programming
linux·运维·数据库·算法·list