Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnumParse failed when parsing Enum field with name alias in Tuple. #538

Open
nick1ee opened this issue Oct 30, 2024 · 1 comment
Open

EnumParse failed when parsing Enum field with name alias in Tuple. #538

nick1ee opened this issue Oct 30, 2024 · 1 comment

Comments

@nick1ee
Copy link

nick1ee commented Oct 30, 2024

Hi,
I encountered an issue where declaring an enum field within a tuple causes a System.ArgumentOutOfRangeException during EnumType.Parse when performing bulk insertion.

EnumType.cs (line: 32)

If I leave my code unchanged and only modify the table schema to replace the enum within the tuple with a string, the same code executes successfully, and the data is written without errors.

It seems like a bug. Could it be that type parsing for enums within tuples is currently unsupported or has limitations?

Environment:
.net 8.0 + clickhouse.client 6.8.1
clickhouse version: 24.8.4.13

CREATE TABLE demo.product ON CLUSTER 'default'
(
    shop String,
    product String,
    property Tuple(title String, description String, status Enum8('Active' = 0, 'Inactive' = 1)),
    updated_at DateTime64(3, 'UTC')
)
ENGINE = ReplicatedReplacingMergeTree(updated_at)
ORDER BY (shop, product)
SETTINGS clean_deleted_rows = 'Always', index_granularity = 8192;
string[] columnNames = ["shop", "product", "property", "updated_at"];
await using var conn = new ClickHouseConnection(_connectionString);
await conn.OpenAsync();
using ClickHouseBulkCopy bulkCopy = new(conn)
{
    DestinationTableName = "demo.product",
    ColumnNames = columnNames,
    BatchSize = 10000
};

IEnumerable<object[]> data = models
    .GroupBy(m => (m.Shop, m.Product, m.UpdatedAt))
    .Select(g => new object[]
    {
        g.Key.Shop,
        g.Key.Product,
        g.Select(v => new Tuple<string, string, string,>(v.Title, v.Description, v.Status)).ToList(),
        g.Key.UpdatedAt
    });

await bulkCopy.InitAsync();
await bulkCopy.WriteToServerAsync(data);
await conn.CloseAsync();

Originally posted by @nick1ee in #536

@nick1ee
Copy link
Author

nick1ee commented Oct 30, 2024

Here comes some pictures for reference.

Slack 2024-10-30 10 14 59

Slack 2024-10-30 10 15 02

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

No branches or pull requests

1 participant