ClickHouse / ClickHouse/ClickHouse

[bug] Error dynamic type for parse list when the first element is DateTime format.

Open
#76,707 0 comments 0 reactions 0 assignees View on GitHub
comp-json-datatype external potential bug
Dominant language
C++
Stars
49.9k
Forks
9k
Avg merge
21h 32m
Merged PRs (30d)
515

Description

### Describe what's wrong

When the first element of an array is in DateTime format, subsequent elements that are not of DateTime type will continuously be converted to DateTime type.

### Does it reproduce on the most recent release?

Yes

### How to reproduce

ClickHouse server version: `25.1.3.23`

Settings:

|name |value|
|--------|-----|
date_time_input_format|best_effort

#### Fiddle
https://fiddle.clickhouse.com/92917235-93ed-4e48-bd87-0404c64b9359

#### Example

```sql
with
JSONExtract('{"list": ["2024-12-22 16:18:16","1","31","32"]}', 'list', 'Array(Dynamic)') as list
select dynamicType(list[1]),dynamicType(list[2]),dynamicType(list[3]),dynamicType(list[4]),list
settings date_time_input_format='best_effort';
```

#### Actual:

```
DateTime DateTime DateTime String ['2024-12-22 16:18:16','2025-01-01 00:00:00','2025-01-31 00:00:00','32']
```

### Expected behavior

```
DateTime String String String ['2024-12-22 16:18:16','1','31','32']
```

Or to disable `DateTime` type:

```
String String String String ['2024-12-22 16:18:16','1','31','32']
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.