SimpleAggregateFunction: GetDataTypeName and GetSchema drop the parameters of the aggregate function (groupUniqArrayArray(10) becomes groupUniqArrayArray)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- clickhouse, csharp
- Domain
- backend-api-design, databases
Research direction
Start with ClickHouse.Driver/Types/SimpleAggregateFunctionType.cs, especially Parse and ToString; the issue identifies where function parameters are dropped and which reader and schema paths use the result. Reproduce with the provided C# program against ClickHouse 26.11 and check GetDataTypeName, GetSchemaTable() and GetSchema("Columns"). Done when all report SimpleAggregateFunction(groupUniqArrayArray(10), Array(UInt8)) and the reproduction preserves the limit.
Written by the indexing model from the issue text.
Description
Describe the bug
For a SimpleAggregateFunction column whose aggregate function has parameters, the HTTP client reports the type name without the parameters. For the server type SimpleAggregateFunction(groupUniqArrayArray(10), Array(UInt8)), these give SimpleAggregateFunction(groupUniqArrayArray, Array(UInt8)):
ClickHouseDataReader.GetDataTypeName- the
ProviderTypeofGetSchemaTable() - the
ProviderTypeofconnection.GetSchema("Columns", ...)
The reported name is a different type: a table created from it uses groupUniqArrayArray with no limit. In the code example, after 20 inserts and a merge, the original table keeps 10 values and the table created from the reported name keeps 20.
The values read correctly. Not affected: functions with no parameters (SimpleAggregateFunction(sum, UInt64)), and the TCP client (IColumn.TypeName gives the name of the server).
Steps to reproduce
- Start a ClickHouse 26.11 server.
- Put the code example in a directory one level below a clone of this repository (for example
repro/app.cs). - Run
CLICKHOUSE_CONNECTION="Host=localhost" dotnet run app.cs.
Expected behaviour
The name that the server reports for the column (curl, same table as the code example):
SELECT type FROM system.columns WHERE database = 'default' AND table = 't_saf_src' AND name = 's'
SimpleAggregateFunction(groupUniqArrayArray(10), Array(UInt8))
The parameters are part of the type. The ClickHouse docs write the type as SimpleAggregateFunction(function_name(param_1, ..., param_N), arg_T1, ..., arg_TN) (Data types binary encoding).
Code example
Reproduction program (C#, 30 lines)
#:project ../ClickHouse.Driver/ClickHouse.Driver.csproj
using ClickHouse.Driver.ADO;
using ClickHouse.Driver.Utility;
var cs = Environment.GetEnvironmentVariable("CLICKHOUSE_CONNECTION") ?? "Host=localhost";
using var connection = new ClickHouseConnection(cs);
const string type = "SimpleAggregateFunction(groupUniqArrayArray(10), Array(UInt8))";
await connection.ExecuteStatementAsync($"CREATE OR REPLACE TABLE t_saf_src (k UInt8, s {type}) ENGINE = AggregatingMergeTree ORDER BY k");
string name;
using (var reader = await connection.ExecuteReaderAsync("SELECT s FROM t_saf_src"))
{
name = reader.GetDataTypeName(0);
Console.WriteLine($"GetDataTypeName: {name}");
Console.WriteLine($"GetSchemaTable: {reader.GetSchemaTable().Rows[0]["ProviderType"]}");
}
var columns = connection.GetSchema("Columns", new[] { "default", "t_saf_src" });
Console.WriteLine($"GetSchema(Columns): {columns.Rows[1]["ProviderType"]}");
// A table created from the reported name gets another aggregate function.
await connection.ExecuteStatementAsync($"CREATE OR REPLACE TABLE t_saf_copy (k UInt8, s {name}) ENGINE = AggregatingMergeTree ORDER BY k");
foreach (var table in new[] { "t_saf_src", "t_saf_copy" })
{
for (var i = 0; i < 20; i++)
await connection.ExecuteStatementAsync($"INSERT INTO {table} VALUES (1, [{i}])");
await connection.ExecuteStatementAsync($"OPTIMIZE TABLE {table} FINAL");
Console.WriteLine($"{table}: length(s) = {await connection.ExecuteScalarAsync($"SELECT length(s) FROM {table}")}");
}
await connection.ExecuteStatementAsync("DROP TABLE t_saf_src");
await connection.ExecuteStatementAsync("DROP TABLE t_saf_copy");
Error log
Output, the same in 2 of 2 runs:
GetDataTypeName: SimpleAggregateFunction(groupUniqArrayArray, Array(UInt8))
GetSchemaTable: SimpleAggregateFunction(groupUniqArrayArray, Array(UInt8))
GetSchema(Columns): SimpleAggregateFunction(groupUniqArrayArray, Array(UInt8))
t_saf_src: length(s) = 10
t_saf_copy: length(s) = 20
Root cause
SimpleAggregateFunctionType.Parse keeps only node.ChildNodes[0].Value, the bare function name, and drops the arguments of that node (ClickHouse.Driver/Types/SimpleAggregateFunctionType.cs:21). ToString() (line 28) builds the name from it, and GetDataTypeName (ClickHouse.Driver/ADO/Readers/ClickHouseDataReader.cs:254) and GetSchema("Columns") (ClickHouse.Driver/Utility/SchemaDescriber.cs:132) use ToString().
The fix is in the HTTP client only. Polyglot AI can open a fix PR if a maintainer assigns this issue to @polyglotAI-bot.
Related
#506 (open) adds the binary type decoder of SimpleAggregateFunction (Dynamic, JSON); it also keeps only the function name.
Configuration
Environment
- Client version: 1.7.0 (
mainat c58178ed) - .NET version: .NET SDK 11.0.100, runtime .NET 11.0.0
- OS: Linux (container)
ClickHouse server
- ClickHouse Server version: 26.11.7.10
- ClickHouse Server non-default settings, if any: none
Classification: impact: none · area: Data types & formats (SimpleAggregateFunction)
Found by automated analysis (Polyglot AI) while working on clickhouse-rs#576. Verified against a live server.
- Dominant language
- C#
- Stars
- 102
- Forks
- 31
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 40
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ClickHouse/clickhouse-cs
-
bug documentation queries
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ClickHouse/clickhouse-cs#815 ·
Maintainers usually reply within 1 day
-
bug data-types native-format
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
ClickHouse/clickhouse-cs#813 ·
Maintainers usually reply within 1 day
-
bug data-types documentation
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/clickhouse-cs#811 ·
Maintainers usually reply within 1 day
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ClickHouse/clickhouse-cs#809 ·
Maintainers usually reply within 1 day
-
bug data-types
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
ClickHouse/clickhouse-cs#806 · 1 comment ·
Maintainers usually reply within 1 day
All issues in ClickHouse/clickhouse-cs
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
XML grammar: only the closing --> of a comment gets the scope comment.block.xmlPossibly taken @alexeyfala claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
danipen/TextMateSharp#145 · 2 comments ·
-
good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Klyroo/klyroo-dashboard#12 ·
Maintainers usually reply within 1 day
-
CONTRIBUTING rules Node out in step 0, then tells client-side contributors to run node --test, which is what CI gates onPossibly taken @yadavraj2001 claimed this today. Opendocumentation good first issue
Difficulty 1/5 1-3 hours Newbie friendliness 82/100
juandresrodca/AdminForge#73 · 1 comment ·
Maintainers usually reply within 1 day
-
[辞書] VIVANTOpen要トリアージ 辞書
Difficulty 1/5 Under an hour Newbie friendliness 70/100
Maintainers usually reply within 1 day