Doris初步使用2


使用命令查看创建表语句:
HELP CREATE TABLE;

创建表完整语句:
    CREATE [EXTERNAL] TABLE [IF NOT EXISTS] [database.]table_name
    (column_definition1[, column_definition2, ...]
    [, index_definition1[, ndex_definition12,]])
    [ENGINE = [olap|mysql|broker]]
    [key_desc]
    [COMMENT "table comment"];
    [partition_desc]
    [distribution_desc]
    [rollup_index]
    [PROPERTIES ("key"="value", ...)]
    [BROKER PROPERTIES ("key"="value", ...)] 
 
1)创建表 在某些多维分析场景下,数据既没有主键,也没有聚合需求。因此,我们引入 Duplicate 数据模型来满足这类需求
    DUPLICATE KEY 是按字段排序:
    
CREATE TABLE IF NOT EXISTS example_db.duplicate_table
(
    aid INT NOT NULL COMMENT "文章id",
    title VARCHAR(32) COMMENT "标题",
    content VARCHAR(32) COMMENT "评论",
    uid VARCHAR(32) COMMENT "用户id",
    tid VARCHAR(32) COMMENT "文章类型"
)
DUPLICATE KEY(aid)
DISTRIBUTED BY HASH(aid) BUCKETS 5
PROPERTIES("replication_num" = "1");

----在zeppelin里面执行 :
%doris
CREATE TABLE IF NOT EXISTS example_db.duplicate_table2
(
    aid INT NOT NULL COMMENT "文章id",
    title VARCHAR(32) COMMENT "标题",
    content VARCHAR(32) COMMENT "评论",
    uid VARCHAR(32) COMMENT "用户id",
    tid VARCHAR(32) COMMENT "文章类型"
)
DUPLICATE KEY(aid)
DISTRIBUTED BY HASH(aid) BUCKETS 5
PROPERTIES("replication_num" = "1");

---创建成功之后我们可以通过mysql 客户端查看到表跟信息。目前表是空的

---我们需要导入数据,通过kafka实时导入,格式为json
---具体的细节信息通过 HELP ROUTINE LOAD;

CREATE ROUTINE LOAD example_db.duplicate_insert2 ON duplicate_table2
        COLUMNS(aid,title,content,uid,tid)
        PROPERTIES
        (
        "desired_concurrent_number"="3",
        "max_batch_interval" = "20",
        "max_batch_rows" = "300000",
        "max_batch_size" = "209715200",
        "strict_mode" = "false",
        "format" = "json"
        )
           FROM KAFKA
        (
            "kafka_broker_list" = "192.168.12.188:9092",
            "kafka_topic" = "doris_article2",
            "kafka_partitions" = "0",
            "kafka_offsets" = "OFFSET_BEGINNING"
        );

Doris初步使用2_第1张图片

 

---执行语句,查看过程:
SHOW ROUTINE LOAD;

| 10096 | duplicate_insert | 2020-08-14 11:49:50 | N/A       | N/A     | default_cluster:example_db | duplicate_table | RUNNING | KAFKA          | 1              | {"partitions":"*","columnToColumnExpr":"aid,title,content,uid,tid&

你可能感兴趣的:(apache,doris,doris多表join,doris使用,doris实操)