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

Tuple Insert from JSONEachRow not working #64242

Open
DJRickyB opened this issue May 22, 2024 · 7 comments
Open

Tuple Insert from JSONEachRow not working #64242

DJRickyB opened this issue May 22, 2024 · 7 comments
Labels
comp-documentation Documentation

Comments

@DJRickyB
Copy link

DJRickyB commented May 22, 2024

Describe what's wrong

Using Clickhouse 24.3.3.102, I cannot follow the following from the documentation:

Does it reproduce on the most recent release?

The list of releases

How to reproduce

DROP TABLE IF EXISTS http;

CREATE table http
(
    `@timestamp` Int32 EPHEMERAL 0,
    clientip     IPv4,
    request Tuple(method LowCardinality(String), path String, version LowCardinality(String)),
    status       UInt16,
    size         UInt32,
    timestamp    DateTime DEFAULT toDateTime(`@timestamp`)
) ENGINE = MergeTree() ORDER BY (status, timestamp);
INSERT INTO http (`@timestamp`, clientip, request, status, size) FORMAT JSONEachRow
    {"@timestamp":893964617,"clientip":"40.135.0.0","request":["GET", "/images/hm_bg.jpg", "HTTP/1.0"],"status":200,"size":24736}

Error:

Expected behavior

Success

Error message and/or stacktrace

Ok.
Exception on client:
Code: 27. DB::Exception: Cannot parse input: expected '{' before: '["GET", "/images/hm_bg.jpg", "HTTP/1.0"],\n    "status":200,"size":24736}': (while reading the value of key request): (at row 1)
: While executing ParallelParsingBlockInputFormat: data for INSERT was parsed from query. (CANNOT_PARSE_INPUT_ASSERTION_FAILED)

Seems it is asking for Tuples to have their field names included in this input format.

This is working in 22.5 : https://fiddle.clickhouse.com/227d593c-10ad-4be6-ab8c-13c6f781c707 but not past that

@DJRickyB DJRickyB added the potential bug To be reviewed by developers and confirmed/rejected. label May 22, 2024
@Algunenano
Copy link
Member

You are declaring an array, not a tuple.

The correct way would be:

INSERT INTO http (`@timestamp`, clientip, request, status, size) FORMAT JSONEachRow
    {"@timestamp":893964617,"clientip":"40.135.0.0","request":{"method":"GET", "path":"/images/hm_bg.jpg", "version":"HTTP/1.0"},"status":200,"size":24736}

@Algunenano Algunenano closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2024
@DJRickyB
Copy link
Author

DJRickyB commented May 23, 2024 via email

@Algunenano
Copy link
Member

It seems the documentation is wrong. Which version did you check that it was working?

https://fiddle.clickhouse.com/e60fbefc-150e-4248-ab87-78d9a0005a29

@DJRickyB
Copy link
Author

DJRickyB commented May 23, 2024 via email

@Algunenano
Copy link
Member

@DJRickyB
Copy link
Author


Error on processing query: Code: 26. DB::ParsingException: Cannot parse JSON string: expected opening quote:

Apologies, it looks like the copy from the documentation included a newline character. It does work in 22.5: https://fiddle.clickhouse.com/227d593c-10ad-4be6-ab8c-13c6f781c707

@DJRickyB
Copy link
Author

I have updated the description with the fiddle, the fixed query copy, and the last working version

@Algunenano Algunenano added comp-documentation Documentation and removed invalid potential bug To be reviewed by developers and confirmed/rejected. labels May 23, 2024
@Algunenano Algunenano reopened this May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-documentation Documentation
Projects
None yet
Development

No branches or pull requests

2 participants