Skip to content

Fix SchemaDumper incorrectly down casting AggregateFunction types#232

Merged
PNixx merged 1 commit intoPNixx:masterfrom
jonyoi:fix-aggregate-schema-dump
Feb 5, 2026
Merged

Fix SchemaDumper incorrectly down casting AggregateFunction types#232
PNixx merged 1 commit intoPNixx:masterfrom
jonyoi:fix-aggregate-schema-dump

Conversation

@jonyoi
Copy link
Copy Markdown
Contributor

@jonyoi jonyoi commented Feb 4, 2026

The SchemaDumper was previously downcasting 'SimpleAggregateFunction' and 'AggregateFunction' columns to their base types (e.g. converting 'SimpleAggregateFunction(sum, UInt64)' to ':integer').

This commit modifies the 'table' method to explicitly detect these aggregate types and use 't.column' with the raw SQL definition. This ensures the schema dump preserves the full ClickHouse type wrapper.

Resolves #224

@PNixx PNixx merged commit ba2b3da into PNixx:master Feb 5, 2026
25 checks passed
jrgarcia added a commit to huntresslabs/clickhouse-activerecord that referenced this pull request Mar 4, 2026
… load

Upstream PR PNixx#232 fixed the schema dumper to use t.column with raw SQL
types for AggregateFunction columns, but the redundant aggregate_function
options in the colspec cause add_column_options! to double-wrap the type
during schema load (e.g. AggregateFunction(sum, AggregateFunction(sum, Float64))).

Add an early-return guard in add_column_options! that skips all
type-wrapping options when the SQL type is already a complete
(Simple)AggregateFunction definition. Only codec and default are applied.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Schema dumper incorrectly downcasts SimpleAggregateFunction and AggregateFunction types to base types

2 participants