Delta Table Create
DeltaTableCreateUtility
Bases: UtilitiesInterface
Creates a Delta Table in a Hive Metastore or in Databricks Unity Catalog.
Example
from rtdip_sdk.pipelines.utilities.spark.delta_table_create import DeltaTableCreateUtility, DeltaTableColumn
table_create_utility = DeltaTableCreateUtility(
spark=spark_session,
table_name="delta_table",
columns=[
DeltaTableColumn(name="EventDate", type="date", nullable=False, metadata={"delta.generationExpression": "CAST(EventTime AS DATE)"}),
DeltaTableColumn(name="TagName", type="string", nullable=False),
DeltaTableColumn(name="EventTime", type="timestamp", nullable=False),
DeltaTableColumn(name="Status", type="string", nullable=True),
DeltaTableColumn(name="Value", type="float", nullable=True)
],
partitioned_by=["EventDate"],
properties={"delta.logRetentionDuration": "7 days", "delta.enableChangeDataFeed": "true"},
comment="Creation of Delta Table"
)
result = table_create_utility.execute()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spark |
SparkSession
|
Spark Session required to read data from cloud storage |
required |
table_name |
str
|
Name of the table, including catalog and schema if table is to be created in Unity Catalog |
required |
columns |
list[DeltaTableColumn]
|
List of columns and their related column properties |
required |
partitioned_by |
list[str]
|
List of column names to partition the table by |
None
|
location |
str
|
Path to storage location |
None
|
properties |
dict
|
Propoerties that can be specified for a Delta Table. Further information on the options available are here |
None
|
comment |
str
|
Provides a comment on the table metadata |
None
|
Source code in src/sdk/python/rtdip_sdk/pipelines/utilities/spark/delta_table_create.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
system_type()
staticmethod
Attributes:
Name | Type | Description |
---|---|---|
SystemType |
Environment
|
Requires PYSPARK |
Source code in src/sdk/python/rtdip_sdk/pipelines/utilities/spark/delta_table_create.py
100 101 102 103 104 105 106 |
|