forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add footprint case
- Loading branch information
Showing
20 changed files
with
421 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !sql_1 -- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !sql_2 -- | ||
2022-07-31 1 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !sql_3 -- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !sql_4 -- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !sql_5 -- | ||
2022-07-31 100.270639191 211.137623227 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !sql_6 -- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !sql_7 -- | ||
2022-07-31 100.270639191 211.137623227 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !sql_8 -- | ||
2022-07-31 100.270639191 211.137623227 | ||
|
23 changes: 23 additions & 0 deletions
23
regression-test/suites/usercases/FOOTPRINT/ddl/bsc_token_transfers.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
create table bsc_token_transfers | ||
( | ||
transaction_hash varchar(200) null, | ||
log_index int null, | ||
block_timestamp datetime null, | ||
block_date date null, | ||
block_hash varchar(200) null, | ||
block_number int null, | ||
from_address varchar(100) null, | ||
to_address varchar(100) null, | ||
decimals int null, | ||
token_address varchar(100) null, | ||
token_symbol varchar(100) null, | ||
amount_raw float null, | ||
amount float null, | ||
value float null, | ||
token_price float null | ||
) ENGINE=OLAP | ||
DUPLICATE KEY(`transaction_hash`) | ||
DISTRIBUTED BY HASH(`transaction_hash`) BUCKETS 1 | ||
PROPERTIES ( | ||
"replication_allocation" = "tag.location.default: 1" | ||
); |
31 changes: 31 additions & 0 deletions
31
regression-test/suites/usercases/FOOTPRINT/ddl/bsc_transactions.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
create table bsc_transactions | ||
( | ||
block_timestamp datetime null, | ||
hash varchar(100) null, | ||
block_number int null, | ||
nonce int null, | ||
transaction_index int null, | ||
block_date date null, | ||
from_address varchar(100) null, | ||
to_address varchar(100) null, | ||
value float null, | ||
type string null, | ||
gas int null, | ||
gas_price bigint null, | ||
receipt_cumulative_gas_used int null, | ||
receipt_gas_used int null, | ||
receipt_contract_address varchar(100) null, | ||
receipt_root varchar(100) null, | ||
receipt_status int null, | ||
block_hash varchar(100) null, | ||
max_fee_per_gas bigint null, | ||
max_priority_fee_per_gas bigint null, | ||
transaction_type int null, | ||
receipt_effective_gas_price bigint null, | ||
base_fee_per_gas bigint null | ||
) ENGINE=OLAP | ||
DUPLICATE KEY(`block_timestamp`) | ||
DISTRIBUTED BY HASH(`block_timestamp`) BUCKETS 1 | ||
PROPERTIES ( | ||
"replication_allocation" = "tag.location.default: 1" | ||
); |
13 changes: 13 additions & 0 deletions
13
regression-test/suites/usercases/FOOTPRINT/ddl/token_price_5min_90d.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
create table token_price_5min_90d | ||
( | ||
token_address varchar(1000) null, | ||
chain string null, | ||
`timestamp` datetime null, | ||
price float null, | ||
token_symbol string null | ||
) ENGINE=OLAP | ||
DUPLICATE KEY(`token_address`) | ||
DISTRIBUTED BY HASH(`timestamp`) BUCKETS 1 | ||
PROPERTIES ( | ||
"replication_allocation" = "tag.location.default: 1" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// 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. | ||
|
||
// The cases is copied from https://github.com/trinodb/trino/tree/master | ||
// /testing/trino-product-tests/src/main/resources/sql-tests/testcases/tpcds | ||
// and modified by Doris. | ||
suite("load") { | ||
def tables = [ | ||
"bsc_token_transfers", | ||
"bsc_transactions", | ||
"token_price_5min_90d" | ||
] | ||
|
||
|
||
for (String table in tables) { | ||
sql """ DROP TABLE IF EXISTS $table """ | ||
} | ||
|
||
for (String table in tables) { | ||
sql new File("""${context.file.parent}/ddl/${table}.sql""").text | ||
} | ||
|
||
for (String tableName in tables) { | ||
streamLoad { | ||
// you can skip db declaration, because a default db has already been | ||
// specified in ${DORIS_HOME}/conf/regression-conf.groovy | ||
// db 'regression_test' | ||
table tableName | ||
|
||
// default label is UUID: | ||
// set 'label' UUID.randomUUID().toString() | ||
|
||
// default column_separator is specify in doris fe config, usually is '\t'. | ||
// this line change to ',' | ||
// set 'column_separator', ',' | ||
set 'column_separator', ',' | ||
set 'compress_type', 'GZ' | ||
// set 'max_filter_ratio' ,'1' | ||
|
||
// relate to ${DORIS_HOME}/regression-test/data/demo/streamload_input.csv. | ||
// also, you can stream load a http stream, e.g. http://xxx/some.csv | ||
file """${getS3Url() + '/regression/usercases/FOOTPRINT/' + tableName}.csv.gz""" | ||
|
||
time 100000 // limit inflight 10s | ||
|
||
// stream load action will check result, include Success status, and NumberTotalRows == NumberLoadedRows | ||
|
||
// if declared a check callback, the default check condition will ignore. | ||
// So you must check all condition | ||
check { result, exception, startTime, endTime -> | ||
if (exception != null) { | ||
throw exception | ||
} | ||
log.info("Stream load result: ${result}".toString()) | ||
def json = parseJson(result) | ||
assertEquals("success", json.Status.toLowerCase()) | ||
assertEquals(json.NumberTotalRows, json.NumberLoadedRows) | ||
assertTrue(json.NumberLoadedRows > 0 && json.LoadBytes > 0) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SELECT `bsc_token_transfers`.`block_date` AS `block_date`, count(*) AS `count` | ||
FROM `bsc_token_transfers` | ||
WHERE (`bsc_token_transfers`.`token_address` = '0xa7f263b9c7e3aeb03f0b466c40480807bae6dbc0' | ||
AND `bsc_token_transfers`.`block_date` >= convert_tz('2022-06-19 00:00:00.000', 'GMT', @@session.time_zone) AND `bsc_token_transfers`.`from_address` = '0x0000000000000000000000000000000000000000') | ||
GROUP BY `bsc_token_transfers`.`block_date` | ||
ORDER BY `bsc_token_transfers`.`block_date` ASC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
WITH first_depo AS | ||
(SELECT t.`from_address` AS USER, | ||
min(date(t.`block_timestamp`))AS block_date | ||
FROM `bsc_token_transfers` t | ||
WHERE t.`to_address` = '0x6238872a0bd9f0e19073695532a7ed77ce93c69e' | ||
GROUP BY t.`from_address`), | ||
first_depo_agg AS | ||
( | ||
SELECT block_date, count(USER) as daily_new_deposited_accounts | ||
from first_depo | ||
group by block_date | ||
) | ||
|
||
SELECT block_date, | ||
daily_new_deposited_accounts, | ||
sum(daily_new_deposited_accounts) over ( | ||
ORDER BY block_date) cumu_user | ||
FROM first_depo_agg where block_date < now() | ||
ORDER BY block_date; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SELECT `bsc_transactions`.`block_date` AS `block_date`, sum((`bsc_transactions`.`value` * power(10, -18))) AS `income_bnb` | ||
FROM `bsc_transactions` | ||
WHERE `bsc_transactions`.`to_address` = '0xec38dab76a01e180431cea50e4d4d64daa882284' | ||
GROUP BY `bsc_transactions`.`block_date` | ||
ORDER BY `bsc_transactions`.`block_date` ASC |
106 changes: 106 additions & 0 deletions
106
regression-test/suites/usercases/FOOTPRINT/sql/sql_4.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
SELECT date(`source`.`block_date`) AS `block_date`, avg(`source`.`price`) AS `avg`, count(*) AS `count`, min(`source`.`price`) AS `min`, max(`source`.`price`) AS `max` | ||
FROM (WITH `melody_bnb_trade_data` AS | ||
( | ||
SELECT | ||
`bsc_transactions`.`hash` AS `transaction_hash`, | ||
`bsc_transactions`.`block_date` AS `block_date`, | ||
`bsc_transactions`.`block_timestamp` AS `block_timestamp`, | ||
str_to_date(date_format(`bsc_transactions`.`block_timestamp`, '%Y-%m-%d %H'), '%Y-%m-%d %H') AS `block_hour`, | ||
`bsc_transactions`.`from_address` AS `buyer_address`, | ||
`bsc_token_transfers`.`from_address` AS `seller_address`, | ||
`bsc_transactions`.`value` * power(10, -18) AS `bnb_price`, | ||
`bsc_token_transfers`.`amount_raw` AS `melody_nft_id` | ||
FROM `bsc_transactions` | ||
JOIN `bsc_token_transfers` `bsc_token_transfers` | ||
ON `bsc_transactions`.`hash` = `bsc_token_transfers`.`transaction_hash` | ||
|
||
AND `bsc_transactions`.`block_date` >= convert_tz('2022-06-11 00:00:00.000', 'GMT', @@session.time_zone) | ||
AND `bsc_token_transfers`.`block_date` >= convert_tz('2022-06-11 00:00:00.000', 'GMT', @@session.time_zone) | ||
AND ( | ||
`bsc_transactions`.`to_address` = '0x449d05c544601631785a7c062dcdff530330317e' | ||
|
||
OR `bsc_transactions`.`to_address` = '0x9beddcb663954b7e858fa73d28f0fc64dd7d20b3' | ||
) | ||
AND `bsc_token_transfers`.`token_address` = '0xa7f263b9c7e3aeb03f0b466c40480807bae6dbc0' | ||
), | ||
|
||
`bnb_price_table` AS | ||
( | ||
SELECT | ||
distinct * | ||
FROM | ||
( | ||
SELECT | ||
str_to_date(date_format(`token_price_5min_90d`.`timestamp`, '%Y-%m-%d %H'), '%Y-%m-%d %H') AS `timestamp_hour`, | ||
AVG(`token_price_5min_90d`.`price`) AS `price` | ||
FROM | ||
`token_price_5min_90d` | ||
|
||
WHERE | ||
`timestamp` >= convert_tz('2022-06-11 00:00:00.000', 'GMT', @@session.time_zone) | ||
AND `token_price_5min_90d`.`chain` = 'BSC' | ||
AND `token_price_5min_90d`.`token_symbol` = 'WBNB' | ||
AND `token_price_5min_90d`.`token_address` = '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c' | ||
|
||
GROUP BY | ||
str_to_date(date_format(`token_price_5min_90d`.`timestamp`, '%Y-%m-%d %H'), '%Y-%m-%d %H') | ||
) `bnb_price_raw` | ||
), | ||
|
||
`melody_usdt_trade_data_01` AS ( | ||
SELECT | ||
`transaction_hash`, | ||
`block_date`, | ||
`block_timestamp`, | ||
`buyer_address`, | ||
`seller_address`, | ||
`melody_nft_id`, | ||
`bnb_price` * `bnb_price_table`.`price` AS `price` | ||
FROM | ||
`melody_bnb_trade_data` | ||
|
||
LEFT JOIN `bnb_price_table` | ||
ON `melody_bnb_trade_data`.`block_hour` = `bnb_price_table`.`timestamp_hour` | ||
), | ||
|
||
`melody_usdt_trade_data_02` AS ( | ||
SELECT | ||
distinct | ||
`melody_nft_transfer`.`transaction_hash`, | ||
`melody_nft_transfer`.`block_date`, | ||
`melody_nft_transfer`.`block_timestamp`, | ||
`T2`.`from_address` AS `buyer_address`, | ||
`T2`.`to_address` AS `seller_address`, | ||
`melody_nft_transfer`.`melody_nft_id`, | ||
CASE | ||
WHEN `T2`.`value` IS NULL THEN `T2`.`amount_raw` * power(10, -18) | ||
ELSE `T2`.`value` | ||
END AS `price` | ||
|
||
FROM | ||
( | ||
SELECT | ||
`transaction_hash`, | ||
`block_hash`, | ||
`block_date`, | ||
`block_timestamp`, | ||
`amount_raw` AS `melody_nft_id` | ||
FROM `bsc_token_transfers` `T1` | ||
where | ||
`T1`.`block_date` >= convert_tz('2022-06-14 00:00:00.000', 'GMT', @@session.time_zone) | ||
AND `T1`.`token_address` = '0xa7f263b9c7e3aeb03f0b466c40480807bae6dbc0' | ||
) `melody_nft_transfer` | ||
|
||
JOIN | ||
`bsc_token_transfers` `T2` | ||
ON | ||
`T2`.`block_date` >= convert_tz('2022-06-11 00:00:00.000', 'GMT', @@session.time_zone) | ||
AND `melody_nft_transfer`.`transaction_hash` = `T2`.`transaction_hash` | ||
AND `T2`.`token_address` <> '0xa7f263b9c7e3aeb03f0b466c40480807bae6dbc0' | ||
) | ||
|
||
SELECT * FROM `melody_usdt_trade_data_01` | ||
union | ||
SELECT * FROM `melody_usdt_trade_data_02` | ||
) `source` WHERE (`source`.`block_date` >= date(date_add(now(), INTERVAL -30 day)) AND `source`.`block_date` < date(now()) AND `source`.`price` > 0 AND (`source`.`buyer_address` <> '0x0000000000000000000000000000000000000000' OR `source`.`buyer_address` IS NULL) AND (`source`.`seller_address` <> '0x0000000000000000000000000000000000000000' OR `source`.`seller_address` IS NULL) AND `source`.`block_date` >= convert_tz('2022-06-26 00:00:00.000', 'GMT', @@session.time_zone)) GROUP BY date(`source`.`block_date`) | ||
ORDER BY date(`source`.`block_date`) ASC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
SELECT `source`.`block_date` AS `block_date`, sum(CASE WHEN `source`.`Net_bnb_amount` > 0 THEN `source`.`Net_bnb_amount` ELSE 0.0 END) AS `deposit_BNB_amount`, (-1 * sum(CASE WHEN `source`.`Net_bnb_amount` < 0 THEN `source`.`Net_bnb_amount` ELSE 0.0 END)) AS `withdraw_bnb_amount` | ||
FROM (SELECT `bsc_transactions`.`block_date` AS `block_date`, CASE WHEN `bsc_transactions`.`from_address` = '0x6238872a0bd9f0e19073695532a7ed77ce93c69e' THEN `bsc_transactions`.`to_address` ELSE `bsc_transactions`.`from_address` END AS `owner`, (sum(CASE WHEN `bsc_transactions`.`to_address` = '0x6238872a0bd9f0e19073695532a7ed77ce93c69e' THEN (`bsc_transactions`.`value` * power(10, -18)) ELSE 0.0 END) - sum(CASE WHEN `bsc_transactions`.`from_address` = '0x6238872a0bd9f0e19073695532a7ed77ce93c69e' THEN (`bsc_transactions`.`value` * power(10, -18)) ELSE 0.0 END)) AS `Net_bnb_amount` FROM `bsc_transactions` | ||
WHERE ((`bsc_transactions`.`from_address` = '0x6238872a0bd9f0e19073695532a7ed77ce93c69e' | ||
OR `bsc_transactions`.`to_address` = '0x6238872a0bd9f0e19073695532a7ed77ce93c69e') | ||
AND `bsc_transactions`.`value` > 0.01 AND `bsc_transactions`.`block_timestamp` >= date(date_add(now(), INTERVAL -30 day)) AND `bsc_transactions`.`block_timestamp` < date(now())) | ||
GROUP BY `bsc_transactions`.`block_date`, CASE WHEN `bsc_transactions`.`from_address` = '0x6238872a0bd9f0e19073695532a7ed77ce93c69e' THEN `bsc_transactions`.`to_address` ELSE `bsc_transactions`.`from_address` END | ||
ORDER BY `bsc_transactions`.`block_date` ASC, CASE WHEN `bsc_transactions`.`from_address` = '0x6238872a0bd9f0e19073695532a7ed77ce93c69e' THEN `bsc_transactions`.`to_address` ELSE `bsc_transactions`.`from_address` END ASC) `source` GROUP BY `source`.`block_date` ORDER BY `source`.`block_date` ASC |
Oops, something went wrong.