【问题标题】:Creating a primary key data health expectation in Palantir Foundry Code Repositories在 Palantir Foundry 代码库中创建主键数据健康预期
【发布时间】:2022-07-14 02:45:30
【问题描述】:

我有一个数据集,它是 Palantir Foundry 代码库中定义的 Python 转换的输出。它有一个主键,但考虑到随着时间的推移数据可能会发生变化,我想在将来验证这个主键是否成立。

如何创建数据健康预期或检查以确保主键在未来保持不变?

【问题讨论】:

    标签: palantir-foundry foundry-code-repositories


    【解决方案1】:

    您可以在 Python 转换中定义数据预期,例如:

    from transforms.api import transform_df, Input, Output, Check
    from transforms import expectations as E
    
    
    @transform_df(
        Output("/path/to/output"),
        source_df=Input("/path/to/input", checks=[
            Check(E.primary_key("thing_id"), "primary_key: thing_id"),
        ]),
    )
    def compute(source_df):
        return source_df.select("thing_id", "thing_name").distinct()
    

    更多信息请访问Palantir Foundry documentation on defining data expectations

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-07-06
      • 2021-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-19
      • 2022-07-05
      相关资源
      最近更新 更多