Skip to content

lake: refine data protection policy guide docs#23314

Merged
ti-chi-bot[bot] merged 2 commits into
pingcap:release-8.5from
lilin90:lake-0719
Jul 21, 2026
Merged

lake: refine data protection policy guide docs#23314
ti-chi-bot[bot] merged 2 commits into
pingcap:release-8.5from
lilin90:lake-0719

Conversation

@lilin90

@lilin90 lilin90 commented Jul 21, 2026

Copy link
Copy Markdown
Member

What is changed, added or deleted? (Required)

Reworked the Lake data protection documentation for clarity and faster onboarding: simplified the main data protection overview, condensed masking and row access guides into quick-start and example-driven sections, and clarified policy interactions, limits, and privilege requirements.

Also added a vector search cross-reference showing how row access policies enforce role-based document visibility in RAG/search workflows.

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions.

  • master (the latest development version)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)

What is the related PR or file link(s)?

  • This PR is translated from:
  • Other reference link(s):

AI agent involvement

  • The changes in this PR were primarily made by an AI agent on behalf of the PR author.

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

Summary by CodeRabbit

  • Documentation
    • Rewrote the Data Protection Policies, Masking Policy, and Row Access Policy guides into shorter, better-structured sections with clearer “when to use” guidance.
    • Added quick-start walkthroughs and refreshed policy comparisons, management steps, limits, and best-practice checklists.
    • Expanded role-based row visibility, time-window access, JSON key masking, and read/write behavior examples (including detach/drop verification flows).
    • Added guidance to restrict Vector/RAG and vector search results using Row Access Policies.

Reworked the Lake data protection documentation for clarity and faster onboarding: simplified the main data protection overview, condensed masking and row access guides into quick-start and example-driven sections, and clarified policy interactions, limits, and privilege requirements. Also added a vector search cross-reference showing how row access policies enforce role-based document visibility in RAG/search workflows.
@lilin90
lilin90 requested a review from awxxxxxx July 21, 2026 03:20
@lilin90 lilin90 self-assigned this Jul 21, 2026
@lilin90 lilin90 added translation/no-need No need to translate this PR. lake Related to TiDB Cloud Lake docs. labels Jul 21, 2026
@ti-chi-bot ti-chi-bot Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 21, 2026
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: cd2fdd85-388f-4466-9fe5-177def1d4466

📥 Commits

Reviewing files that changed from the base of the PR and between 65b8e5c and 0a0602e.

📒 Files selected for processing (1)
  • tidb-cloud-lake/guides/row-access-policy.md

📝 Walkthrough

Walkthrough

Changes

The PR restructures four data protection guides with shorter explanations, updated SQL examples, revised policy behavior documentation, and expanded row-access guidance for Vector/RAG and role-based time windows.

Data Protection Policy Documentation

Layer / File(s) Summary
Masking policy workflow
tidb-cloud-lake/guides/masking-policy.md
Adds quick-start and conditional masking examples, updates VARIANT masking and read/write behavior, and revises management, limits, practices, privileges, and references.
Row access fundamentals
tidb-cloud-lake/guides/row-access-policy.md
Condenses the introduction and quick start, documents policy mechanics and multi-column mapping, and updates enablement and attachment guidance.
Row access examples and operations
tidb-cloud-lake/guides/row-access-policy.md, tidb-cloud-lake/guides/vector-search-guide.md
Reworks Vector/RAG and time-range examples, DML behavior, policy management, limits, best practices, references, and vector-search visibility guidance.
Combined policy guidance
tidb-cloud-lake/guides/data-protection-policies.md
Adds policy-selection and execution-order explanations and replaces the longer walkthrough with a condensed separation-of-duties example.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main doc refinement in the PR.
Description check ✅ Passed The description covers the required change summary and affected version, with only non-critical reference fields left blank.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4c8dbf3b-66c2-41d5-9ec8-89eca82943ef

📥 Commits

Reviewing files that changed from the base of the PR and between e1c43af and 65b8e5c.

📒 Files selected for processing (4)
  • tidb-cloud-lake/guides/data-protection-policies.md
  • tidb-cloud-lake/guides/masking-policy.md
  • tidb-cloud-lake/guides/row-access-policy.md
  • tidb-cloud-lake/guides/vector-search-guide.md

Comment thread tidb-cloud-lake/guides/data-protection-policies.md
Comment thread tidb-cloud-lake/guides/data-protection-policies.md
Comment thread tidb-cloud-lake/guides/masking-policy.md
Comment thread tidb-cloud-lake/guides/masking-policy.md
Comment on lines +68 to +78
Multi-column policy:

