Skip to content

Instantly share code, notes, and snippets.

@medvedev1088
Last active May 2, 2022 14:24
Show Gist options
  • Save medvedev1088/1756465de0ed2f68a9836e0ee477ebce to your computer and use it in GitHub Desktop.
Save medvedev1088/1756465de0ed2f68a9836e0ee477ebce to your computer and use it in GitHub Desktop.
CREATE EXTERNAL TABLE IF NOT EXISTS blocks (
number BIGINT,
hash STRING,
parent_hash STRING,
nonce STRING,
sha3_uncles STRING,
logs_bloom STRING,
transactions_root STRING,
state_root STRING,
receipts_root STRING,
miner STRING,
difficulty DECIMAL(38,0),
total_difficulty DECIMAL(38,0),
size BIGINT,
extra_data STRING,
gas_limit BIGINT,
gas_used BIGINT,
timestamp BIGINT,
transaction_count BIGINT
)
PARTITIONED BY (start_block BIGINT, end_block BIGINT)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ',',
'escape.delim' = '\\'
)
STORED AS TEXTFILE
LOCATION 's3://<your_bucket>/ethereumetl/export/blocks'
TBLPROPERTIES (
'skip.header.line.count' = '1'
);
MSCK REPAIR TABLE blocks;
CREATE EXTERNAL TABLE IF NOT EXISTS transactions (
hash STRING,
nonce BIGINT,
block_hash STRING,
block_number BIGINT,
transaction_index BIGINT,
from_address STRING,
to_address STRING,
value DECIMAL(38,0),
gas BIGINT,
gas_price BIGINT,
input STRING
)
PARTITIONED BY (start_block BIGINT, end_block BIGINT)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ',',
'escape.delim' = '\\'
)
STORED AS TEXTFILE
LOCATION 's3://<your_bucket>/ethereumetl/export/transactions'
TBLPROPERTIES (
'skip.header.line.count' = '1'
);
MSCK REPAIR TABLE transactions;
CREATE EXTERNAL TABLE IF NOT EXISTS token_transfers (
token_address STRING,
from_address STRING,
to_address STRING,
value DECIMAL(38,0),
transaction_hash STRING,
log_index BIGINT,
block_number BIGINT
)
PARTITIONED BY (start_block BIGINT, end_block BIGINT)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ',',
'escape.delim' = '\\'
)
STORED AS TEXTFILE
LOCATION 's3://<your_bucket>/ethereumetl/export/token_transfers'
TBLPROPERTIES (
'skip.header.line.count' = '1'
);
MSCK REPAIR TABLE token_transfers;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment