Skip to content

Parse a datetime with optional fractional seconds from json file #6774

@ayemjay

Description

@ayemjay

What happens?

Inconsistent behavior when casting a json value with optional fractional seconds to timestamp. Works as expected with json_transform function, but fails when reading as table with read_json

To Reproduce

working:

select json_transform('["2022-06-01T06:41:58Z", "2021-08-21T08:26:55.5Z", "2009-11-15T21:58:54.636Z"]', '"TIMESTAMP[]"');

fails:

simple.json:

{
    "ts": ["2022-06-01T06:41:58Z", "2021-08-21T08:26:55.5Z", "2009-11-15T21:58:54.636Z"]
}
select ts from read_json('simple.json', columns={"ts": "TIMESTAMP[]"});
-- Error: Invalid Input Error: JSON transform error in file "./simple.json", in object 1: Could not parse string "2022-06-01T06:41:58Z" according to format specifier "%Y-%m-%dT%H:%M:%S.%fZ"
2022-06-01T06:41:58Z

OS:

Windows 10

DuckDB Version:

0.7.1

DuckDB Client:

cli

Full Name:

Adrian

Affiliation:

personal hobby

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions