查看a表的创建语句
SHOW CREATE TABLE a;
删除表b
DROP TABLE b;
例如:
CREATE TABLE ark_us.d_stk_info_us_polygon_cik_5_w
(`ticker` String,`t_date` DateTime64(6),`name` Nullable(String),`market` Nullable(String),`type` Nullable(String),`cik` Nullable(String),`primary_exchange` Nullable(String),`is_alter` Nullable(String),`data_issue` Nullable(String),`alter_data` Nullable(String)
)
ENGINE = MergeTree
PARTITION BY toYYYYMM(t_date)
ORDER BY (ticker, t_date)
SETTINGS index_granularity = 8192DROP TABLE ark_us.d_stk_info_us_polygon_cik_5_w
select语句,group by,
正则表达式:
SELECT *FROM ark_us.d_stk_info_us_polygon_cik_1_wWHERE (not arrayStringConcat(splitByChar('.', substring(ticker, 1))) != arrayStringConcat(splitByChar('.', replaceRegexpAll(ticker, '[a-z]', ''))))---小写字母and(NOT (ticker LIKE '%.%')-- ticker 不含有点OR-- ticker 含有点且点后只含有一个字符(ticker LIKE '%._%' AND ticker NOT LIKE '%.__%'))and (not ticker like '%.%.%')
对于v1表,选出两种类型,只有CS,只发生CS和NULL转变的两种cik-ticker,得到v2表
--插入数据表
insert into ark.d_stk_info_us_polygon_v2 select * from
(SELECT ticker, t_date, name, market, if(type IS NULL, 'CS', type)as type, cik, primary_exchangeFROM (select concat(if(cik IS NULL, 'NULL', cik),if(ticker IS NULL, 'NULL', ticker) ) as cik_ticker ,cik,ticker,t_date,type,name,market,primary_exchangeFROM ark.d_stk_info_us_polygon_v1where market = 'stocks') as a_tableRIGHT JOIN (select *,concat(if(cik IS NULL, 'NULL', cik),if(ticker IS NULL, 'NULL', ticker) ) as cik_ticker from (SELECT cik,ticker,groupArray(DISTINCT if(type IS NULL, 'NULL', type)) AS type_list,arrayStringConcat(type_list) AS type_strFROM ark.d_stk_info_us_polygon_v1where market = 'stocks'GROUP BY cik,tickerHAVING length(type_list) >= 1) where type_str in ('CS', 'CSNULL', 'NULLCS')) as b_table USING (cik_ticker)
)
distinct ,count(),group by having
nohup python3 data.py > output_1733.log &