# Row-level security and column masking on a lakehouse: how to design policies that hold

> In DataNature, row-level security is a SQL predicate per user or group, and column masking is a mask type per column: null, redact, first or last four, hash, year only or exempt. Atlas enforces both in the interactive SQL and serving compute (Trino and DN Warehouse), in JDBC clients, cubes and impersonating Superset connections, within about a minute of a change.

Source: https://datanature.ai/blog/lakehouse-row-level-security-column-masking
Publisher: Dlytica Inc. (DataNature is a Dlytica company)
Updated: 2026-11-05

Fine-grained access control is where many lakehouse projects get audited, and where many quietly fail. The policy looks right in the console, but a notebook, a cached dashboard or a shared service account reads around it. This guide explains how row filters and column masks work in DataNature, exactly where they are enforced, and the design rules that keep them from leaking.

## What are row filters and column masks?

A **row filter** limits which rows a user or group can see, using a SQL predicate such as `branch_code = 'KTM'` or `province = 'ON'`. A **column mask** changes what a user sees in a column without changing the stored data. Together they let one Gold table serve a branch manager, an analyst and a regulator, each with the right view.

## Which mask types are available?

| Mask | What the user sees | Typical use |
|---|---|---|
| Null | `NULL` | Fields a role should never see, such as national ID |
| Redact | Every character replaced | Free-text notes |
| Show last 4 | `****1234` | Account and card references for support staff |
| Show first 4 | `5412****` | Routing or prefix analysis |
| Hash | A consistent hash | Joins and counts on customer IDs without revealing them |
| Year only | `1987` | Age-band analytics on dates of birth |
| Exempt | Clear value | Named roles with a business need, such as fraud investigators |

Hash is the mask analysts miss most: because the same input always gives the same output, masked keys still join across tables and still count distinct customers.

## Where are policies enforced, and where are they not?

This is the part to read twice.

| Surface | Row filters and masks applied per user? |
|---|---|
| SQL workbench, Lakehouse (Trino) tab and its CSV export | Yes |
| External JDBC clients (for example DBeaver) through the query endpoint | Yes |
| Semantic-layer cubes, through Cube Security | Yes |
| Superset pre-configured `lakehouse` and `warehouse` connections (impersonation on) | Yes |
| Superset connections added by hand, unless "Impersonate logged-in user" is ticked | No |
| SQL workbench, DN Warehouse tab | No, workspace-level identity |
| Voir lakehouse connector | No, read-only service account; limit with twin scope |
| Notebooks, Spark and dbt | No; control with page access |

The rule that follows: **people who must only see filtered data should only have access to the enforced surfaces.** Analysts who need notebooks either work on already-masked tables or get page access to notebooks only for data they are cleared for.

## How should you design policies for a bank or insurer?

1. **Mirror the org chart in groups.** Create groups in Settings → Organization (branch staff, regional managers, risk, fraud, data engineering) and grant to groups, never to individuals.
2. **Mask PII in Bronze and Silver too.** Analysts can reach every layer through SQL; masking only Gold leaves the raw copy open.
3. **Scope every policy.** Apply row filters to specific schemas and tables, not `*` / `*` / `*`.
4. **Use hash for identifiers, null for secrets.** Customer IDs hashed for analytics; national IDs nulled for everyone outside a named exempt group.
5. **Put row predicates on cubes** with Cube Security so semantic-layer answers, including Voir answers through cubes, follow the same rule.
6. **Disable caching per user** in Superset for datasets with row filters, so one viewer's cached result is never served to another.

## How do you roll out policies safely?

Two mistakes have hidden all data from every user in real deployments: a row filter on every table with an invalid predicate, and a null mask on a whole catalog. Users saw only the `default` schema, with no error. To avoid that:

- Write predicates as valid SQL booleans over the table's real columns.
- Test with a non-admin account. Admins and owners bypass many rules, so an admin test proves nothing.
- Disable a policy while testing instead of deleting it, so you can restore it exactly.
- Expect a 30 to 60 second delay before changes apply.
- Check the Audit tab after go-live to confirm who accessed what.

## How does this compare with Unity Catalog or Snowflake policies?

Conceptually it is the same model: row filters as predicates, masks per column, grants on securables. The practical differences are where it runs and how it is expressed. DataNature policies are configured per engine (Lakehouse or DN Warehouse) in the [Atlas](/platform/atlas) console using predefined mask types, and they run inside your deployment, so the policy store and its audit log never leave your jurisdiction.

## Frequently asked questions

### Do masks change the stored data?

No. Masks apply at query time. The stored value is unchanged, so exempt users and approved processes still see it.

### Can masked columns still be joined?

Yes, with the hash mask. It is consistent, so the same value always produces the same hash.

### Does Voir respect row filters?

Through cubes, yes: Cube Security predicates apply to every cube query. Through the direct lakehouse connector, Voir uses a read-only service account, so limit each twin's table scope to what its audience may see.

## Sources

- [DataNature documentation: access and policies](https://docs.datanature.ai/docs/developers/governance/access-and-policies)
- [DataNature documentation: BI, Voir AI and ML tools](https://docs.datanature.ai/docs/developers/ai-and-analytics/bi-voir-ml-tools)
- [DataNature documentation: semantic layer](https://docs.datanature.ai/docs/developers/data-management/data-warehouse/semantic-layer)

## How does DataNature Atlas keep this secure and compliant?

Every rule in this article is enforced in one place, inside your jurisdiction. [DataNature Atlas](/platform/atlas) is the platform's governance module:

- **Knows your data**: a catalog with automated PII detection and classification across Bronze, Silver and Gold.
- **Controls access**: role-based grants plus attribute-based policies, row filters and column masks (null, redact, partial, hash, year only).
- **Governs AI**: Voir agents are scoped principals; masks, row filters and PII guardrails apply to every tool call and answer.
- **Proves it**: lineage from source to metric to decision, and an audit log of who or what accessed which data.
- **Stays local**: Atlas runs inside your deployment, so policies, lineage and logs never leave your jurisdiction.

These controls support GDPR, PIPEDA, Quebec Law 25, CCPA, HIPAA and sector rules such as OSFI E-23. Read [DataNature Atlas in depth](/blog/datanature-atlas-governance-rbac-abac-pii-masking) or see [security and compliance](/security).
