load.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:arthur-redshift-etl 作者: harrystech 项目源码 文件源码
def load_table_design(stream, table_name):
    """
    Load table design from stream (usually, an open file).
    The table design is validated before being returned.
    """
    try:
        table_design = yaml.safe_load(stream)
    except yaml.parser.ParserError as exc:
        raise TableDesignParseError(exc) from exc

    # BEGIN -- Support of DEPRECATED format of specifying constraints
    # This rewrites the format from v0.23.1 and earlier to v0.24.0 -- I would prefer to drop this soon.
    etl.config.validate_with_schema(table_design, "table_design.schema")
    constraints = table_design.get("constraints")
    if isinstance(constraints, dict):
        table_design["constraints"] = [{constraint_type: constraints[constraint_type]}
                                       for constraint_type in sorted(constraints)]
    # END -- Support of DEPRECATED format of specifying constraints

    return validate_table_design(table_design, table_name)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号