clickhouse数据字典

前言:
clickhouse的安装见

https://blog.csdn.net/weixin_41463944/article/details/142534145?spm=1001.2014.3001.5501

1、需要在路径/etc/clickhouse-serve下定义*_dictionary.xml结尾的配置文件
2、需要准备organization.csv和sales.csv本地测试文件(注意不是windows下的xlsx表格,是linux下的文件)

2.1 organization.csv文件

1,"a0001","研发部"
2,"a0002","产品部"
3,"a0003","数据部"
4,"a0004","测试部"
5,"a0005","运维部"
6,"a0006","规划部",
7,"a0007","市场部"

2.2 sales.csv文件
1,2016-01-01,2017-01-10,100
2,2016-05-01,2017-07-01,200
3,2014-03-05,2018-01-20,300
4,2018-08-01,2019-10-01,400
5,2017-03-01,2017-06-01,500
6,2017-04-09,2018-05-30,600
7,2018-06-01,2019-01-25,700
8,2019-08-01,2019-12-12,800

3、关于每个xml字典文件的格式

<?xml version="1.0"?>
<dictionaries><dictionary><name>字典名称(全局唯一)</name><source>数据源配置</source><layout>字典数据在内存中的格式</layout><structure>字典的数据结构</structure><lifetime>字典的自动更新频率<min>300</min><max>360</max></lifetime></dictionary>
</dictionaries>

4、关于扩展字典的几种类型配置
一共7种类型,其中flat、hashed、sparse_hashed、range_hashed、cache的主键为数值型UInt64类型的,其他类型如complex_key_hashed、complex_key_cache为复合类型的key

4.1)flat类型的字典,在/etc/clickhouse-serve目录下新建test_flat_dictionary.xml
<?xml version="1.0"?>
<dictionaries><dictionary><name>test_flat_dict</name><source><file><path>/home/clickhouse-server/etc/clickhouse-server/dictionary/organization.csv</path><format>CSV</format></file></source><layout><flat/></layout><structure><id><name>id</name></id><attribute><name>code</name><type>String</type><null_value></null_value></attribute><attribute><name>name</name><type>String</type><null_value></null_value></attribute></structure><lifetime><min>300</min><max>360</max></lifetime></dictionary>
</dictionaries>
4.2)hashed类型的字典,在/etc/clickhouse-serve目录下新建test_hashed_dictionary.xml
<?xml version="1.0"?>
<dictionaries><dictionary><name>test_hashed_dict</name><source><file><path>/home/clickhouse-server/etc/clickhouse-server/dictionary/organization.csv</path><format>CSV</format></file></source><layout><hashed/></layout><structure><id><name>id</name></id><attribute><name>code</name><type>String</type><null_value></null_value></attribute><attribute><name>name</name><type>String</type><null_value></null_value></attribute></structure><lifetime><min>300</min><max>360</max></lifetime></dictionary>
</dictionaries>
4.3)complex_key_hashed类型的字典,在/etc/clickhouse-serve目录下新建complex_key_hashed_dictionary.xml
<?xml version="1.0"?>
<dictionaries><dictionary><name>test_complex_key_hashed_dict</name><source><file><path>/home/clickhouse-server/etc/clickhouse-server/dictionary/organization.csv</path><format>CSV</format></file></source><layout><complex_key_hashed/></layout><structure><key><attribute><name>id</name><type>UInt64</type></attribute><attribute><name>code</name><type>String</type></attribute></key><attribute><name>name</name><type>String</type><null_value></null_value></attribute></structure><lifetime><min>300</min><max>360</max></lifetime></dictionary>
</dictionaries>
4.4)range_hashed类型的字典,在/etc/clickhouse-serve目录下新建test_range_hashed_dictionary.xml
<?xml version="1.0"?>
<dictionaries><dictionary><name>test_range_hashed_dict</name><source><file><path>/home/clickhouse-server/etc/clickhouse-server/dictionary/sales.csv</path><format>CSV</format></file></source><layout><range_hashed/></layout><structure><id><name>id</name></id><range_min><name>start</name></range_min><range_max><name>end</name></range_max><attribute><name>price</name><type>Float32</type><null_value></null_value></attribute></structure><lifetime><min>300</min><max>360</max></lifetime></dictionary>
</dictionaries>

5、关于字典的数据源
5.1 文件类型,格式通常为CSV或者TabSeparated
1)本地文件

