File tree Expand file tree Collapse file tree 6 files changed +27
-22
lines changed Expand file tree Collapse file tree 6 files changed +27
-22
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python
22
3- from soda .contracts .connection import Connection , SodaException
4- from soda .contracts .contract import Contract , ContractResult
3+ from soda .contracts .contract_verification import ContractVerification , ContractVerificationResult
54
6- try :
7- with Connection .from_yaml_file ("./connection.yml" ) as connection :
8- contract : Contract = Contract .from_yaml_file ("./customers.contract.yml" )
9- contract_result : ContractResult = contract .verify (connection )
10-
11- print ("Soda checks passed" )
12- except SodaException as e :
13- print (e .contract_result )
5+ contract_verification_result : ContractVerificationResult = (
6+ ContractVerification .builder ()
7+ .with_contract_yaml_file ('./customers.contract.yml' )
8+ .with_warehouse_yaml_file ('./connection.yml' )
9+ .execute ()
10+ .assert_ok ()
11+ )
Original file line number Diff line number Diff line change 1- type : postgres
2- host : localhost
3- database : postgres
4- username : postgres
5- password : secret
1+ name : local_postgres
2+ type : postgres
3+ connection :
4+ host : localhost
5+ database : postgres
6+ username : postgres
7+ password : secret
Original file line number Diff line number Diff line change 11dataset : customers
2- owner : product-team@data-contracts.com
2+ owner :
3+ email : product-team@data-contracts.com
34description : All active customers of our product.
45version : 1
56
@@ -23,3 +24,9 @@ columns:
2324 - name : distance
2425 description : The distance the customer is from our shop
2526 data_type : INTEGER
27+
28+ checks :
29+ - type : metric_expression
30+ metric : retention_period
31+ expression_sql : COUNT(CASE WHEN created < NOW() - interval '1 year' THEN 1 END)
32+ must_be : 0
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ def to_datacontract_cli(contract):
4040 title = contract ["dataset" ],
4141 version = str (contract ["version" ]),
4242 description = contract ["description" ],
43- owner = contract ["owner" ],
43+ owner = contract ["owner" ][ "email" ] ,
4444 ),
4545 servers = dict (
4646 workshop = dict (
Original file line number Diff line number Diff line change 66from data_contract import *
77
88import yaml
9- from soda .contracts .contract import Contract
109
1110with open ("./customers.contract.yml" , "r" ) as stream :
1211 contents = stream .read ()
1312 contract = yaml .safe_load (contents )
14- soda_contract = Contract .from_yaml_str (contents )
1513
1614print (
1715 f'Successfully parsed the `{ contract ["dataset" ]} ` contract, which is owned by `{ contract ["owner" ]} `.' )
Original file line number Diff line number Diff line change 11pyyaml == 6.0
2- soda-core == 3.3.2
3- soda-core-contracts == 3.3.2
4- soda-core-postgres == 3.3.2
2+ soda-core == 3.3.5
3+ soda-core-contracts == 3.3.5
4+ soda-core-postgres == 3.3.5
You can’t perform that action at this time.
0 commit comments