使用以下字段创建流
CREATE STREAM pageviews_original_string(view_time string, user_id varchar, pageid varchar) WITH (kafka_topic='pageviews',value_format='DELIMITED',KEY='pageid');
将pageid和以下值更改为大写。
create stream up_case AS SELECT UCASE(pageid), user_id FROM PAGEVIEWS_ORIGINAL_STRING where user_id = 'User_9';
结果
PAGE_26 | User_9
PAGE_67 | User_9
PAGE_39 | User_9
PAGE_80 | User_9
PAGE_40 | User_9
PAGE_92 | User_9
现在,我想要的是满足条件的数据必须与剩余的字段值一起修改和提取像这个
****PAGE_26 | User_9
PAGE_67 | User_9
PAGE_39 | User_9
PAGE_80 | User_9
PAGE_40 | User_9
PAGE_92 | User_9****
Page_66 | User_7
Page_25 | User_2
Page_41 | User_3
Page_34 | User_1
Page_28 | User_2
Page_55 | User_5
Page_77 | User_5
Page_32 | User_8
Page_60 | User_4
你能帮我解决这个用例吗
步骤1:已创建流,条件是更改user_9 的pageid的大写字母
create stream step1 AS SELECT UCASE(pageid) AS upcase, user_id FROM PAGEVIEWS_ORIGINAL_STRING where user_id = 'User_9';
第2步:然后通过排除user_9 ,在不改变所有用户的任何情况的情况下创建另一个具有条件的流
create stream step2 AS select pageid AS upcase, user_id from PAGEVIEWS_ORIGINAL_STRING where user_id != 'User_9';
然后创建了合并两个流的另一个流
ksql> create stream merge_two AS select step1;
insert into merge_two select * from step2;
结果
1544165217141 | 50671 | Page_35 | User_2
1544165217103 | 50661 | Page_10 | User_6
1544165217580 | 50681 | Page_54 | User_2
1544165217699 | 50691 | Page_45 | User_6
1544165218104 | 50701 | Page_20 | User_8
1544165218511 | 50711 | Page_13 | User_2
1544165218931 | 50721 | Page_45 | User_4
1544165219146 | 50731 | Page_68 | User_8
1544165219505 | 50741 | Page_65 | User_4
1544165219713 | 50751 | Page_74 | User_8
1544165219787 | 50761 | Page_30 | User_5
1544165220104 | 50771 | Page_72 | User_2
1544165220421 | 50781 | Page_39 | User_2
1544165220523 | 50791 | Page_55 | User_8
1544165220645 | 50801 | Page_76 | User_6
1544165220818 | 50821 | Page_46 | User_5
1544165220781 | 50811 | Page_60 | User_4
1544165220911 | 50831 | Page_24 | User_4
1544165221102 | 50841 | PAGE_11 | User_9
1544165221377 | 50851 | PAGE_95 | User_9
1544165221685 | 50861 | PAGE_56 | User_9
1544165222164 | 50871 | Page_50 | User_3
1544165222233 | 50881 | Page_12 | User_8
1544165222500 | 50891 | Page_18 | User_3
1544165222913 | 50901 | Page_67 | User_5
1544165223237 | 50911 | Page_30 | User_3
1544165223665 | 50921 | Page_62 | User_8