<source><file><path>/home/clickhouse-server/etc/clickhouse-server/dictionary/organization.csv</path><format>CSV</format></file></source>
2)可执行文件
<source><executable><command>/home/clickhouse-server/etc/clickhouse-server/dictionary/organization.csv</command><format>CSV</format></executable></source>
3)远程文件
<source><http><url>xxxxx.csv</url><format>CSV</format></http></source>
5.2 数据库类型的数据源
1)mysql
<source><mysql><port>3306</port><user>xxxx</user><password>xxxx</password><replica><host>localhost</host><priority>1</priority></replica><db>db_mybatis</db><table>userList</table></mysql></source>

其中<mysql> 标签的下一级可添加 <where>is_deleted=0</where>做为筛选条件
2)clickhouse

 <source><clickhouse><host>localhost</host><port>9000</port><user>xxxx</user><password>xxxxx</password><db>my_database</db><table>test_table</table></clickhouse></source>

6、关于DDL语句

dictGet(‘字典名称’,‘字典的具体字段’,‘key键值’),如果字典为复合key的话,则在字典函数中的key用元组tuple(‘a’,‘b’,‘c’)表示

7、关于手动刷新数据字典

7.1 )全局字典刷新

system reload dictionaries

7.2)刷新单个字典(字典名称不加单引号)

system reload dictionary test_mysql_dict

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/443104.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C++——vector

目录 一、简介 二、接口 1.构造 2.空间变化 3.增删查改 三、vector与string的区别 四、模拟实现 vector.h test.cpp 一、简介 vector&#xff0c;其实就是我们C语言学过的动态顺序表&#xff0c;一个可以存储任何数据类型&#xff0c;可以动态增长的数组。C的STL将其收…

项目完整开发的流程

流程 1.设计产品 2.写需求文档 2.1需求分析&#xff0c;后端设计数据库&#xff0c;建表&#xff0c;客户沟通&#xff0c;说完签字&#xff0c;留证据&#xff0c;防止后面扯皮&#xff0c;和防止后续变需求重新写业务 3.画原型图&#xff0c;也就是草图&#xff0c;初始的…

Java报错输出的信息究竟是什么?

Java报错输出的信息究竟是什么&#xff1f; 本篇会带大家了解一下java运行时报错输出的信息内容&#xff0c;简单学习一下虚拟机内存中Java虚拟机栈的工作方式以及栈帧中所存储的信息内容 异常信息 当你的程序运行报错时&#xff0c;你是否会好奇打印出来的那一大坨红色的究竟…

上海AI Lab视频生成大模型书生.筑梦环境搭建推理测试

引子 最近视频生成大模型层出不穷&#xff0c;上海AI Lab推出新一代视频生成大模型 “书生・筑梦 2.0”(Vchitect 2.0)。根据官方介绍&#xff0c;书生・筑梦 2.0 是集文生视频、图生视频、插帧超分、训练系统一体化的视频生成大模型。OK&#xff0c;那就让我们开始吧。 一、模…

怎么将手机备忘录传送至电脑

在数字化时代&#xff0c;手机备忘录已成为我们生活中不可或缺的一部分。无论是记录购物清单、工作事项&#xff0c;还是灵感闪现的瞬间&#xff0c;手机备忘录都能随时记录下这些宝贵的信息&#xff0c;帮助我们防止遗忘。然而&#xff0c;有时候我们需要将这些备忘录内容转移…

AtCoder Beginner Contest 374

C - Separated Lunch 题目&#xff1a; 思路&#xff1a; dfs枚举每个数是否选入a数组中&#xff0c;求和比较 代码&#xff1a; #include <bits/stdc.h>using namespace std;typedef long long LL;const int N25;int a[N]; bool st[N]; int mn0x3f3f3f3f; int sum; …

thinkphp 学习记录

1、PHP配置 &#xff08;点开链接后&#xff0c;往下拉&#xff0c;找到PHP8.2.2版本&#xff0c;下载的是ZIP格式&#xff0c;解压即用&#xff09; PHP For Windows: Binaries and sources Releases &#xff08;这里是下载地址&#xff09; 我解压的地址是&#xff1a;D:\…

webGL进阶(一)多重纹理效果

效果&#xff1a; 代码&#xff1a; <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><meta http-equiv"X-UA-Compatible" content"IEedge"><meta name"viewport" content&q…

初始Linux(二)基础命令

前言&#xff1a; 之前那一篇我们已经介绍了一部分的基础命令&#xff0c;当然那只不过是九牛一毛&#xff0c;本篇我们继续介绍一些比较重要且需要掌握的基础命令。 mv命令&#xff1a; 其实这个命令有两个功能&#xff0c;一个是移动&#xff08;剪切&#xff09;文件&#…

