clickhouse集群对接hive(三)

九月2年前技术文章686

前提:集群中已经部署了hive组件和clickhouse集群,clickhouse集群进行对接hive

1、设置hdfs文件系统本地缓存

<local_cache_for_remote_fs>
    <enable>true</enable>
    <root_dir>local_cache</root_dir>
    <limit_size>559096952</limit_size>
    <bytes_read_before_flush>1048576</bytes_read_before_flush>
</local_cache_for_remote_fs>

1.png

2、在hive中创建orc的表

user use test;
CREATE TABLE `test`.`test_orc`(
  `f_tinyint` tinyint, 
  `f_smallint` smallint, 
  `f_int` int, 
  `f_integer` int, 
  `f_bigint` bigint, 
  `f_float` float, 
  `f_double` double, 
  `f_decimal` decimal(10,0), 
  `f_timestamp` timestamp, 
  `f_date` date, 
  `f_string` string, 
  `f_varchar` String,
  `f_bool` boolean, 
  `f_binary` binary, 
  `f_array_int` array<int>, 
  `f_array_string` array<string>, 
  `f_array_float` array<float>, 
  `f_array_array_int` array<array<int>>, 
  `f_array_array_string` array<array<string>>, 
  `f_array_array_float` array<array<float>>)
  PARTITIONED BY ( 
  `day` string)
ROW FORMAT SERDE 
  'org.apache.hadoop.hive.ql.io.orc.OrcSerde' 
STORED AS INPUTFORMAT 
  'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat' 
OUTPUTFORMAT 
  'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'
LOCATION
  'hdfs://mycluster/user/hive/warehouse/test.db/test_orc';
  
insert into test.test_orc partition(day='2021-09-18') select 1, 2, 3, 4, 5, 6.11, 7.22, 8.333, current_timestamp(), current_date(),'hello world', 'hello world',  true, 'hello world', array(1, 2, 3), array('hello world', 'hello world'), array(float(1.1), float(1.2)), array(array(1, 2), array(3, 4)), array(array('a', 'b'), array('c', 'd')), array(array(float(1.11), float(2.22)), array(float(3.33), float(4.44)));

2.png

在clickhouse中创建表

CREATE TABLE test.test_orc
(
    `f_tinyint` Int8,
    `f_smallint` Int16,
    `f_int` Int32,
    `f_integer` Int32,
    `f_bigint` Int64,
    `f_float` Float32,
    `f_double` Float64,
    `f_decimal` Float64,
    `f_timestamp` DateTime,
    `f_date` Date,
    `f_string` String,
    `f_varchar` String,
    `f_bool` Bool,
    `f_binary` String,
    `f_array_int` Array(Int32),
    `f_array_string` Array(String),
    `f_array_float` Array(Float32),
    `f_array_array_int` Array(Array(Int32)),
    `f_array_array_string` Array(Array(String)),
    `f_array_array_float` Array(Array(Float32)),
    `day` String
)
ENGINE = Hive('thrift://172.16.121.0:9083', 'test', 'test_orc')
PARTITION BY day

SELECT * FROM test.test_orc settings input_format_orc_allow_missing_columns = 1\G

3.jpg



相关文章

MongoDB的碎片化问题

一、碎片化问题1.1 为什么会出现碎片化的问题在生产业务中,一般会对集合数据进行频繁的增删改,常见的碎片化原因有:1、记录被remove,但是其空间没有被复用drop命令会直接删除集合的物理文件,空间...

CDH实操--kudumaster迁移

CDH实操--kudumaster迁移

1 概述本次kudumaster迁移,中间不需要停kudu集群(会涉及滚动重启kudu角色); 注:若因为任务持续运行导致kudu停止超时可手动一台台停止-启动2 master迁移将cdh2中的ma...

OSS bucket权限设置

OSS bucket权限设置

问题描述调用oss的bucket资源,开始的时候可以访问,过几分钟再访问的时候,就提示拒绝访问问题原因是因为相应的bucket权限为私有,私有权限在访问文件对象时,是存在鉴权URL,存在时间有效性,所...

oracle设置归档路径和格式

1.归档文件格式设置说明:设置归档日志名称格式:alter system set log_archive_format='arch_%t_%s_%r.arc' scope=spfile sid='*'...

Hbase热点现象

热点现象:HBase热点现象是指在分布式存储系统HBase中,由于数据访问不均衡而导致部分Region Server负载过重的情况。这种不均衡通常是由于某些特定的数据行或列族频繁地被访问,从而导致某个...

MySQL日期相关函数

一、当前时间--当前时间select current_timestamp();--当前时间 等价于 select current_timestamp();select now();--基本等价于以上两...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。