Palantir Data Handling
Overview
Handle sensitive data in Foundry using markings (data classifications), column-level security, PII redaction in transforms, and GDPR/CCPA deletion workflows.
Prerequisites
- Foundry enrollment with Markings enabled
- Understanding of your organization's data classification policy
- Familiarity with transforms (
palantir-core-workflow-a)
Instructions
Step 1: Data Classification with Markings
Foundry Markings control who can access data at the dataset, column, or row level.
| Marking |
Access |
Use Case |
PUBLIC |
All users |
Aggregated reports, reference data |
INTERNAL |
Employees only |
Business metrics, operational data |
CONFIDENTIAL |
Specific groups |
Customer PII, financial data |
RESTRICTED |
Named individuals |
Compensation, legal, M&A |
Step 2: PII Redaction in Transforms
from transforms.api import transform_df, Input, Output
from pyspark.sql import functions as F
@transform_df(
Output("/Company/datasets/customers_safe"),
customers=Input("/Company/datasets/raw_customers"),
)
def redact_pii(customers):
"""Create an analytics-safe view with PII removed."""
return (
customers
.withColumn("email", F.sha2(F.col("email"), 256)) # Hash email
.withColumn("phone", F.lit("***-***-****")) # Mask phone
.withColumn("ssn", F.lit(None).cast("string")) # Remove SSN
.withColumn("name", F.concat(
F.substring("first_name", 1, 1), F.lit("***") # First initial only
))
.drop("first_name", "last_name", "address", "date_of_birth")
)
Step 3: GDPR Right to Erasure
def delete_user_data(client, user_id: str):
"""GDPR Article 17: delete all data for a specific user."""
datasets_with_pii = [
"/Company/datasets/raw_customers",
"/Company/datasets/raw_orders",
"/Company/datasets/customer_communications",
]
for dataset_path in datasets_with_pii:
# Trigger a transform that filters out the user
client.ontologies.Action.apply(
action_type="gdprDeleteUser",
parameters={"userId": user_id, "datasetPath": dataset_path},
)
# Log the deletion for compliance
client.ontologies.Action.apply(
action_type="logDeletionRequest",
parameters={
"userId": user_id,
"requestedAt": datetime.utcnow().isoformat(),
"status": "completed",
},
)
Step 4: Column-Level Security in Ontology
# Define object type with restricted properties
# In Ontology Manager:
# - fullName: marking = CONFIDENTIAL
# - email: marking = CONFIDENTIAL
# - department: marking = INTERNAL
# - employeeId: marking = INTERNAL
# Users without CONFIDENTIAL marking see:
# employeeId, department (but NOT fullName, email)
Step 5: Data Retention Policy
@transform_df(
Output("/Company/datasets/events_retained"),
events=Input("/Company/datasets/raw_events"),
)
def apply_retention(events):
"""Keep only last 2 years of data per retention policy."""
from pyspark.sql import functions as F
from datetime import datetime, timedelta
cutoff = (datetime.utcnow() - timedelta(days=730)).strftime("%Y-%m-%d")
return events.filter(F.col("event_date") >= cutoff)
Output
- PII-redacted datasets safe for analytics
- GDPR deletion workflow with audit trail
- Column-level security via Foundry Markings
- Automated data retention enforcement
Error Handling
| Compliance Risk |
Detection |
Mitigation |
| PII in analytics dataset |
Column scan |
Apply redaction transform |
| Stale data beyond retention |
Date filter |
Schedule retention transforms |
| Missing deletion audit |
Log review |
Always log GDPR actions |
| Over-permissive markings |
Access audit |
Review marking assignments quarterly |
Resources
Next Steps
For access control, see palantir-enterprise-rbac.
1---
2name: palantir-data-handling
3description: |
4 Implement Palantir Foundry data handling with PII protection, markings, and GDPR compliance.
5 Use when handling sensitive data in Foundry, implementing data classifications,
6 or ensuring compliance with privacy regulations.
7 Trigger with phrases like "palantir data", "foundry PII",
8 "palantir GDPR", "foundry data protection", "palantir markings".
9allowed-tools: Read, Write, Edit
10version: 2.0.0
11license: MIT
12author: Jeremy Longshore <jeremy@intentsolutions.io>
13tags: [saas, palantir, foundry, data, privacy, compliance]
14compatible-with: claude-code, codex, openclaw
15metadata:
16 source: https://skillmd.com/skills/aibot88/palantir-data-handling
17---
18
19# Palantir Data Handling
20
21## Overview
22Handle sensitive data in Foundry using markings (data classifications), column-level security, PII redaction in transforms, and GDPR/CCPA deletion workflows.
23
24## Prerequisites
25- Foundry enrollment with Markings enabled
26- Understanding of your organization's data classification policy
27- Familiarity with transforms (`palantir-core-workflow-a`)
28
29## Instructions
30
31### Step 1: Data Classification with Markings
32Foundry Markings control who can access data at the dataset, column, or row level.
33
34| Marking | Access | Use Case |
35|---------|--------|----------|
36| `PUBLIC` | All users | Aggregated reports, reference data |
37| `INTERNAL` | Employees only | Business metrics, operational data |
38| `CONFIDENTIAL` | Specific groups | Customer PII, financial data |
39| `RESTRICTED` | Named individuals | Compensation, legal, M&A |
40
41### Step 2: PII Redaction in Transforms
42```python
43from transforms.api import transform_df, Input, Output
44from pyspark.sql import functions as F
45
46@transform_df(
47 Output("/Company/datasets/customers_safe"),
48 customers=Input("/Company/datasets/raw_customers"),
49)
50def redact_pii(customers):
51 """Create an analytics-safe view with PII removed."""
52 return (
53 customers
54 .withColumn("email", F.sha2(F.col("email"), 256)) # Hash email
55 .withColumn("phone", F.lit("***-***-****")) # Mask phone
56 .withColumn("ssn", F.lit(None).cast("string")) # Remove SSN
57 .withColumn("name", F.concat(
58 F.substring("first_name", 1, 1), F.lit("***") # First initial only
59 ))
60 .drop("first_name", "last_name", "address", "date_of_birth")
61 )
62```
63
64### Step 3: GDPR Right to Erasure
65```python
66def delete_user_data(client, user_id: str):
67 """GDPR Article 17: delete all data for a specific user."""
68 datasets_with_pii = [
69 "/Company/datasets/raw_customers",
70 "/Company/datasets/raw_orders",
71 "/Company/datasets/customer_communications",
72 ]
73 for dataset_path in datasets_with_pii:
74 # Trigger a transform that filters out the user
75 client.ontologies.Action.apply(
76 ontology="my-company",
77 action_type="gdprDeleteUser",
78 parameters={"userId": user_id, "datasetPath": dataset_path},
79 )
80 # Log the deletion for compliance
81 client.ontologies.Action.apply(
82 ontology="my-company",
83 action_type="logDeletionRequest",
84 parameters={
85 "userId": user_id,
86 "requestedAt": datetime.utcnow().isoformat(),
87 "status": "completed",
88 },
89 )
90```
91
92### Step 4: Column-Level Security in Ontology
93```python
94# Define object type with restricted properties
95# In Ontology Manager:
96# - fullName: marking = CONFIDENTIAL
97# - email: marking = CONFIDENTIAL
98# - department: marking = INTERNAL
99# - employeeId: marking = INTERNAL
100
101# Users without CONFIDENTIAL marking see:
102# employeeId, department (but NOT fullName, email)
103```
104
105### Step 5: Data Retention Policy
106```python
107@transform_df(
108 Output("/Company/datasets/events_retained"),
109 events=Input("/Company/datasets/raw_events"),
110)
111def apply_retention(events):
112 """Keep only last 2 years of data per retention policy."""
113 from pyspark.sql import functions as F
114 from datetime import datetime, timedelta
115
116 cutoff = (datetime.utcnow() - timedelta(days=730)).strftime("%Y-%m-%d")
117 return events.filter(F.col("event_date") >= cutoff)
118```
119
120## Output
121- PII-redacted datasets safe for analytics
122- GDPR deletion workflow with audit trail
123- Column-level security via Foundry Markings
124- Automated data retention enforcement
125
126## Error Handling
127| Compliance Risk | Detection | Mitigation |
128|----------------|-----------|------------|
129| PII in analytics dataset | Column scan | Apply redaction transform |
130| Stale data beyond retention | Date filter | Schedule retention transforms |
131| Missing deletion audit | Log review | Always log GDPR actions |
132| Over-permissive markings | Access audit | Review marking assignments quarterly |
133
134## Resources
135- [Foundry Markings](https://www.palantir.com/docs/foundry)
136- [Transforms Guide](https://www.palantir.com/docs/foundry/transforms-python/transforms)
137
138## Next Steps
139For access control, see `palantir-enterprise-rbac`.