【LeetCode】每日一题 2024_10_9 找到按位或最接近 K 的子数组(LogTrick、位运算)

前言 每天和你一起刷 LeetCode 每日一题~ LeetCode 启动&#xff01; 题目&#xff1a;找到按位或最接近 K 的子数组 代码与解题思路 今天是 2100 的题目&#xff0c;难度略高&#xff0c;不在我的能力范围&#xff0c;推荐题解&#xff1a;两种方法&#xff1a;LogTrick/滑…

【优选算法】--- 位运算

位运算 一、常见的位运算总结&#xff08;重点&#xff01;&#xff09;1、关于位运算的符号2、&#xff08;判断&#xff09;给一个数字n&#xff0c;确定它的二进制表示中的第X位&#xff0c;是1还是0&#xff1f;3、&#xff08;修改&#xff09;如何把一个二进制的数字的第…

计算机、大数据与人工智能国际学术会议

第五届计算机、大数据与人工智能国际会议由景德镇陶瓷大学主办&#xff0c;西安交通大学、暨南大学、南京邮电大学、长沙学院、景德镇学院、爱迩思出版社&#xff08;ELSP&#xff09;协办。会议于2024年11月1日~3日在江西景德镇举行。在本次会议上发表的文章将出版到会议论文集…

目标检测实战教程Day1(原创)

原创不易&#xff0c;转载请标明本文地址 目标检测一直是计算机视觉领域的核心问题之一&#xff0c;它就像是让计算机拥有了一双“鹰眼”&#xff0c;能在复杂的图像中迅速锁定和识别出各种有趣的目标&#xff0c;比如人、汽车、动物或者任何其他特定物体。在这一章&#xff0c…

NeuVector部署、使用与原理分析

文章目录 前言1、概述2、安装与使用2.1、安装方法2.1.1、部署NeuVector前的准备工作2.1.1.1 扩容系统交换空间2.1.1.2 Kubernetes单机部署2.1.1.2.1 部署Docker2.1.1.2.2 部署Kubectl2.1.1.2.3 部署Minikube 2.1.1.3 Helm部署 2.1.2、使用Helm部署NeuVector 2.2、使用方法2.2.1…

跟《经济学人》学英文:2024年09月28日这期 The curse of the Michelin star

The curse of the Michelin star Restaurants awarded the honour are more likely to close, research finds 原文&#xff1a; The twelve new restaurants added to the New York Michelin Guide this month, serving up cuisine ranging from “haute French” to “eco…

【springboot9735】基于springboot+vue的车辆充电桩

主营内容&#xff1a;SpringBoot、Vue、SSM、HLMT、Jsp、PHP、Nodejs、Python、爬虫、数据可视化、小程序、安卓app等设计与开发。 收藏点赞不迷路&#xff0c;关注作者有好处 项目描述 随着信息化时代的到来&#xff0c;管理系统都趋向于智能化、系统化&#xff0c;车辆充电桩…

LabVIEW交直流接触器动态检测系统

LabVIEW软件与霍尔传感器技术结合的交直流接触器动态检测系统通过实时数据采集和处理技术&#xff0c;有效地测量并分析交直流接触器在吸合及吸持阶段的电流和电压变化&#xff0c;以及相应的功率消耗&#xff0c;从而优化电力和配电系统的性能和可靠性。 项目背景 交直流接触…

【Linux:线程控制】

目录 线程的创建与等待&#xff1a; ​编辑 代码中tid是什么&#xff1f; 如何看待线程函数传参&#xff1f; ​编辑 ​编辑创建多线程&#xff1a;​编辑 终止多线程&#xff1a; 线程分离&#xff1a; 线程封装&#xff1a; 线程的创建与等待&#xff1a; void *thre…

在docker中安装并运行mysql8.0.31

第一步&#xff1a;命令行拉取mysql镜像 docker pull mysql:8.0.31查看是否拉取成功 docker images mysql:latest第二步&#xff1a;运行mysql镜像&#xff0c;启动mysql实例 docker run -p 3307:3307 -e MYSQL_ROOT_PASSWORD"123456" -d mysql:8.0.313307:3307前…

51单片机的智能水温控制系统【proteus仿真+程序+报告+原理图+演示视频】

1、主要功能 该系统由AT89C51/STC89C52单片机LCD1602显示模块温度传感器继电器LED和按键等模块构成。适用于智能热水器控制、泳池水温控制系统等相似项目。 可实现功能: 1、LCD1602实时显示水温信息和上下限 2、温度传感器DS18B20采集水体温度 3、当温度低于下限&#xff0…