@@ -674,7 +674,7 @@ def create_ctas_table( # pylint: disable=too-many-locals
674674 The name of the database where the original table is stored.
675675 ctas_table : Optional[str], optional
676676 The name of the CTAS table.
677- If None, a random string is used.
677+ If None, a name with a random string is used.
678678 ctas_database : Optional[str], optional
679679 The name of the alternative database where the CTAS table should be stored.
680680 If None, `database` is used, that is the CTAS table is stored in the same database as the original table.
@@ -718,6 +718,42 @@ def create_ctas_table( # pylint: disable=too-many-locals
718718 Dict[str, Union[str, _QueryMetadata]]
719719 A dictionary with the the CTAS database and table names.
720720 If `wait` is `False`, the query ID is included, otherwise a Query metadata object is added instead.
721+
722+ Examples
723+ --------
724+ Select all into a new table and encrypt the results
725+
726+ >>> import awswrangler as wr
727+ >>> wr.athena.create_ctas_table(
728+ ... sql="select * from table",
729+ ... database="default",
730+ ... encryption="SSE_KMS",
731+ ... kms_key="1234abcd-12ab-34cd-56ef-1234567890ab",
732+ ... )
733+ {'ctas_database': 'default', 'ctas_table': 'temp_table_5669340090094....', 'ctas_query_id': 'cc7dfa81-831d-...'}
734+
735+ Create a table with schema only
736+
737+ >>> wr.athena.create_ctas_table(
738+ ... sql="select col1, col2 from table",
739+ ... database="default",
740+ ... ctas_table="my_ctas_table",
741+ ... schema_only=True,
742+ ... wait=True,
743+ ... )
744+
745+ Partition data and save to alternative CTAS database
746+
747+ >>> wr.athena.create_ctas_table(
748+ ... sql="select * from table",
749+ ... database="default",
750+ ... ctas_database="my_ctas_db",
751+ ... storage_format="avro",
752+ ... write_compression="snappy",
753+ ... partitioning_info=["par0", "par1"],
754+ ... wait=True,
755+ ... )
756+
721757 """
722758 ctas_table = catalog .sanitize_table_name (ctas_table ) if ctas_table else f"temp_table_{ uuid .uuid4 ().hex } "
723759 ctas_database = ctas_database if ctas_database else database
0 commit comments