Payload formats
PutRows accepts rows in JSON or Avro. Set the x-amz-payload-format header to the format of your payload. PutRows validates every row against the table's schema, and then writes the rows to Apache Parquet files.
| Format | x-amz-payload-format |
Payload |
|---|---|---|
| JSON | JSON |
One or more JSON objects, one per row, separated by newlines (NDJSON). Each object's keys are column names. |
| Avro OCF | AVRO |
One Avro object container file (OCF), with one Avro record per row. The fields in the file's writer schema map to the table's columns. Compression codecs supported: null (uncompressed), deflate, and snappy* |
You can send the body either uncompressed (Content-encoding: identity), or compressed gzip (Content-Encoding: gzip). PutRows rejects any other content encoding. PutRows rejects requests that compress more than once: if your payload uses a compression codec (e.g. snappy), you must use the identity content encoding. Conversely, if you use Content-Encoding: gzip, then the avro file must not use a compression codec.
How PutRows validates a request
PutRows checks every row against the table's current schema at the time that it receives the request.
-
A request succeeds or fails as a whole. If PutRows rejects any row in a request, it stores none of the request's rows.
-
When PutRows rejects a request, the error message describes the problem. When possible, it identifies the row and column.
Column matching, missing values, and nulls
-
Column names are case sensitive.
-
PutRows rejects a row that contains a field that isn't in the table's schema. PutRows doesn't accept extra fields.
-
If a row leaves out a column, PutRows writes the column's default value (
write-default) from the table schema. If the column has no default, PutRows writes null to an optional column and rejects the request for a required column. -
If a row sets a column to null, PutRows writes null to an optional column and rejects the request for a required column, even when the column has a default.
-
In Avro, a record inside a map key must include a field for every field of the key's struct, even an optional one.
The same rules apply to fields inside structs, list elements, and map values.
Payload format limitations
The following limitations apply to PutRows payloads.
-
JSON maps with struct, list, or map keys – PutRows doesn't yet accept these maps in JSON. In a JSON request, you can leave out the column or set it to null. If the column is required, use Avro to write to the table.
-
JSON dates outside the years 0000 to 9999 – PutRows doesn't accept signed years, such as
"-0001-01-01", in JSON. Use Avro to write these dates. -
Avro type references with dotted names – In an Avro schema, you can give a type a namespace in two ways: with a
namespaceattribute, as in"name": "Row", "namespace": "com.example", or in the name itself, as in"name": "com.example.Row". PutRows rejects some schemas that use the latter form. Named type references are typically introduced when a field reuses a type that's defined earlier in the schema, for example twouuidfields that share onefixed(16)definition. The Avro libraries for Java, Python, and Rust always use thenamespaceattribute and aren't affected. But other libraries (e.g. fastavro) can sometimes use singular form. Configure your writer to use namespaces, or to avoid type definition reuse. -
Geometry and geography values – PutRows writes WKB bytes as you send them. For the widest compatibility with query engines, send ISO WKB without an embedded spatial reference identifier (SRID).
-
Variant values – PutRows writes the
metadataandvaluebytes as you send them. Invalid binary encodings will be rejected. For the widest compatibility with query engines, limit yourself to variants that stay under 50 levels of nesting.
For details on each format, see the following topics.