pinax-network / substreams-sink-sql

Apache License 2.0
0 stars 0 forks source link

Issue when using `Nullable` SQL type #11

Closed DenisCarriere closed 3 months ago

DenisCarriere commented 3 months ago

Having issues using Nullable field type https://clickhouse.com/docs/en/sql-reference/data-types/nullable

CREATE TABLE IF NOT EXISTS blocks
(
    `id` String,
    `difficulty` Int64
)
ENGINE = ReplacingMergeTree
PRIMARY KEY id
ORDER BY id

Substreams test code logic

match header.difficulty {
    Some(difficulty) => row.change("difficulty", ("", "123")),
    None => row,
};

❌ Errors

✅ work around solution

Set null values as 0

DenisCarriere commented 3 months ago

Clickhouse best practices recommend avoiding using Nullable fields https://clickhouse.com/docs/en/cloud/bestpractices/avoid-nullable-columns

This issue isn't fixed in the substreams sink sql, however Nullable types shouldn't be used

Alternative setting integer values to 0 and String values to "" empty string