Load and query a small JSON dataset
A small end-to-end example is useful for checking an importer's field names and value types before sending a large file. Create a fresh destination table with an explicit schema:
CREATE TABLE sample_events(id UInt64, event String, amount Decimal(18, 2));Send the row objects in a separate request:
INSERT INTO sample_events FORMAT json_each_row
{"id":1,"event":"purchase","amount":"12.50"}
{"id":2,"event":"refund","amount":"2.00"}Then verify the result in another request:
SELECT id, event, amount FROM sample_events ORDER BY id FORMAT json_each_row;Review the contract before scaling
The field names must match the intended destination columns. A declared Decimal preserves an exact amount with its scale; it should not be replaced by an approximate type solely because the source encodes numbers as text. Decide how omitted values and explicit nulls should behave in the production table.
The input consumes the rest of its request. Do not append the verification SELECT after the row data. When sending a file, native stdin or an HTTP attached upload keeps the SQL separate from its input bytes.
Retain this reduced example when reporting a failure, replacing real customer values with equivalent synthetic values.
See JSON loading, Decimal and HTTP uploads.