```sql
SET enable_experimental_row_access_policy = 1;

DROP TABLE IF EXISTS rap_dml_orders;
DROP TABLE IF EXISTS rap_dml_src;
DROP ROW ACCESS POLICY IF EXISTS rap_sales_only;

CREATE ROW ACCESS POLICY rap_sales_only
AS (dept STRING)
RETURNS BOOLEAN -> dept = 'sales';

CREATE TABLE rap_dml_orders(id INT, dept STRING, amount INT);
ALTER TABLE rap_dml_orders ADD ROW ACCESS POLICY rap_sales_only ON (dept);

-- INSERT is not affected: both visible and invisible rows are stored.
INSERT INTO rap_dml_orders VALUES
(1, 'sales', 100),
(2, 'eng', 200),
(3, 'sales', 300);

-- SELECT is affected: only policy-visible rows are returned.
SELECT id, dept, amount FROM rap_dml_orders ORDER BY id;

id | dept | amount
---|-------|-------
1 | sales | 100
3 | sales | 300

-- Detach only for inspection: the inserted 'eng' row exists.
ALTER TABLE rap_dml_orders DROP ROW ACCESS POLICY rap_sales_only;
SELECT id, dept, amount FROM rap_dml_orders ORDER BY id;

id | dept | amount
---|-------|-------
1 | sales | 100
2 | eng | 200
3 | sales | 300

ALTER TABLE rap_dml_orders ADD ROW ACCESS POLICY rap_sales_only ON (dept);

-- UPDATE is affected: only visible target rows are updated.
UPDATE rap_dml_orders SET amount = amount + 10;

ALTER TABLE rap_dml_orders DROP ROW ACCESS POLICY rap_sales_only;
SELECT id, dept, amount FROM rap_dml_orders ORDER BY id;

id | dept | amount
---|-------|-------
1 | sales | 110
2 | eng | 200
3 | sales | 310

ALTER TABLE rap_dml_orders ADD ROW ACCESS POLICY rap_sales_only ON (dept);

-- DELETE is affected: invisible target rows are not deleted.
DELETE FROM rap_dml_orders WHERE dept = 'eng';

ALTER TABLE rap_dml_orders DROP ROW ACCESS POLICY rap_sales_only;
SELECT id, dept, amount FROM rap_dml_orders ORDER BY id;

id | dept | amount
---|-------|-------
1 | sales | 110
2 | eng | 200
3 | sales | 310

ALTER TABLE rap_dml_orders ADD ROW ACCESS POLICY rap_sales_only ON (dept);

-- DELETE still affects visible target rows.
DELETE FROM rap_dml_orders WHERE id = 1;
CREATE ROW ACCESS POLICY rap_region_dept
AS (region STRING, dept STRING)
RETURNS BOOLEAN ->
region = 'APAC' AND dept = 'Engineering';

ALTER TABLE rap_dml_orders DROP ROW ACCESS POLICY rap_sales_only;
SELECT id, dept, amount FROM rap_dml_orders ORDER BY id;
ALTER TABLE employees
ADD ROW ACCESS POLICY rap_region_dept ON (office_region, department);
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== .ai/AI-README.md ==\n'
sed -n '1,220p' .ai/AI-README.md

printf '\n== .ai/shared ==\n'
fd -t f . .ai/shared | sort | sed -n '1,200p'

printf '\n== .ai/skills ==\n'
fd -t f . .ai/skills | sort | sed -n '1,200p'

printf '\n== target file outline ==\n'
ast-grep outline tidb-cloud-lake/guides/row-access-policy.md --view expanded || true

printf '\n== target file excerpt ==\n'
sed -n '1,380p' tidb-cloud-lake/guides/row-access-policy.md

Repository: pingcap/docs

Length of output: 234


🏁 Script executed:

sed -n '1,220p' .ai/AI-README.md

Repository: pingcap/docs

Length of output: 210


🌐 Web query:

TiDB row access policy only one row access policy per table multi-column ALTER TABLE ADD ROW ACCESS POLICY ON

💡 Result:

In TiDB, a table can have at most one row access policy attached to it at any given time [1][2]. Consequently, you cannot add multiple row access policies to a single table [1]. If you need to implement complex filtering logic that involves multiple conditions, the recommended approach is to define a single row access policy that incorporates all required conditions using Boolean logic within the policy's predicate expression [3]. When using the ALTER TABLE ADD ROW ACCESS POLICY statement, you can map multiple table columns to the policy's arguments [1]. These columns are bound to the policy arguments by position rather than by name [1][2]. For example: CREATE ROW ACCESS POLICY rap_example AS (arg1 STRING, arg2 STRING) RETURNS BOOLEAN -> arg1 = 'Value1' AND arg2 = 'Value2'; ALTER TABLE my_table ADD ROW ACCESS POLICY rap_example ON (column1, column2); To change or update a policy, you must first drop the existing policy using DROP ROW ACCESS POLICY or DROP ALL ROW ACCESS POLICIES before adding a new one, as CREATE OR REPLACE and ALTER ROW ACCESS POLICY operations are not supported [1][2].

Citations:


Make the multi-column example use its own table.
employees can have only one row access policy, so this example should not attach a second policy to the same table.

Committable suggestion
-Multi-column policy:
+Multi-column policy (use a separate table):
 
 ```sql
 CREATE ROW ACCESS POLICY rap_region_dept
 AS (region STRING, dept STRING)
 RETURNS BOOLEAN ->
   region = 'APAC' AND dept = 'Engineering';
 
