Open zolting opened 3 days ago
Managed to fix most parsing issues by simply using serde_json
but there are still some edge cases
pub fn string_array_to_string_with_escapes(values: &[String]) -> String {
serde_json::to_string(values).unwrap_or_else(|_| "[]".to_string())
}
The pinax fork of substreams-sink-sql now supports
Array
Clickhouse types, but the current implementation implies :"[123, 345, 678]"
or"['one', 'two', 'three']"
row.change()
call withsubstreams-database-change
Rust librarysubstreams-sink-sql
then JSON unmarshals the array string to then insert the array into ClickhouseThis approach works perfectly in most cases, but fails with arrays that contain strings like :
Program log: Some(AnchorError(AnchorError { error_name: \"AggregatorAccountNotFound\", error_code_number: 6028, error_msg: \"Aggregator account missing from provided account list.\", error_origin: Some(Source(Source { filename: \"programs/switchboard_v2/src/actions/crank_pop_action.rs\", line: 150 })), compared_values: None }))
In this situation, a simple solution could be to simply make a
transaction_log_messages
Clickhouse table instead of using alog_messages
field in thetransactions
table, but this comes at the expense of making the schema more complex than necessaryOr, if it's not too much work, adapting the substreams-database-change library and substreams-sink-sql so that it better handles arrays could be great. Maybe a method like
change_array()
?