Skip to content
NewDatafor 10.02 is out: subscriptions and metric alerts, in Slack and Teams
Datafor
Blog

A row-level rule can be right and still let the rows through

, Datafor team

Row-level security is usually reviewed one rule at a time. Someone opens the policy for the Northeast managers, reads “region equals Northeast”, agrees that it is right, and moves on.

The rule is right. Whether a particular person sees only Northeast rows depends on more than that rule: on which other rules also match them, on what happens when none does, and on who ran the test. This post goes through five situations where every rule is correct and the wrong rows still come back, using the rules Datafor applies. Other products make some of these choices differently, so check the documentation of whichever one you run.

The example

Larkwood, the retailer in Datafor’s sample data, has 25 stores in four regions. Over 2024 and 2025 its net sales were $11.09 million. Three people open the same sales report:

Who Should see Net sales
Finance director Every region $11,091,257
Northeast regional manager Five Northeast stores $2,617,247
Store manager, New York SoHo One store $767,055

The total on the page is the quickest check there is. If the regional manager’s report says $11.09 million, something below has happened.

1. An administrator ran the test

The built-in SuperUser and Administrator roles bypass data security entirely, both the row rules and the rules that hide tables and columns. An administrator who opens the report to check the new policy sees every row, as they did before the policy existed.

That result says nothing about the policy. Test with an ordinary account, or with Test access, described below. The same bypass is why an administrative role is the wrong way to give a finance director full access. A policy that returns all rows does that job and leaves the column rules in force.

2. No rule matches this person

In Datafor, a row policy restricts the people it names. If someone may query a table and no enabled row policy matches them, row-level security adds no restriction for that table.

So a policy for the Northeast managers does not keep everyone else out of the Northeast. A new analyst who has access to the report and belongs to none of the regional roles sees $11.09 million. The documentation calls this a coverage gap, and it is the first thing to look for when a role is created or a person changes teams.

The fix is to decide what each group that can open the report should get, including the groups with no regional role, and to write that down as policies.

3. Two roles add up

Policies that match the same person on the same table are combined with OR. A manager who holds both the Northeast and the South role gets the rows of both regions, $5,107,576 in this data by our arithmetic.

This is usually what was intended. The surprise comes when someone adds a second, narrower policy and expects it to tighten the first. It cannot: a rule only adds rows to what the person may already see. To narrow access, change or remove the broader policy, or put both conditions inside one policy, where they can be joined with AND.

One kind of policy overrides the others. If a “Return all rows” policy matches a person, the restrictive policies that also match them stop filtering that table.

4. A policy was switched off

A draft policy does nothing until it is enabled, and a disabled policy does nothing either. Disabling a person’s only matching policy puts them in situation 2, with no restriction at all.

This happens during maintenance: a policy is switched off while its condition is rewritten, and for that hour the Northeast managers see every region. Edit the policy in place, or create the replacement and enable it before disabling the old one.

5. The rows are reachable another way

A row policy belongs to one data source connection and one table or view. Three routes go around it.

A second connection to the same database is a different data source, and the policy on the first does not cover it. Review every connection a model uses.

In a model with several fact tables, a policy on a dimension table restricts a measure only if that measure’s own fact table joins the dimension. A rule on the customer table restricts sales measures and leaves inventory measures alone when inventory has no direct relationship to customers. Put the policy on a table each fact joins itself.

A filter on a report that readers can change is a convenience. It restricts nothing, however the page is laid out.

Testing as the person

Datafor’s Test access screen takes a user, a schema and a table, and shows what that user would get: the roles and user type it resolved, the effective condition after every matching policy is combined, which columns are visible, and the list of policies in effect. Testing a user is better than testing a role, because the result includes all of that person’s roles.

Before testing, confirm that the model has Apply data security switched on in its settings. It is on by default, and the policies have no effect on a model where someone has turned it off.

For the Northeast manager the effective condition should read as the single region. If it shows no condition, or two regions joined with OR, you are in situation 2 or 3 before anyone has opened a report.

Test access checks tables, and its data preview returns at most 50 rows, so it cannot prove that an unwanted row is absent. The last step is to sign in as an ordinary user and open the real report: read the total, clear the report’s filters, and try a measure from each fact table. Repeat it when memberships, policies or data sources change.

One set of rules for every way in

A rule that holds on the dashboard has to hold wherever the same data can be asked for. In Datafor the policies sit on the data source, below the model, so a dashboard, a report embedded in another product, an answer from the AI Agent and a question from Claude or ChatGPT over MCP all pass through them under the asker’s own account. The store manager gets $767,055 on every one of them.

That also means the five situations above apply everywhere at once. Test them once, carefully, as the people involved.

The rules in this post are set out in full, with a worked example you can reproduce, in Row-Level Security in Analytics. The Governance page shows the policy editor and Test access.