-ALTER TABLE employees
+CREATE TABLE employee_locations (
+  office_region STRING,
+  department STRING
+);
+
+ALTER TABLE employee_locations
 ADD ROW ACCESS POLICY rap_region_dept ON (office_region, department);
</details>

<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

```suggestion
Multi-column policy (use a separate table):

Source: Path instructions

Comment on lines +129 to +130
GRANT SELECT ON knowledge_docs TO ROLE sales;
GRANT SELECT ON knowledge_docs TO ROLE finance;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== .ai files ==\n'
git ls-files .ai | sed -n '1,200p'

printf '\n== .ai/AI-README.md ==\n'
sed -n '1,220p' .ai/AI-README.md

printf '\n== .ai/shared (if present) ==\n'
find .ai/shared -maxdepth 1 -type f | sort | sed -n '1,200p'

printf '\n== .ai/skills (if present) ==\n'
find .ai/skills -maxdepth 2 -type f | sort | sed -n '1,200p'

printf '\n== target file outline ==\n'
wc -l tidb-cloud-lake/guides/row-access-policy.md
sed -n '1,240p' tidb-cloud-lake/guides/row-access-policy.md

Repository: pingcap/docs

Length of output: 251


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== file size and relevant range ==\n'
wc -l tidb-cloud-lake/guides/row-access-policy.md
sed -n '1,220p' tidb-cloud-lake/guides/row-access-policy.md

printf '\n== search for admin role references in this guide ==\n'
rg -n "ROLE admin|admin sees|admin" tidb-cloud-lake/guides/row-access-policy.md

printf '\n== search for knowledge_docs grants in repo ==\n'
rg -n "GRANT SELECT ON knowledge_docs TO ROLE" tidb-cloud-lake -g '*.md'

Repository: pingcap/docs

Length of output: 7428


Grant admin SELECT on knowledge_docs.

The visibility table says admin sees all rows, but the example only grants SELECT to sales and finance. Add the missing grant so the admin role can query the table too.

Committable replacement
+GRANT SELECT ON knowledge_docs TO ROLE admin;
 GRANT SELECT ON knowledge_docs TO ROLE sales;
 GRANT SELECT ON knowledge_docs TO ROLE finance;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
GRANT SELECT ON knowledge_docs TO ROLE sales;
GRANT SELECT ON knowledge_docs TO ROLE finance;
GRANT SELECT ON knowledge_docs TO ROLE admin;
GRANT SELECT ON knowledge_docs TO ROLE sales;
GRANT SELECT ON knowledge_docs TO ROLE finance;

Source: Path instructions

Comment thread tidb-cloud-lake/guides/row-access-policy.md Outdated
@ti-chi-bot

ti-chi-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

@awxxxxxx: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@lilin90 lilin90 added the lgtm label Jul 21, 2026
@lilin90

lilin90 commented Jul 21, 2026

Copy link
Copy Markdown
Member Author

/approve

@ti-chi-bot

ti-chi-bot Bot commented Jul 21, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lilin90

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the approved label Jul 21, 2026
@ti-chi-bot
ti-chi-bot Bot merged commit 281b43b into pingcap:release-8.5 Jul 21, 2026
11 of 12 checks passed
@lilin90
lilin90 deleted the lake-0719 branch July 21, 2026 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lake Related to TiDB Cloud Lake docs. lgtm size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. translation/no-need No need to translate this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants