Skip to content

Commit

Permalink
val not nullable anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
kylemumma committed Mar 4, 2025
1 parent a472777 commit 3411880
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ schema:
{ name: attr_type, type: String, args: { schema_modifiers: [low_cardinality] } },
{ name: timestamp, type: DateTime },
{ name: retention_days, type: UInt, args: { size: 16 } },
# attr_value is null for 'float' attr_type
{ name: attr_value, type: String, args: { schema_modifiers: [nullable] } },
# attr_value is always an empty string for 'float' attr_type
{ name: attr_value, type: String },
]
local_table_name: items_attrs_1_local
dist_table_name: items_attrs_1_dist
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Migration(migration.ClickhouseNodeMigration):
This migration creates a table meant to store just the attributes seen in a particular org.
* attr_type can either be "string" or "float"
* attr_value is null for float attributes
* attr_value is always an empty string for float attributes
"""

blocking = False
Expand All @@ -36,9 +36,7 @@ class Migration(migration.ClickhouseNodeMigration):
DateTime(modifiers=Modifiers(codecs=["DoubleDelta", "ZSTD(1)"])),
),
Column("retention_days", UInt(16)),
Column(
"attr_value", String(modifiers=Modifiers(codecs=["ZSTD(1)"], nullable=True))
),
Column("attr_value", String(modifiers=Modifiers(codecs=["ZSTD(1)"]))),
]

def forwards_ops(self) -> Sequence[SqlOperation]:
Expand Down Expand Up @@ -88,7 +86,7 @@ def forwards_ops(self) -> Sequence[SqlOperation]:
LEFT ARRAY JOIN
arrayConcat(
{", ".join(f"arrayMap(x -> tuple(x.1, x.2, 'string'), CAST(attributes_string_{n}, 'Array(Tuple(String, String))'))" for n in range(ITEM_ATTRIBUTE_BUCKETS))},
{",".join(f"arrayMap(x -> tuple(x, Null, 'float'), mapKeys(attributes_float_{n}))" for n in range(ITEM_ATTRIBUTE_BUCKETS))}
{",".join(f"arrayMap(x -> tuple(x, '', 'float'), mapKeys(attributes_float_{n}))" for n in range(ITEM_ATTRIBUTE_BUCKETS))}
) AS attrs
GROUP BY
organization_id,
Expand Down

0 comments on commit 3411880

Please sign in to comment.