HiveMetastoreDataSink
laktory.models.datasinks.HiveMetastoreDataSink
¤
Bases: TableDataSink
Data sink writing to a Hive Metastore data table.
Examples:
import laktory as lk
df = spark.createDataFrame([{"x": 1}, {"x": 2}, {"x": 3}])
sink = lk.models.HiveMetastoreDataSink(
schema_name="default",
table_name="my_table",
mode="APPEND",
)
# sink.write(df)
| PARAMETER | DESCRIPTION |
|---|---|
as_stream
|
If
TYPE:
|
catalog_name
|
Sink table catalog name
TYPE:
|
checkpoint_path_
|
Path to which the checkpoint file for which a streaming dataframe should be written.
TYPE:
|
custom_writer
|
Custom writer that fully replaces Laktory's built-in write logic. Laktory manages the streaming query lifecycle (foreachBatch, trigger, checkpoint, start/await). Can be set as a plain string (func_name only) or a full CustomWriter object with func_name, func_args, and func_kwargs. Mutually exclusive with
TYPE:
|
databricks_data_profiling_config
|
Databricks Data Quality Monitor data profiling configuration
TYPE:
|
format
|
Storage format for data table.
TYPE:
|
is_quarantine
|
Sink used to store quarantined results from a pipeline node expectations.
TYPE:
|
merge_cdc_options
|
Merge options to handle input DataFrames that are Change Data Capture (CDC). Only used when
TYPE:
|
metadata
|
Table and columns metadata.
TYPE:
|
mode
|
Write mode. Spark¤
Spark Streaming¤
Polars Delta¤
Laktory¤
TYPE:
|
schema_definition
|
Explicit table schema used when creating the table. If not set, schema is inferred from the transformer output DataFrame.
TYPE:
|
schema_name
|
Sink table schema name
TYPE:
|
table_name
|
Sink table name. Also supports fully qualified name (
TYPE:
|
table_type
|
Type of table. 'TABLE' and 'VIEW' are currently supported.
TYPE:
|
type
|
Sink Type
TYPE:
|
writer_kwargs
|
Keyword arguments passed directly to dataframe backend writer. Passed to
TYPE:
|
writer_methods
|
DataFrame backend writer methods.
TYPE:
|
| METHOD | DESCRIPTION |
|---|---|
as_source |
Generate a table data source with the same properties as the sink. |
create |
Creates an empty table with the expected schema if it does not already exist. |
is_streaming |
Return |
purge |
Delete sink data and checkpoints |
read |
Read dataframe from sink. |
write |
Write dataframe into sink. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
full_name |
Table full name {catalog_name}.{schema_name}.{table_name}
TYPE:
|
ldp_auto_cdc_flow_kwargs |
Keyword arguments for dp.create_auto_cdc_flow function
TYPE:
|
sdp_pre_merge_view_name |
SPD view applying node transformer prior to applying CDC changes.
|
full_name
property
¤
Table full name {catalog_name}.{schema_name}.{table_name}
ldp_auto_cdc_flow_kwargs
property
¤
Keyword arguments for dp.create_auto_cdc_flow function
sdp_pre_merge_view_name
property
¤
SPD view applying node transformer prior to applying CDC changes.
as_source(as_stream=None, reader_kwargs=None, reader_methods=None)
¤
Generate a table data source with the same properties as the sink.
| PARAMETER | DESCRIPTION |
|---|---|
as_stream
|
If
DEFAULT:
|
reader_kwargs
|
Keyword arguments passed to the dataframe backend reader.
DEFAULT:
|
reader_methods
|
DataFrame backend reader methods.
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
TableDataSource
|
Table Data Source |
Source code in laktory/models/datasinks/tabledatasink.py
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | |
create(df=None)
¤
Creates an empty table with the expected schema if it does not already exist.
Returns True if the table was created, False otherwise.
Schema is taken from schema_definition if set, otherwise inferred from df.
Source code in laktory/models/datasinks/tabledatasink.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
is_streaming(df=None)
¤
Return True if the write should use Spark Structured Streaming.
Resolution order:
1. If a Narwhals-wrapped PySpark DataFrame is provided, read its native
isStreaming attribute.
2. Fall back to self.as_stream (explicit sink configuration).
3. Fall back to the parent node's source as_stream flag.
4. Default to False (static write).
If both the DataFrame state and the configuration are set and they
disagree, a TypeError is raised to surface the misconfiguration
early.
| PARAMETER | DESCRIPTION |
|---|---|
df
|
Optional Narwhals DataFrame or LazyFrame. Must be passed before
calling
DEFAULT:
|
Source code in laktory/models/datasinks/basedatasink.py
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
purge()
¤
Delete sink data and checkpoints
Source code in laktory/models/datasinks/tabledatasink.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
read(as_stream=None, reader_kwargs=None, reader_methods=None)
¤
Read dataframe from sink.
| PARAMETER | DESCRIPTION |
|---|---|
as_stream
|
If
DEFAULT:
|
reader_kwargs
|
Keyword arguments passed to the dataframe backend reader.
DEFAULT:
|
reader_methods
|
DataFrame backend reader methods.
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
AnyFrame
|
DataFrame |
Source code in laktory/models/datasinks/basedatasink.py
696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 | |
write(df=None, view_definition=None, mode=None)
¤
Write dataframe into sink.
| PARAMETER | DESCRIPTION |
|---|---|
df
|
Input dataframe.
TYPE:
|
mode
|
Write mode overwrite of the sink default mode.
TYPE:
|
view_definition
|
View definition for table data sinks of
TYPE:
|
Source code in laktory/models/datasinks/basedatasink.py
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 | |