Skip to content

Commit

Permalink
Minor fixes to get BQ running
Browse files Browse the repository at this point in the history
  • Loading branch information
WuBruno committed Oct 16, 2023
1 parent 36cbc15 commit 5064f6c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
4 changes: 1 addition & 3 deletions products/pdt/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
target/
.vscode/
# Target for downloaded files
downloads/
# Stores download metadata
meta.json
data/
1 change: 1 addition & 0 deletions products/pdt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"pdtlib",
"pdtbq",
Expand Down
10 changes: 6 additions & 4 deletions products/pdt/pdt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct Cli {
#[arg(long, default_value = "/home/rrw/tmp/unpacked")]
unpack_dir: String,

#[arg(long, default_value = "testnet-901")]
#[arg(long, default_value = "testnet-925")]
network: String,

#[arg(long, value_enum)]
Expand Down Expand Up @@ -139,7 +139,7 @@ struct ListenOptions {
#[arg(long)]
dataset_id: String,

#[arg(long, default_value = "rrw-bigquery-test-id")]
#[arg(long, default_value = "prj-c-data-analytics-3xs14wez")]
project_id: String,

#[arg(long)]
Expand All @@ -163,8 +163,10 @@ async fn download_persistence(
} else {
if network_name.starts_with("mainnet-") {
&NetworkType::Mainnet
} else {
} else if network_name.starts_with("testnet-") {
&NetworkType::Testnet
} else {
panic!("Unexpected network type")
}
};
let bucket_name = match network_type {
Expand All @@ -184,7 +186,7 @@ async fn download_persistence(
incr.save_meta(max_block)?;
println!("Max block {}", max_block);

let render = Renderer::new("testnet-901", download_dir, unpack_dir)?;
let render = Renderer::new(network_name, download_dir, unpack_dir)?;
let recovery_points = render.get_recovery_points()?;
println!(
"persistence blocks: {:?} , state blocks: {:?}",
Expand Down
6 changes: 3 additions & 3 deletions products/pdt/pdtbq/src/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl MetaTable for Meta {
start: i64,
nr_blks: i64,
) -> Result<Option<(i64, String)>> {
let query = format!("SELECT start_blk,nr_blks,client_id FROM {} WHERE start_blk <= {} and nr_blks >= {} - start_blk ORDER BY nr_blks DESC LIMIT 1",
let query = format!("SELECT start_blk,nr_blks,client_id FROM `{}` WHERE start_blk <= {} and nr_blks >= {} - start_blk ORDER BY nr_blks DESC LIMIT 1",
self.table.get_table_desc(), start, nr_blks + start);
let mut result = client
.job()
Expand Down Expand Up @@ -186,7 +186,7 @@ impl MetaTable for Meta {
let mut result = client
.job()
.query(&self.table.dataset.project_id,
QueryRequest::new(format!("SELECT start_blk, nr_blks FROM {} WHERE start_blk >= {} AND nr_blks > 0 ORDER BY start_blk ASC, nr_blks DESC LIMIT 1",
QueryRequest::new(format!("SELECT start_blk, nr_blks FROM `{}` WHERE start_blk >= {} AND nr_blks > 0 ORDER BY start_blk ASC, nr_blks DESC LIMIT 1",
self.table.get_table_desc(), blk_to_find))).await?;
if result.next_row() {
let start_blk = result
Expand All @@ -211,7 +211,7 @@ impl MetaTable for Meta {
let _ = client
.job()
.query(&self.table.dataset.project_id,
QueryRequest::new(format!("INSERT INTO {} (client_id, event_stamp, start_blk, nr_blks) VALUES (\"{}\",CURRENT_DATETIME(), {}, {})",
QueryRequest::new(format!("INSERT INTO `{}` (client_id, event_stamp, start_blk, nr_blks) VALUES (\"{}\",CURRENT_DATETIME(), {}, {})",
self.table.get_table_desc(),
self.coords.client_id, range.start, range.end-range.start)))
.await?;
Expand Down
2 changes: 1 addition & 1 deletion products/pdt/pdtbq/src/tracked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl Trackable for TrackedTable {
) -> Result<(i64, i64)> {
let mut result = client.job()
.query(&self.location.dataset.project_id,
QueryRequest::new(format!("SELECT block,offset_in_block FROM {} WHERE block >= {} AND block < {} ORDER BY block DESC, offset_in_block DESC LIMIT 1",
QueryRequest::new(format!("SELECT block,offset_in_block FROM `{}` WHERE block >= {} AND block < {} ORDER BY block DESC, offset_in_block DESC LIMIT 1",
self.location.get_table_desc(), blks.start, blks.end))).await?;
if result.next_row() {
// There was one!1
Expand Down
4 changes: 4 additions & 0 deletions products/pdt/pdtparse/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub enum ZRC2Event {
pub struct MintedEvent {
txn_id: String,
block: i64,
#[allow(dead_code)]
minter: String,
recipient: String,
amount: Decimal,
Expand Down Expand Up @@ -53,6 +54,7 @@ impl LedgerInsertable for MintedEvent {
pub struct BurntEvent {
txn_id: String,
block: i64,
#[allow(dead_code)]
burner: String,
burn_account: String,
amount: Decimal,
Expand Down Expand Up @@ -124,6 +126,7 @@ impl LedgerInsertable for TransferSuccessEvent {
pub struct TransferFromSuccess {
txn_id: String,
block: i64,
#[allow(dead_code)]
initiator: String,
sender: String,
recipient: String,
Expand Down Expand Up @@ -165,6 +168,7 @@ impl LedgerInsertable for TransferFromSuccess {
pub struct OperatorSendSuccess {
txn_id: String,
block: i64,
#[allow(dead_code)]
initiator: String,
sender: String,
recipient: String,
Expand Down
1 change: 1 addition & 0 deletions products/pdt/pdtpsql/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use anyhow::Result;
use sqlx::{postgres::types::PgRange, query_as, PgPool};

#[derive(Debug)]
#[allow(dead_code)]
pub struct SchemaColumn {
column_name: Option<String>,
data_type: Option<String>,
Expand Down

0 comments on commit 5064f6c

Please sign in to comment.