From ce84196d141bce6f9fcf277503f24c7e82783a35 Mon Sep 17 00:00:00 2001 From: ion-elgreco <15728914+ion-elgreco@users.noreply.github.com> Date: Fri, 1 Dec 2023 13:10:09 +0100 Subject: [PATCH] update docs --- mkdocs.yml | 7 +++++++ python/deltalake/table.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/mkdocs.yml b/mkdocs.yml index 7b3e2ccee6..f54ae35b6d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -14,6 +14,8 @@ theme: - navigation.tabs.sticky - navigation.footer - content.tabs.link + - content.code.annotation + - content.code.copy nav: - Home: index.md - Usage: @@ -80,6 +82,11 @@ plugins: on_page_markdown: 'docs._build.hooks:on_page_markdown' markdown_extensions: + - pymdownx.highlight: + anchor_linenums: true + line_spans: __span + pygments_lang_class: true + - pymdownx.inlinehilite - admonition - pymdownx.details - attr_list diff --git a/python/deltalake/table.py b/python/deltalake/table.py index 45446a9b2a..1973254730 100644 --- a/python/deltalake/table.py +++ b/python/deltalake/table.py @@ -310,6 +310,40 @@ def create( configuration: Optional[Mapping[str, Optional[str]]] = None, storage_options: Optional[Dict[str, str]] = None, ) -> "DeltaTable": + """`CREATE` or `CREATE_OR_REPLACE` a delta table given a table_uri. + + Args: + table_uri: URI of a table + schema: Table schema + mode: How to handle existing data. Default is to error if table already exists. + If 'append', returns not support error if table exists. + If 'overwrite', will `CREATE_OR_REPLACE` table. + If 'ignore', will not do anything if table already exists. Defaults to "error". + partition_by: List of columns to partition the table by. + name: User-provided identifier for this table. + description: User-provided description for this table. + configuration: A map containing configuration options for the metadata action. + storage_options: options passed to the object store crate. + + Returns: + DeltaTable: created delta table + + **Examples:** + ``` .py + import pyarrow as pa + + from deltalake import DeltaTable + + dt = DeltaTable.create( + table_uri="my_local_table", + schema=pa.schema( + [pa.field("foo", pa.string()), pa.field("bar", pa.string())] + ), + mode="error", + partition_by="bar", + ) + ``` + """ if isinstance(schema, DeltaSchema): schema = schema.to_pyarrow() if isinstance(partition_by, str):