Skip to content

Commit f7f5a9f

Browse files
committed
Complete PACE implementation
1 parent bf56c56 commit f7f5a9f

File tree

3 files changed

+51
-6
lines changed

3 files changed

+51
-6
lines changed

initdb.d/init.sql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ create user mark with encrypted password 'mark';
22
create role administrator;
33
create role marketing;
44
grant marketing to mark;
5-
grant administrator to postgres;
6-
-- Grant select access to user 'other' on all (including future) tables
7-
-- alter default privileges in schema public grant all on tables to other;
5+
grant administrator to postgres;

lib/data_contract.py

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,51 @@ def to_datacontract_cli(contract):
6767
}
6868

6969

70-
return data
70+
return data
71+
72+
def to_pace(contract):
73+
# The schema
74+
fields = []
75+
for column in contract["columns"]:
76+
fields.append({
77+
'name_parts': [column["name"]],
78+
'type': column["data_type"].lower(),
79+
})
80+
81+
# The access policies
82+
conditions = []
83+
for policy in contract["access"]:
84+
conditions.append(dict(
85+
principals = policy.get("principals", []),
86+
condition = policy.get("condition")
87+
))
88+
89+
filters = [dict(
90+
generic_filter = dict(
91+
conditions = conditions
92+
)
93+
)]
94+
95+
return dict(
96+
metadata = dict(
97+
title = f"public.{contract['dataset']}",
98+
),
99+
source = dict(
100+
ref = dict(
101+
integration_fqn = f"public.{contract['dataset']}",
102+
platform = dict(
103+
id = "postgres",
104+
platform_type = "POSTGRES",
105+
)
106+
),
107+
fields = fields,
108+
),
109+
rule_sets = [dict(
110+
target = dict(
111+
ref = dict(
112+
integration_fqn = f"public.{contract['dataset']}_view",
113+
),
114+
),
115+
filters = filters,
116+
)]
117+
)

pace/application.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
spring:
22
datasource:
3-
url: jdbc:postgresql://postgres_pace:5431/pace
3+
url: jdbc:postgresql://postgres_pace:5432/pace
44
hikari:
55
username: pace
66
password: pace
@@ -10,7 +10,7 @@ app:
1010
expose-application-exceptions: true
1111
processing-platforms:
1212
postgres:
13-
- id: "sample-connection"
13+
- id: "postgres"
1414
host-name: "postgres"
1515
port: 5432
1616
user-name: "postgres"

0 commit comments

Comments
 (0)