• kudu 常用整理


    进入终端,输入Impala-shell,进入impala数据库命令窗口

    impala-shell
    

    创建库:

    create database kudu_test_txd;
    

    kudu内部表:

    create table multi_kudu_table3
    (
    id BIGINT,
    name STRING,
    mobile BIGINT,
    info STRING,
    created_time STRING,
    address STRING,
    PRIMARY KEY(id)
    )
    PARTITION BY HASH PARTITIONS 2 STORED AS KUDU;
    

    格式化查看:

    desc formatted multi_kudu_table3;
    

    外部表:

    create external table multi_table_external3
    STORED AS KUDU
    TBLPROPERTIES(
    'kudu.master_addresses'='10.201.0.114,10.201.0.115,10.201.0.116',
    'kudu.table_name'='impala::kudu_test_txd.multi_kudu_table3'
    );
    

    测试内外部表:

    INSERT INTO multi_kudu_table3 VALUES (1,"xj",123,"xj","20210824","xj");
    INSERT INTO multi_kudu_table3 VALUES (2,"xz",123,"xz","20210824","xz");
    INSERT INTO multi_kudu_table3 VALUES (3,"gs",123,"gs","20210824","gs");
    INSERT INTO multi_kudu_table3 VALUES (4,"nz",123,"nz","20210824","nz");
    INSERT INTO multi_kudu_table3 VALUES (5,"xn",123,"xn","20210824","xn");
    INSERT INTO multi_kudu_table3 VALUES (6,"lz",123,"lz","20210824","lz");
    INSERT INTO multi_kudu_table3 VALUES (7,"nx",123,"nx","20210824","nx");
    INSERT INTO multi_kudu_table3 VALUES (8,"nm",123,"nm","20210824","nm");
    
    select * from multi_kudu_table3;
    

    创建内部range分区表:

    CREATE TABLE multi_partition_table1  
    (  
    id BIGINT,
    year INT, 
    name STRING,
    mobile BIGINT,
    info STRING,
    created_time STRING,
    address STRING,
    PRIMARY KEY(id,year)
    
    ) PARTITION BY RANGE(year) (  
    	PARTITION 2000 <= VALUES < 2005,  
    	PARTITION 2005 <= VALUES < 2010,  
    	PARTITION 2010 <= VALUES < 2015,  
    	PARTITION 2015 <= VALUES < 2020  
    ) STORED AS KUDU;
    

    创建Hash分区表:此分区字段需是第一个字段,单个

    CREATE TABLE multi_hash_table1  
    (
    name STRING,                    
    id BIGINT,
    mobile BIGINT,
    info STRING,
    created_time STRING,
    address STRING, 
    PRIMARY KEY(name)  
    ) PARTITION BY HASH(name) PARTITIONS 4
    STORED AS KUDU; 
    

    多字段分区:

    CREATE TABLE multi_hash_table2  
    (
    id BIGINT,
    name STRING,                    
    mobile BIGINT,
    info STRING,
    created_time STRING,
    address STRING, 
    PRIMARY KEY(id,name)  
    ) PARTITION BY HASH(id,name) PARTITIONS 4
    STORED AS KUDU; 
    

    混合分区:

    CREATE TABLE multi_mix_table1  
    ( 
    id BIGINT,
    year INT,
    name STRING,                    
    mobile BIGINT,
    info STRING,
    created_time STRING,
    address STRING, 
    PRIMARY KEY(id,year)
    )  
    PARTITION BY HASH(id) PARTITIONS 4,  
    RANGE(year) (  
    	PARTITION 2000 <= VALUES < 2005,  
    	PARTITION 2005 <= VALUES < 2010,  
    	PARTITION 2010 <= VALUES < 2015,  
    	PARTITION 2015 <= VALUES < 2020  
    ) STORED AS KUDU;  
    
    show partitions multi_mix_table1;
    小小测试一枚
  • 相关阅读:
    微信小程序使用canvas画布实现当前页面截屏并分享
    微信小程序分享转发用法大全——自定义分享、全局分享、组合分享
    小程序条形码插件wxbarcode的使用及改进
    支付宝小程序开发——修改小程序原生radio默认样式
    常用maven配置
    Android Studio 星云常用配置工具箱
    星云最佳实践功法秘籍
    Intellij Idea 星云常用配置工具箱
    那些好用的Chrome 插件
    星云的Linux专用学习手册
  • 原文地址:https://www.cnblogs.com/txdblog/p/15210287.html
Copyright © 2020-2023  润新知