技术博客 技术博客
  • JAVA
  • 仓颉
  • 设计模式
  • 人工智能
  • Spring
  • Mybatis
  • Maven
  • Git
  • Kafka
  • RabbitMQ
  • RocketMQ
  • Redis
  • Zookeeper
  • Nginx
  • 数据库套件
  • MySQL
  • Elasticsearch
  • MongoDB
  • Hadoop
  • ClickHouse
  • Hbase
  • Hive
  • Flink
  • Flume
  • SQLite
  • linux
  • Docker
  • Jenkins
  • Kubernetes
  • 工具
  • 前端
  • AI
GitHub (opens new window)
  • JAVA
  • 仓颉
  • 设计模式
  • 人工智能
  • Spring
  • Mybatis
  • Maven
  • Git
  • Kafka
  • RabbitMQ
  • RocketMQ
  • Redis
  • Zookeeper
  • Nginx
  • 数据库套件
  • MySQL
  • Elasticsearch
  • MongoDB
  • Hadoop
  • ClickHouse
  • Hbase
  • Hive
  • Flink
  • Flume
  • SQLite
  • linux
  • Docker
  • Jenkins
  • Kubernetes
  • 工具
  • 前端
  • AI
GitHub (opens new window)
  • mysql

    • MySQL 问题汇总
    • MySQL 索引介绍
    • MySQL 锁介绍
    • MySQL 索引优化工具 explain
    • MySQL 主从复制(GTID)
    • MySQL 8安装
    • MySQL 8.x新特性总结
    • MySQL UDF以及新类型JSON
    • MySQL 高可用MGR(一) 理论
    • MySQL 高可用MGR(二) 搭建
    • MySQL 高可用MGR(三) 测试
  • Elasticsearch

    • ES 7.8.0(一) 入门介绍
    • ES 7.8.0(二) 读、写和写索引流程以及文档分析过程
    • ES 7.8.0(三) 文档冲突
  • mongodb

    • mongodb
  • hadoop

    • Hadoop 伪分布式及集群
    • Hadoop 指令
    • Hadoop 读写流程详解
    • Hadoop SpringBoot集成
    • Hadoop MapReduce机制
    • Hadoop YARN
    • Hadoop MapReduce配置和编写job及数据倾斜的解决
    • Hadoop MapReduce自定义格式输入输出
  • clickhouse

    • ClickHouse 介绍及安装
    • ClickHouse 数据类型
    • ClickHouse 表引擎
    • ClickHouse SQL操作
    • ClickHouse 副本配置
    • ClickHouse 分片与集群部署
    • ClickHouse Explain及建表优化
    • ClickHouse 语法优化规则
    • ClickHouse 查询优化
    • ClickHouse 数据一致性
    • ClickHouse 物化视图
    • ClickHouse MaterializeMySQL引擎
    • ClickHouse 监控及备份
  • hbase

    • Hbase 介绍及安装
    • Hbase 优化
    • Hbase phoenix安装及使用
    • Hbase LSM-TREE
  • hive

    • Hive 介绍及安装
    • Hive 内外部表、分区表、分桶表概念及hiveSQL命令
    • Hive 数据类型
      • 常用的基本数据类型
      • 复杂数据类型
      • array类型
      • map类型
      • struct类型
    • Hive 函数 MySQL联合
    • Hive 数据倾斜和优化
    • Hive Sqoop安装及指令
  • flink

    • Flink 介绍及安装
    • Flink 配置介绍及Demo
    • Flink API讲解
    • Flink 运行架构
    • Flink 时间语义及Watermark
    • Flink 状态管理
    • Flink 容错,检查点,保存点
    • Flink 状态一致性
    • Flink Table API 和 Flink SQL
    • Flink CEP编程
    • Flink Joining编程
    • Flink CDC
  • flume

    • Flume 日志收集系统介绍及安装
    • Flume Source支持的类型
    • Flume Sink支持的类型
    • Flume Channel支持的类型
    • Flume Selector
    • Flume Interceptor拦截器类型
    • Flume Process
  • sqlite

    • SQLite介绍
目录
常用的基本数据类型
复杂数据类型
array类型
map类型
struct类型

Hive 数据类型

本文及后续所有文章都以 3.1.2 做为版本讲解和入门学习

# 常用的基本数据类型

基本数据类型 所占字节
int
boolean
float
double
string

# 复杂数据类型

基本数据类型 说明
array array 类型是由一系列相同数据类型的元素组成。并且可以通过下标来进行访问。下标从 0 开始计
map map 包含 key-value 键值对,可以通过 key 来访问元素
struct struct 可以包含不同的数据类型元素。相当于一个对象结构。可以通过 对象。属性 来访问

# array 类型

现有外部数据路径为 /a1/a1.txt 结构如下:

100,300,200 aa,v,cc
442,245,214 dd,ee,dd
1
2

把外部数据创建到 hive 里,terminated by ' ' 为列分隔符,terminated by ',' 集合元素分隔符

create external table table_name(t1 array<int>,t2 array<string>) row format delimited fields terminated by ' ' collection items terminated by ',' location '/a1'
1

查看 t1 列的元素个数

select size(t1) from table_name;
1

通过下标获取 t1 列的集合元素的第一个数据

select t1[0] from table_name;
1

# map 类型

现有外部数据路径为 /a2/a2.txt 结构如下:

test1,100
test2,200
test3,300
test1,200
test2,200
1
2
3
4
5

把外部数据创建到 hive 里,terminated by '\t' 为列分隔符(必须),terminated by ',' key-value 分隔符

create external table table_name(t1 map<string,int>) row format delimited fields terminated by '\t' map keys terminated by ',' location '/a2'
1

查询 t1 列 为 test2 的 key 的值,并去重,distinct 函数会触发 mapreduce。

select distinct(t1['test2']) from table_name where  t1['test1' is not null;
1

# struct 类型

现有外部数据路径为 /a3/a3.txt 结构如下:

1 zs 22
1 ls 23
1 ww 18
1 zl 25
1
2
3
4

把外部数据创建到 hive 里,terminated by '\t' 为列分隔符(必须),terminated by ',' key-value 分隔符

create external table table_name(t1 struct<id:int,name:string,age:int>) row format delimited collection items terminated by ' ' location '/a2'
1

查看 ls 的年龄

select t1.age from table_name y1.name = 'ls';
1
上次更新: 6/11/2025, 4:10:30 PM
Hive 内外部表、分区表、分桶表概念及hiveSQL命令
Hive 函数 MySQL联合

← Hive 内外部表、分区表、分桶表概念及hiveSQL命令 Hive 函数 MySQL联合→

Theme by Vdoing | Copyright © 2023-2025
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式