- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2022 05:31 PM
How would I implement the Identity column in Delta Live Tables using Python syntax?
GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY [ ( [ START WITH start ] [ INCREMENT BY step ] ) ]
- Labels:
-
DLT
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 03:12 AM
Hi @Kory Skistad
Please find below the table schema definition to use in a python dlt pipeline. You can see it mentions the identity column definition.
@dlt.table(
comment="Raw data on sales",
schema="""
customer_id STRING,
customer_name STRING,
number_of_line_items STRING,
order_datetime STRING,
order_number LONG,
order_day_of_week STRING GENERATED ALWAYS AS (dayofweek(order_datetime))
""",
partition_cols = ["order_day_of_week"])
def sales():
return ("...")
This example has been taken from this page: https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-python-ref.html
By the way, be careful about how it is generated regarding you are dealing with a streaming table or not: https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-faqs-issues.html#how-do-i-...
HTH
Laurent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2022 03:12 AM
Hi @Kory Skistad
Please find below the table schema definition to use in a python dlt pipeline. You can see it mentions the identity column definition.
@dlt.table(
comment="Raw data on sales",
schema="""
customer_id STRING,
customer_name STRING,
number_of_line_items STRING,
order_datetime STRING,
order_number LONG,
order_day_of_week STRING GENERATED ALWAYS AS (dayofweek(order_datetime))
""",
partition_cols = ["order_day_of_week"])
def sales():
return ("...")
This example has been taken from this page: https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-python-ref.html
By the way, be careful about how it is generated regarding you are dealing with a streaming table or not: https://docs.databricks.com/workflows/delta-live-tables/delta-live-tables-faqs-issues.html#how-do-i-...
HTH
Laurent

