MCPcopy Index your code
hub / github.com/pathwaycom/pathway / write

Function write

python/pathway/io/dynamodb/__init__.py:19–270  ·  view source on GitHub ↗

Writes ``table`` into a DynamoDB table. The connection settings are retrieved from the environment. This connector supports three modes: ``default`` mode, which performs no preparation on the target table; ``create_if_not_exists`` mode, which creates the table if it does not al

(
    table: Table,
    table_name: str,
    partition_key: ColumnReference,
    *,
    sort_key: ColumnReference | None = None,
    init_mode: Literal["default", "create_if_not_exists", "replace"] = "default",
    name: str | None = None,
)

Source from the content-addressed store, hash-verified

17@check_arg_types
18@trace_user_frame
19def write(
20 table: Table,
21 table_name: str,
22 partition_key: ColumnReference,
23 *,
24 sort_key: ColumnReference | None = None,
25 init_mode: Literal["default", "create_if_not_exists", "replace"] = "default",
26 name: str | None = None,
27) -> None:
28 """
29 Writes ``table`` into a DynamoDB table. The connection settings are retrieved from
30 the environment.
31
32 This connector supports three modes: ``default`` mode, which performs no preparation
33 on the target table; ``create_if_not_exists`` mode, which creates the table if it does
34 not already exist; and ``replace`` mode, which replaces the table and clears any
35 previously existing data. The table is created with an
36 `on-demand <https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/capacity-mode.html>`_
37 billing mode. Be aware that this mode may not be optimal for your use case, and the
38 provisioned mode with capacity planning might offer better performance or cost
39 efficiency. In such cases, we recommend creating the table yourself in AWS with the
40 desired provisioned throughput settings.
41
42 Note that if the table already exists and you use either ``default`` or
43 ``create_if_not_exists`` mode, the schema of the table, including the primary key and
44 optional sort key, must match the schema of the table you are writing.
45
46 The connector performs writes using the primary key, defined as a combination of the
47 partition key and an optional sort key. Note that, due to how DynamoDB operates,
48 entries may overwrite existing ones if their keys coincide. When an entry is deleted
49 from the Pathway Live Data Framework table, the corresponding entry is also removed from the DynamoDB
50 table maintained by the connector. In this sense, the connector behaves similarly to
51 the snapshot mode in the
52 `Delta Lake </developers/api-docs/pathway-io/deltalake/#pathway.io.deltalake.write>`_
53 output connector or the
54 `Postgres </developers/api-docs/pathway-io/postgres#pathway.io.postgres.write_snapshot>`_
55 output connector.
56
57 Args:
58 table: The table to write.
59 table_name: The name of the destination table in DynamoDB.
60 partition_key: The column to use as the
61 `partition key <https://aws.amazon.com/blogs/database/choosing-the-right-dynamodb-partition-key/>`_
62 in the destination table. Note that only the scalar types ``String``, ``Number``
63 and ``Binary`` can be used as index fields in DynamoDB. Therefore, the field you
64 select in the Pathway Live Data Framework table must serialize to one of these types. You can verify
65 this using the conversion table provided in the connector documentation. In
66 particular, ``bool`` columns serialize to the DynamoDB ``Boolean`` type, which is
67 not a valid key type, so they cannot be used as a partition or sort key.
68 sort_key: An optional sort key for the destination table. Note that only the scalar
69 types ``String``, ``Number`` and ``Binary`` can be used as the index fields in
70 DynamoDB. Similarly to the partition key, you can only use fields that serialize
71 into one of these scalar DynamoDB types.
72 init_mode: The table initialization mode, one of the three described above.
73 name: A unique name for the connector. If provided, this name will be used in
74 logs and monitoring dashboards.
75
76 Returns:

Callers

nothing calls this directly

Calls 5

_check_entitlementsFunction · 0.90
init_mode_from_strFunction · 0.90
get_column_indexFunction · 0.90
toMethod · 0.80

Tested by

no test coverage detected