Databricks 在 Unity Catalog 中强制执行主键和外键约束。

huangapple go评论58阅读模式
英文:

Databricks enforce primary and foreign key constraints in Unity Catalog

问题

有人对Unity目录中的Databricks Delta表是否支持主键和外键约束有任何想法吗?我想在Unity中创建带有外键约束的Delta表,并需要验证放入这些表中的数据以确保一致性。截止到今天,我还没有找到任何支持文档或示例,说明如何实施这些约束,而不仅仅是声明它们以显示在表描述中。我尝试过创建带有定义约束的表,但它们不起作用。例如,使用主键约束创建的表允许在定义的列中插入重复的值。外键引用也是如此,允许插入在引用列中不存在的记录。

英文:

Does anyone have an idea about databricks delta tables in unity catalog supporting primary and foreign key constraints by enforcing them and not just declaring for informational purposes?

I'm trying to create delta tables in unity with foreign key constraints and need to validate the data put into those tables for consistency. As of today, could not find any supporting documentation or examples of this on databricks or anywhere else on how to implement these constraints and not just declare them to show on table description.

I've tried creating the tables with constraints defined but they do not work. For example, a table created with primary key constraint allow insertion of duplicate values in the defined column. Same with foreign key reference which allows insertion of records which are absent in the referencing column.

答案1

得分: 0

这个功能目前还不存在 - 正如你刚刚提到的,主键和外键目前主要用于信息目的,对于分布式/大数据系统来说是一个非常困难的问题。你可以通过实现使用Delta Live Tables实现SCD Type 1功能,在插入数据之前进行数据验证等方式来实现一些变通方法。

英文:

This functionality doesn't exist yet - as you mentioned right now primary & foreign keys are primarily for the information purpose, and it's really hard problem for distributed/big data systems. You may implement some workarounds for example by implementing SCD Type 1 functionality using Delta Live Tables, validate data before inserting, etc.

huangapple
  • 本文由 发表于 2023年7月11日 11:27:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76658538.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定