Skip to content

Commit ac812a0

Browse files
committed
schemas/aws_partition_by_date: schemas updated to JSON format
Sponsored by CoinStats.app
1 parent 1711d2e commit ac812a0

File tree

5 files changed

+50
-68
lines changed

5 files changed

+50
-68
lines changed

schemas/aws_partition_by_date/blocks.sql

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,16 @@ CREATE EXTERNAL TABLE IF NOT EXISTS blocks (
1616
gas_limit BIGINT,
1717
gas_used BIGINT,
1818
timestamp BIGINT,
19-
transaction_count BIGINT
19+
transaction_count BIGINT,
20+
base_fee_per_gas BIGINT
2021
)
21-
PARTITIONED BY (date STRING)
22-
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
23-
WITH SERDEPROPERTIES (
24-
'serialization.format' = ',',
25-
'field.delim' = ',',
26-
'escape.delim' = '\\'
27-
)
28-
STORED AS TEXTFILE
29-
LOCATION 's3://<your_bucket>/ethereumetl/export/blocks'
30-
TBLPROPERTIES (
31-
'skip.header.line.count' = '1'
32-
);
22+
PARTITIONED BY (block_date STRING)
23+
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
24+
LOCATION 's3://<your_bucket>/export/blocks/';
25+
26+
MSCK REPAIR TABLE blocks;
3327

34-
MSCK REPAIR TABLE blocks;
28+
select *
29+
from blocks
30+
where block_date = '2015-10-01'
31+
;

schemas/aws_partition_by_date/logs.sql

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,16 @@ CREATE EXTERNAL TABLE IF NOT EXISTS logs (
66
block_number BIGINT,
77
address STRING,
88
data STRING,
9-
topics STRING
9+
topics ARRAY<STRING>
1010
)
11-
PARTITIONED BY (date STRING)
12-
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
13-
WITH SERDEPROPERTIES (
14-
'serialization.format' = ',',
15-
'field.delim' = ',',
16-
'escape.delim' = '\\'
17-
)
18-
STORED AS TEXTFILE
19-
LOCATION 's3://<your_bucket>/ethereumetl/export/logs'
20-
TBLPROPERTIES (
21-
'skip.header.line.count' = '1'
22-
);
11+
PARTITIONED BY (block_date STRING)
12+
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
13+
LOCATION 's3://<your_bucket>/export/logs/';
2314

2415
MSCK REPAIR TABLE logs;
16+
17+
show partitions logs;
18+
select *
19+
from logs
20+
where block_date = '2015-11-08'
21+
;

schemas/aws_partition_by_date/receipts.sql

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,16 @@ CREATE EXTERNAL TABLE IF NOT EXISTS receipts (
77
gas_used BIGINT,
88
contract_address STRING,
99
root STRING,
10-
status BIGINT
10+
status BIGINT,
11+
effective_gas_price BIGINT
1112
)
12-
PARTITIONED BY (date STRING)
13-
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
14-
WITH SERDEPROPERTIES (
15-
'serialization.format' = ',',
16-
'field.delim' = ',',
17-
'escape.delim' = '\\'
18-
)
19-
STORED AS TEXTFILE
20-
LOCATION 's3://<your_bucket>/ethereumetl/export/receipts'
21-
TBLPROPERTIES (
22-
'skip.header.line.count' = '1'
23-
);
13+
PARTITIONED BY (block_date STRING)
14+
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
15+
LOCATION 's3://<your_bucket>/export/receipts/';
2416

2517
MSCK REPAIR TABLE receipts;
18+
19+
select *
20+
from receipts
21+
where block_date = '2015-11-08'
22+
;

schemas/aws_partition_by_date/token_transfers.sql

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,17 @@ CREATE EXTERNAL TABLE IF NOT EXISTS token_transfers (
22
token_address STRING,
33
from_address STRING,
44
to_address STRING,
5-
value DECIMAL(38,0),
5+
value STRING,
66
transaction_hash STRING,
77
log_index BIGINT,
88
block_number BIGINT
99
)
10-
PARTITIONED BY (date STRING)
11-
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
12-
WITH SERDEPROPERTIES (
13-
'serialization.format' = ',',
14-
'field.delim' = ',',
15-
'escape.delim' = '\\'
16-
)
17-
STORED AS TEXTFILE
18-
LOCATION 's3://<your_bucket>/ethereumetl/export/token_transfers'
19-
TBLPROPERTIES (
20-
'skip.header.line.count' = '1'
21-
);
10+
PARTITIONED BY (block_date STRING)
11+
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
12+
LOCATION 's3://<your_bucket>/export/token_transfers/';
2213

23-
MSCK REPAIR TABLE token_transfers;
14+
MSCK REPAIR TABLE token_transfers;
15+
select *
16+
from token_transfers
17+
where block_date = '2015-11-13'
18+
;

schemas/aws_partition_by_date/transactions.sql

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,15 @@ CREATE EXTERNAL TABLE IF NOT EXISTS transactions (
99
value DECIMAL(38,0),
1010
gas BIGINT,
1111
gas_price BIGINT,
12-
input STRING
12+
input STRING,
13+
max_fee_per_gas BIGINT,
14+
max_priority_fee_per_gas BIGINT,
15+
transaction_type BIGINT
1316
)
14-
PARTITIONED BY (date STRING)
15-
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
16-
WITH SERDEPROPERTIES (
17-
'serialization.format' = ',',
18-
'field.delim' = ',',
19-
'escape.delim' = '\\'
20-
)
21-
STORED AS TEXTFILE
22-
LOCATION 's3://<your_bucket>/ethereumetl/export/transactions'
23-
TBLPROPERTIES (
24-
'skip.header.line.count' = '1'
25-
);
17+
PARTITIONED BY (block_date STRING)
18+
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
19+
LOCATION 's3://<your_bucket>/export/transactions/';
2620

27-
MSCK REPAIR TABLE transactions;
21+
MSCK REPAIR TABLE transactions;
22+
SHOW PARTITIONS anton_test.transactions;
23+
SELECT * FROM anton_test.transactions;

0 commit comments

Comments
 (0)