Skip to content

Commit

Permalink
Cir1857 (apache#175)
Browse files Browse the repository at this point in the history
# Checklist

* 内部Jira: http://39.106.86.136:8090/browse/CIR-1857
* 修复PR:
  * master: apache#18042
  * 1.2-lts:
  * 1.1-lts: 
* Doris-master:
  * [x] 已修复
  * [ ] 未修复
  * [ ] 无问题
* Doris-1.2-lts:
  * [ ] 已修复
  * [ ] 未修复
  * [ ] 无问题
* Doris-1.1-lts:
  * [ ] 已修复
  * [ ] 未修复
  * [ ] 无问题
  • Loading branch information
sohardforaname authored Apr 27, 2023
1 parent ad9122a commit 39375bf
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 0 deletions.
13 changes: 13 additions & 0 deletions regression-test/data/usercases/ZH/sql/test_1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !test_1 --
1 \N \N \N \N \N \N \N \N
FymhGD9L0LfIdmAin3CIgASFUcyVZFyoOvVrz 1 \N \N \N \N \N \N \N \N
HKhQggHGzaUw1bZTkZx5XCReGwp1 1 \N \N \N \N \N \N \N \N
K3ITmdVeloEGgLTZMS0rXecAJjCs4X6opmM 1 \N \N \N \N \N \N \N \N
OIKbf1K4eDnAn1L7DtQ 1 \N \N \N \N \N \N \N \N
RKYDZQHtDj1f0eu9UcD5R 1 \N \N \N \N \N \N \N \N
RiTTMw0MouCUGg0YB5G5fZKNTPGhY4DOlZgwA2cKLP8iq 0 \N \N \N \N \N \N \N \N
V0BZw6sl 1 \N \N \N \N \N \N \N \N
ptUuvBhaywR4xpJySE3cZqjr2lwHX5elM 1 \N \N \N \N \N \N \N \N
total 8 4 0 0 3 0.5 0.0 0.0 0.375

18 changes: 18 additions & 0 deletions regression-test/suites/usercases/ZH/ddl/ads_buy_teacher_full.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE `ads_buy_teacher_full` (
`create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP,
`teacher_id` bigint(20) NULL ,
`front_sn` varchar(50) NULL ,
`front_spu_en_name` varchar(50) NULL,
`front_school_line` varchar(50) NULL,
`later_sn` varchar(50) NULL ,
`later_spu_en_name` varchar(50) NULL,
`later_school_line` varchar(50) NULL,
`second_deivce_register_time` datetime NULL,
`register_time_diff` double NULL
) ENGINE=OLAP
DUPLICATE KEY(`create_time`, `teacher_id`, `front_sn`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`create_time`) BUCKETS 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
CREATE TABLE `dws_iot_teacher_thing_sn_full` (
`teacher_id` bigint(20) NULL ,
`data_source` int(11) NOT NULL,
`regtype` varchar(50) NOT NULL,
`country` varchar(64) NULL DEFAULT "",
`province` varchar(150) NULL,
`city` varchar(64) NULL ,
`state` int(11) NOT NULL DEFAULT "0",
`lang` varchar(30) NULL DEFAULT "" ,
`invite_code` varchar(11) NULL ,
`invite_teacher_id` bigint(20) NULL ,
`source` varchar(50) NULL ,
`oauth_source` varchar(32) NULL,
`deleted` int(11) NULL ,
`relation_id` bigint(20) NOT NULL,
`sn` varchar(50) NULL,
`school_spu_en_name` varchar(50) NULL,
`school_sku_name` varchar(50) NULL ,
`create_time` datetime NULL ,
`update_time` datetime NULL,
`thing_flag` tinyint(4) NULL ,
`first_sn` varchar(50) NULL,
`first_sn_spu_en_name` varchar(50) ,
`all_sn` text NULL,
`all_school_sku_name` text NULL,
`all_school_code` text NULL,
`all_spu_en_name` text NULL,
`all_distinct_spu_en_name` text NULL,
`thing_count` bigint(20) NULL
) ENGINE=OLAP
DUPLICATE KEY(`teacher_id`, `data_source`, `regtype`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`teacher_id`) BUCKETS 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
);
56 changes: 56 additions & 0 deletions regression-test/suites/usercases/ZH/load.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

suite("load") {
sql 'drop table if exists dws_iot_teacher_thing_sn_full'
sql 'drop table if exists ads_buy_teacher_full'

def tables = ['dws_iot_teacher_thing_sn_full', 'ads_buy_teacher_full']

for (String table in tables) {
sql """DROP TABLE IF EXISTS ${table}"""
sql new File("""${context.file.parent}/ddl/${table}.sql""").text
}

sql '''
insert into dws_iot_teacher_thing_sn_full values
('2104456658','8894','1lDdt','Macau','g2G0E3IMZl0OKga0L6ojV0CAyZ82Yr4SBwyq8BvFXgI1IwmLdIshPIVaeVzlBDyldN3jDSr5oiLL5fCQTeeGkNhrS851Hn02tJczw9ArJi00CcwfngV4zJHrrFaSvipWQsKtzxlfh','GFM2Rj31bWerw0W1hEp','-14768',null,'UfIY','-1569810066','6nKJ69hCKuLOUBBYaA7SpfwpIl9GrOXyMr7lAMoX','LHkb554ahwZSjeRf','12362','-23966559','olZX46ZMzrwDCvyasxUGMlV','RKYDZQHtDj1f0eu9UcD5R','bRtWhwUqG38ZuHp3rinH1jDXOXpYYpcWRypPlA','2022-11-14 19:25:05','2022-06-17 18:34:36','106','UfbgZGr6','jqOX84WoBlo','R2VZBVo','K6LxkRRRHyDoqKiTELfefWVwLLtIvl5','3u9xldmxTH93SyIHZbAbakPLWbhxF24tVM3lzT2yi5ECqxo8xOrg6ELrSXRzN1','aufHSJrtuBoX3BeF1RG78qstm9Q1P5SShqgw7LrKZcTPttHzP74cICtGMJRM2fxxO0bgZKzpNjz11yMjw','uV','1427391251'),
('983931186','-15784','kuV7H4x18wLDiNXiCINhxdF0D66oxHXXj6J','Vatican City State (Holy See)','FFzOPyFzDfUyrKS5JdyHksa4I9TFuJR5ceTshnsW86nJQRpy4BjBLxi4USlP5NFLh5KC8wzh3Al254nAqEzYIpn9NQAK8','PzMveB1xOZIq8KjKqRCBzoLm7ltZBPNVgmCTgqIZxDQg9ihC','-27508','BP5w7','TLlfGmG',null,'I15Amd9B46sIE7wJMtw3lKfrESbQYKjDMCCB7l1qoLFXmNq6','PUCmuzvjaAF6vnFjLK','13267','2000592234',null,'V0BZw6sl','nv1foCUgJpu','2022-07-08 11:25:29','2023-04-10 18:53:52','75','oMs5NLHn99Xzotfe2lo6fcxQ4CxoMaOLBOnC3TNw00','DWQ6UFf4KEGg89J','VS8G957Ak9xLW1XdHUeSxVPanHeaQ','pxqpBxEVEoYNUUVtLkgJWG0kelN2jggV7OkA37jjmZipoCC2kg3X1ckZaWXxm','tfFJVCaRKul6WmilCRCryEtWodiwiUsCRDZOcwNQQwugQf6oUjmOKDiz5Giqk8Few8mP7m0zM1h94uBYCXHedcLzl1fIltHKWiN69kwVZzcEs3eNywyD','uaPKDNLbIzbcxR45oYxtjsQz3YahefY3lMTxrIKQArVDr5gCxNC7','7b5n6K8GZ4eNpg4Ow9qjwnHLCDa5CJHq3Mi9UGYx7VT4kPHsG6Z7cgJgsiAodJ7NUrUEmQRwvgY','38887701'),
('-1078290962','-29587','SkW09bFfPX6vooqnmTSeqRk8vA','Western Sahara','TYq1L9IfEaIxdBxEVKVF83NNOiDCbqCXJUXWwEbfM3VHLpZRGhPX41b713qgruKhLt7AjxnNYHE5836QYBhWN1B5QSl','xCO7l82vFcvIqRLMXXZlTJyeojEmQ','424','po1pDDjJEyvtBVEy4AjmLF02T','Xg8v4iRcl',null,'3PbSyhUCkar1NgMwXPxOqLDOQ7bE5ljwaxJTj','M7mY3q1gvJPzYVF0VovXIfdJT1VN8wQ','12681','146739679','UQPwDH8YwSeoBzB4JVtp35v8AF6KvYjWQcv','K3ITmdVeloEGgLTZMS0rXecAJjCs4X6opmM','ySVQznME1tjMl7FEMtqY2OV','2022-11-08 15:43:05','2023-02-23 21:35:45','-98','5l9YSl7fb5mzntuqJRdXiKSUTO','feMp7gT09','3dwQfAzktjk24OQft1iV56ap4yuDx2KWGPw5cBMZF1WrshUFUHDra5r',null,'VifCXJVCphkTYQVwkFSCcqiVLLak8FMY5r5nOKeC','FMsjOS26mzRr13bdC7WwJEkK59o21zdPMM4lv7lGpx1bA0N3w1OZVVDQuq8Xr8Hpw7K8hXCmlrpVBi13CsZw','jiZ9j2UdOFhadkMMadGPcNA1Pdc0PCMPD6RFseyItneclPHRBGcndPRPWBir049xdhddIwrEEAJxehpgSOvdYmYaRjK','606931147'),
('1098541480','-26313','rinoXRMYJ4skNez2qAoZpI7WgJ40IEmdnlOHx','Luxembourg','uLF8KIQ1xU0nLUDaMly1s3CAyI6R3EJmVjFGuWdIAQ0OXUQ5Pz','p4VOnZsfSCoYt6i9ETRpMS4qf','5586','xAq8H','zYnkwu6J','-751288708','yy8jHgLGf0dhd2','vxTKMozFdXY','-10644','-2098536365','5VSmCDkL94JyzgdfZz','','D7ILxReJ7wYf5HpXUZp9eReuW8K2ZLAGSoSKVqxKb1gfRbyB','2022-05-23 10:53:10','2022-11-04 21:02:07','67','NTalfNZEuVpzRPs0UV05XNEOg829Zeg2mEv0Gpy',null,'k2oDikt0phimq0uTxreggzzNgoIPxPwoigPejdbIHlzcvtcmcaTMuiRjSBShF','oMkBhL8f9c9gRb7sKYZq4DZpmgxNFXscGB9GSemfp4S1KyiqnyDfFl8jZnal4A','qehq2NGFfh9dLHZLfW2R0IiGEKEq0VwCyC0sK','Q5oixaodXs68zaLAyMjH0yoJdQMF5M6ypv6POrWMV87jQMjX2YnNPZknBZdn03IHR','NXgPtkwxPowRtQzlDJqHmizdoGiqi4vi3F7Wz2cp1G9','-2028431231'),
('-1177033011','28679','Djut13eNTJGQXEVvsprRTjB6fxmT8B3IwXrDHq','Spain','IlpzZWV0Iw6igCiglni15IHlh5mMX6qRUofsnVPbE0GjpimCGuqI6FYkq86d7f2csouCOj9cTteq5cZXlIcS8scTSXuhRYogEjCoD7rkFDDoQC6Wr5DnNBOdXYzmhN1Gw9EiWaiQwEXegHQ','ETyIRPorFmfYVWMwl0bYK4YhqsXz','6085','n','MGfStMG','43950395','Uxs4MPDEhbYbr','wi6IBafD','5782','9116794',null,'OIKbf1K4eDnAn1L7DtQ','jpizWNY7fULA6IgKym6DXvQmYAxCA','2022-07-01 12:22:32','2022-12-02 14:02:11',null,'VPt8nmuGt7RMmtF8fdORz5p49e8wXiMQzztszklUruX','KtXgh5YDH9hd6YFxz','ld0fILLr2dD4xiNcV7zTUQf54EejKtzOv0KU7WFaPP6O0BbSivqmB4fLKLQxRvhuvVjbfXVehmXHqD9WGGUpUefrZPBLiERtJr0VJCQPnnakMmME1NDQIOtzkPuU6R','ZbtDowe6P4sU37Pwbh1nqFnBMRqLnPDTrg3nxddWGFGmpQ70rx','Lx26XKXApR3vNr54TaJUDNT49ZsRZNlqTNevWiDODzTNRsEV9SVg8NWI1C3eASSJJf1ulmyiBvHVQNCRf4fohVGuPKYWo64yBD','UbhMgG9HIqhFO5q3ZilXvOKKz82dKD5TiZiD7f87n4DEjw7aQBN9MaYWCtY3skeRe4a9fsm6fIqDcfkWgcW6S','lq0BumdQwgk9pgfyp3EQoE50BdblRUB0dn6SP5cyjEtGpoKwodPviRCKanxsMXeRpsk49EOYCDgfRiXrD37RcySNIZI8eu2vu','-1530827657'),
('-2099530304','32584','a7hLJrw84V4VggRmpL3VovpyDl1iFuw','Bahrain',null,'st6Xa1NSoOWrjFY3qUUvwWuhvZohBvDB3EmTbsIAF5gLU','17228','zMu6MDeJn5HA2Xq5XD738','aRqpoWolc4','-810022656','2ddhS4cjEb5F','wGC90qzuC3C5SGXvgRt72Cs9jg8cpil','-9351','2012757591','9ZKygQbuacW0R','HKhQggHGzaUw1bZTkZx5XCReGwp1','mu0VX5gkXSAQO8yhDxoGg3CBktbPBrR2Uphgw','2023-02-05 00:53:33','2022-11-30 17:54:45','102','s5ULhiuflDe94NZxwApbu','V8wK5NZqjxCaQgVqTv1xxSTKoCGKTYhbigpjjdtzPR','mQAKapHnQmZgkYC99QglJUMROdTigcdSOqive85nk6U1','uzXdTSQpXvdgywAdEbGbHQEYWZhxKUCYKK','O3SPYXnJk40j31fp1l9552x7VkB4F7YQNc23j0ayjkhES6Qd9BeLYBeGn0MR72ZMkCNoo6Ewjy','5d4jxx9p6jvHYCAIP9YOMf7BgDgFzjNRwXragLVIjjChkXy0buIMtdaVhEBhy7uNJ8JnvGm1QZl30kIWiFQ6y3jSYFlYlZQ6Ls1mReSiF7','3ZwR92UEEg0SjFnMrzNCiA1VL1pOBZ4p6FvCrClZgqYyt0AoPajMfs','-2146812987'),
(null,'5480','BH4028Ogkw0YZg2FS6oiIXCnNHJ1RPhWXoIVn','Maldives','jgDtiYchEuVQO1HOxYDqYPtqgf5dlAcnZF8WThfi8O73dCQWLeBsWAAZ6Rfxz','lQuKuZ90Q9wahxX5MUWVl0OBOuFUEyEA6EzBJWJop0PPO1h5in11cRBO6W','-14566','5DMWfuVtz6hzqcBHJJDh','M14CEUL','1729084642','BNfvZwH7rbT4XldI','ip','-29574','1944060679','IpuXjzZCP','RiTTMw0MouCUGg0YB5G5fZKNTPGhY4DOlZgwA2cKLP8iq','hHGGmAhgb5K','2023-04-09 19:41:17','2023-01-18 14:51:02','-89','q70','zE0MDvtKI1UTBB09aQFQA','16XJE','wJcBiaBGYdS1a7tzJ15WTtEW2CuknQ6OjfNU2PHu4WfGxZkb8WJ1U63GmZhR','X1EsXjFiMHM4NydFHlNZdrS','SSKfdPBmjd1kSOiQuW0Rgo2QX6wwAv9ta8aW5OpD8y3YelCkvfsBjeuMIaI0bptoup1hI8mp2ZsvYmqW','qucpwcqXmEzxnr3c17rh12YoFxh5DQ5C0c6b9WzjbIFwvZ7Krt7sb9rq0qEhlRvqAAeCq1Ze2qoz','-1544524061'),
('-1513847151','-6580','8cHXQqorZeTvALi5pa','Taiwan','ZXe7p99eM6zHOZel3sVj3sg69Fa4b2vdB6skDf2eZd0IXGMkhBgtFwXAiKLJ8xhhiJyRmPIOVzAJkULKuKE8lUMECuOFwC2N79IogeltGDisAe2FB3RuGRWmKSWHgF13MQxJHK7KpHP1R03','1mFQhyhADR6LNN3ZLCiviRzHZKetPsiQep','-21319','VVa8','icuvJ','323418782','f5r8WOwB8rXgdWRJ3n1d0Q23iYIGJLx46Nveui','m1mNR','-31643','-1760705084','NUDlVE7NLp287wlF','ptUuvBhaywR4xpJySE3cZqjr2lwHX5elM','k8RK3YBhV5zmMx2','2023-02-09 22:09:27','2023-02-07 08:45:19','63','J960vqfvld70BQjaERMjvPBp','EjjCnulqNGE7XC0','ebRLTy4MzeeJ7GgIeYp9TCqxn9cQAv94wuky01SigHF36TvocFQXh5RDXhRGHwyYXRU8sho9CEon6X58AnFcCJ5','UTX3wYJaQny2UUcA9KA6SPdEqu7d98VlCQkwMeibNY2vWNQRwLwvv2YCMyigEZ6bLDSUsLuU0eM92Acf6c4ju','VIgG2SbRt00RPV5bgE7GwtHnilDJQJUaWVBjdYls2g6zw3he3kPz3kttvBDlswks3OmTeoEPRWpf61oIObBoulDuIF85REQHrF69UlCVOmf5gVb','jnuspZeYuJNnwRfbD4IfbGoU154AhD6ZweiWqNt8qzu93WqBVQrmymyr75xDv0XDZflu8qRBDBGt8','BKxK6xsPNOHpqLJJ2qfHBTfx2M5xh7qSc0pq9P4teomkBP8j6iRLcczIPcHir0s3P','-801928814'),
('13384638','-22468','usdTQpLs712K1nzJoIwOE','Uzbekistan','TINeJ3qpjIlEJiCVJmzCGSS6U4NHgj01SPhdOwpw','nRU4MSJy1aHA8KUofEU98RFS61NI28wzTiey0ByglsvhDh15qK8Ex65j2pt3qjQ','-16922',null,'ZrtHEQM4','793784940',null,'Arkt6JLdpIyta4jW3b1klh0r','-26467','1017742506','8JCvG11K44KRXYNLwCOBh1Zt2k9L9l','FymhGD9L0LfIdmAin3CIgASFUcyVZFyoOvVrz','uNzxAihk5qstzYBCeArK2OEwP4xr2CNw5NUnmY','2022-08-21 10:15:58','2022-05-13 19:18:42','14','bhNP3vwFzvE56','H058ommIGHaFM6tvvswUjKHUTcHVqzVIg0','RBiCv2pCQ3IcWiE28X7QCo4edfG1tWMjYnhHstkqW760O61KA0gZriDnHEfYmQo7I','PxPgFCvAZGncIFoKFB2KVvANUYTuZTzumedIg0LWIpMK1pNdYbdbCNiWnfvlHw2L3ifm63qogb6IAGN6hOYDdAkhZ3guCVjVcc94IM','RM3zXhfnCLDgBMQVS5hysT025BK2PuHcYiSp6EFasTpw6IbxLLN7wtSSINFeoX8jPr6F4ilu1kGJxes71EKhPMY2lwO4DeIDDnvzvJJsQsHrXPnq','vOwKGBcntCklKqbBznvQaKIdbcf8OIE6XVRtd5jBM','abPUJgr4H','1755443205'),
('-173387572','-27633','QoPy3IDkRdmjBg8SHfTkTXnHV','Central African Republic','LHlGN6V1vES8GWzDsh4tjgbjkg2KDeYHlWj20LBRDqv3g9K1EG6YvlkdjPcszrbqgzOe1fdnXHECtPPW8opfA3ph1HVyrCSC1h3owcFNIqfudFHbcDhvIX8KEbthRzSBFe9RRKJpJUn','rDKB9vBYNwRWq7PI7mP','10820','rWYty3hJoagUVethSAJwAWjN8un','5zHYwhOSY1w','1704252031','HffbFNcsa1UtF4rYVPj7yN','KWJOQ8uPvwbApsKUSj','7102','-1405614685','b2JQbcUMKKBDzuv8ts1',null,'qL2MDswqwu2mVzJgZNmZwYt0gOnD','2022-08-28 10:03:54',null,'10','ol','1xvKftvePiWW500929ZMnvh6U5C0MCAhv','TDXboQRHOBkmSqSheMI4uZfLqLOCWDZRAPOY4lTS3WDLtV00lSCF7HsK2p1Bk9wnF5l5fUcEzeL1OnwwXghhHxMs1iGMwDRDeaDtP',null,'55czgasa6BCyCVMvos8VvrDL0VPLMxI59hCC17hRj9irbAAjOnVf67nHMuL','n2E05nEOw4N5be3gjmu3Lb0RT9uH1u05Vy3jwIpbbHzqa','Wxg1t5zAfl','1095437988')
'''

sql '''
insert into ads_buy_teacher_full values
('2023-02-27 16:03:15','-1268790230','nYcHIECKk2hgH','6Lp2POJTeOXdeSd6du2DoDurpb5MCXpkzWH7tC1S3sJUsX','7th40W9BE1PqDhx7D6YwxTLL7GSCbhH3','sLGbqG5dPdp','saX9rmmYKIeMi3GuRhcSCNaLxCtQoBJDTEziswweV9UGTI','KoSbsiD0ha2PQJI57xO2aEPZjy','2022-12-08 19:36:49','-645258810.788697'),
('2023-02-27 17:33:49','-397274183','d2F2WxsY8jQOyXAPiloMgJJQ6DXbcahiAODTgZgddwILR','Na21gM3cZCy72ecmfzFZ4g2WTOACUBKkYspfp8Bx2bEe','IC0ABs9UV5LHJQOSe3sVMdRKbChX','56boxNYYr6jObt4yh20yr1yt','5','MZv6BDtFDHIC2TsJzghFYXjI8Apy0PFXlti9KeNmK',null,'1109588887.968010'),
('2023-02-27 17:11:06','1171588148','ZDMcl9Hkq16P1vGERlDtHyniIiEftHPCcnmdp','NpLF7wxMPRFUM2DsUjiORjNDYHOQsYf4JAOp2alkipwYg','0','WoKS4UdkH7X5x6hwA4dwrb0NZ','KOzlUlHnkeAwGSJblWYGk8bqJVg','2EVQp9gWKSmy8YBt1NZuUI7KPXr1Oxyp','2022-10-15 21:14:27','1783331195.330720'),
('2023-02-28 04:41:17','-1302827874','F8Nq7','DsZkav6AC4W0ptsP330tY29WdJs5F','Qw6kdoKhPV','CblZOpyatQCzVr8JADGTia7PzxMYoTgqPehgIH0786PhHnj9TB','9YPr9XdeZ5gAdJTXDYK','NJtpHmcB4NEF9Wdq2tlUVLO7l3Jvh4YOr9RuCsHP3NPFfClsLY','2022-06-17 11:12:24','-429672981.730893'),
('2023-02-28 02:47:56',null,'n5xnehmdJK4l9msQ',null,'EGIVTe3yVqNfObfepQsGoXnTASAWsk32DMmwjwg0U0Bu9Wn7l','AW0ton7gUna','hS3ICSr24Dt7fp2WMchnRifsoJO3BDkj5JXtvPc','0rY7EVwAc7wdqq36fTnT498daqE00cPluxG6FLTDRuVC','2022-07-30 02:16:58','1554801168.079804'),
(null,'1696460143','npV1L','X6tN2C4FrkYC','vzukIIvF4bV8FzDoX','FlzFSgQKCVWHsanu0ZUOFKGgB93h6wkYWcuef7bD','YStZJDXQGIC5Y7cbBOLhA6mK2C42HCUbLOmD','xks3uwCe7NNuFyo','2022-07-19 00:26:55','-97942572.917269'),
('2023-02-27 04:33:16','-1296346851','Cyz42r115y','2ikeIQ4Diiuc1VePYPJo01ATKVPoyj09','RsX8hBq4lulBjNhSknQkEETOZFMQ5Nqptrb','L25Mskmgy4kMpTAkswZP4gpI9ntVUXLT','a2m5d','wQRchUNMiGTBJ','2023-03-23 15:38:18','-1466567709.605364'),
('2023-02-27 10:59:05','-1994853739','SPVlRx7Vq9dO7WmDUMh7QgNQbv70xKV9fD7341mdBBc','9MhDjFoa6c3KqA','1Im38Hu','9oDf5QIT3iuDwhnv64PIQNsXx7cHNIe2ozqpRpLvM7O','pCrIssrOtCmOvbeSlgW5KbqtomSUEddtrmjzdgchfWJLDN8H6',null,'2023-04-13 18:56:20','2070213097.583434'),
('2023-02-28 01:05:48','716130520','','s4S6UrHakUyasZJHwP57NQZoBJ','FJ4hgJw2xhI7qsip32','Rhn','Y174V08q1tLnz1ZFd7DKpZzgtMnZIRyfcImdwwSLHVL','35f2Snbd3zLdF',null,'403767916.222701'),
('2023-02-27 01:00:46','442952892','Pjja9degSZ0udzOQXnlI23AAheB0FlVe1gf','GeGfN3kbaCIvkUG5ZYMTK4zMCfuAkKYIp1uwkIA','PmLvISXT','7sHoJU6HB9WboWW','RIRUIerV0W0kzoNkUhb6D0bTS6dEj','ZZiZm6a43OeQy38X7a6YZNpP','2022-05-10 09:41:25','-28567089.592444')
'''
}
89 changes: 89 additions & 0 deletions regression-test/suites/usercases/ZH/sql/test_1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
select * from (
select teacher_history.school_spu_en_name as spu,
teacher_history.teacher_cnt as `历史累计用户数`,
teacher_sum.teacher_sum_cnt as `总复购用户数`,
teacher_function.function_teacher_cnt as `功能性复购用户数`,
teacher_series.series_teacher_cnt as `跨系列复购用户数`,
teacher_eco.eco_teacher_cnt as `跨生态复购用户数`,
teacher_sum.teacher_sum_cnt/teacher_history.teacher_cnt as `总复购率`,
teacher_function.function_teacher_cnt/teacher_history.teacher_cnt as `功能性复购率`,
teacher_series.series_teacher_cnt/teacher_history.teacher_cnt as `跨系列复购率`,
teacher_eco.eco_teacher_cnt/teacher_history.teacher_cnt as `跨生态复购率`
from
(SELECT school_spu_en_name AS school_spu_en_name,
count(DISTINCT teacher_id) AS `teacher_cnt`
FROM dws_iot_teacher_thing_sn_full
where school_spu_en_name is not null
GROUP BY school_spu_en_name) teacher_history
LEFT JOIN
(SELECT front_spu_en_name AS front_spu_en_name,
count(DISTINCT teacher_id) AS `teacher_sum_cnt`
FROM ads_buy_teacher_full
where front_spu_en_name is not null
and register_time_diff>1
GROUP BY front_spu_en_name) teacher_sum on teacher_history.school_spu_en_name = teacher_sum.front_spu_en_name
LEFT JOIN
(SELECT front_spu_en_name AS front_spu_en_name,
count(DISTINCT teacher_id) AS `function_teacher_cnt`
FROM ads_buy_teacher_full
WHERE (front_spu_en_name=later_spu_en_name)
and register_time_diff>1
GROUP BY front_spu_en_name) teacher_function on teacher_history.school_spu_en_name = teacher_function.front_spu_en_name
LEFT JOIN
(SELECT front_spu_en_name AS front_spu_en_name,
count(DISTINCT teacher_id) AS `series_teacher_cnt`
FROM ads_buy_teacher_full
WHERE ((front_spu_en_name<>later_spu_en_name)
AND (front_school_line=later_school_line))
and register_time_diff>1
GROUP BY front_spu_en_name) teacher_series on teacher_history.school_spu_en_name = teacher_series.front_spu_en_name
LEFT JOIN
(SELECT front_spu_en_name AS front_spu_en_name,
count(DISTINCT teacher_id) AS `eco_teacher_cnt`
FROM ads_buy_teacher_full
WHERE ((front_spu_en_name<>later_spu_en_name)
AND (front_school_line<>later_school_line))
and register_time_diff>1
GROUP BY front_spu_en_name) teacher_eco on teacher_history.school_spu_en_name = teacher_eco.front_spu_en_name
-- where school_spu_en_name not in ('RIVER Pro Extra Battery')
union all
select 'total' as spu,
teacher_history.teacher_cnt as `历史累计用户数`,
teacher_sum.teacher_sum_cnt as `总复购用户数`,
teacher_function.function_teacher_cnt as `功能性复购用户数`,
teacher_series.series_teacher_cnt as `跨系列复购用户数`,
teacher_eco.eco_teacher_cnt as `跨生态复购用户数`,
teacher_sum.teacher_sum_cnt/teacher_history.teacher_cnt as `总复购率`,
teacher_function.function_teacher_cnt/teacher_history.teacher_cnt as `功能性复购率`,
teacher_series.series_teacher_cnt/teacher_history.teacher_cnt as `跨系列复购率`,
teacher_eco.eco_teacher_cnt/teacher_history.teacher_cnt as `跨生态复购率`
from
(SELECT count(DISTINCT teacher_id) AS `teacher_cnt`
FROM dws_iot_teacher_thing_sn_full
where school_spu_en_name is not null ) teacher_history
JOIN
(SELECT count(DISTINCT teacher_id) AS `teacher_sum_cnt`
FROM ads_buy_teacher_full
where front_spu_en_name is not null
and register_time_diff>1) teacher_sum on 1=1
JOIN
(SELECT count(DISTINCT teacher_id) AS `function_teacher_cnt`
FROM ads_buy_teacher_full
WHERE (front_spu_en_name=later_spu_en_name)
and register_time_diff>1 ) teacher_function on 1=1
JOIN
(SELECT count(DISTINCT teacher_id) AS `series_teacher_cnt`
FROM ads_buy_teacher_full
WHERE ((front_spu_en_name<>later_spu_en_name)
AND (front_school_line=later_school_line))
and register_time_diff>1 ) teacher_series on 1=1
JOIN
(SELECT count(DISTINCT teacher_id) AS `eco_teacher_cnt`
FROM ads_buy_teacher_full
WHERE ((front_spu_en_name<>later_spu_en_name)
AND (front_school_line<>later_school_line))
and register_time_diff>1 ) teacher_eco on 1=1
-- where spu not in ('RIVER Pro Extra Battery')
) AS virtual_table
WHERE virtual_table.spu not in('sum')
order by 1

0 comments on commit 39375bf

Please sign in to comment.