Cmdlets for Databricks

Build 25.0.9434

PrimaryKeyIdentifiers Parameter (Connect-Databricks Cmdlet)

Specifies primary keys for tables in the hive_metastore catalog.

Syntax

Connect-Databricks -PrimaryKeyIdentifiers string

Data Type

cstr

Default Value

""

Remarks

The PrimaryKeyIdentifiers property defines primary keys for tables that do not natively include them in Databricks. This property only applies to the hive_metastore catalog.

Since Databricks does not enforce primary keys, defining them manually can enable DML operations such as UPDATE or DELETE and improve compatibility with tools that expect primary key metadata.

Primary keys are defined as a list of rules, where each rule maps tables to one or more key columns. Multiple rules are separated by semicolons.

For example:

PrimaryKeyIdentifiers="*=my_key;my_table=my_key2,my_key3;my_nokeys_table=;"

This example defines three rules:

  1. *=my_key: All tables without a specific rule have a single primary key column named my_key. Multiple keys can be set by using a comma-separated list (for example, *=my_key,my_key2).
  2. my_table=my_key2,my_key3: The my_table table has two primary key columns, my_key2 and my_key3. Missing columns are ignored.
  3. my_nokeys_table=: The my_nokeys_table table has no primary keys, overriding the default rule.

Table identifiers in each rule can include the table name only, the schema and table, or the catalog, schema, and table. Any name can be quoted using SQL-style delimiters:

/* Rules with just table names use the default connection Catalog and Schema.
   All these rules refer to the same table when Catalog=someCatalog and Schema=someSchema */

someTable=a,b,c
someSchema.someTable=a,b,c
someCatalog.someSchema.someTable=a,b,c

/* Any table or column name may be quoted */
`someCatalog`."someSchema".[someTable]=`a`,[b],"c"

This property is useful for defining primary key metadata in Databricks when working with tools or operations that rely on key-based updates or synchronization logic.

Copyright (c) 2025 CData Software, Inc. - All rights reserved.
Build 25.0.9434