Row-level security management
You can use natural language instructions to direct code agents, such as Qoder and CodeX, to create, update, delete, and run multi-dimensional queries on row-level security policies in Dataphin. This capability lets you control the visibility of data rows based on field values. This document describes this capability's features, prerequisites, usage examples, and execution results. An appendix lists the required input information.
Overview
The row-level security management capability lets you use natural language instructions to manage the lifecycle of row-level security policies in Dataphin. Common operations include creating, updating, and deleting policies, performing paginated queries, querying policies by table or user, and querying authorized accounts for a specific rule. Row-level security is used to control data row visibility based on field values. For example, you can allow specific users to view order data only for the East China region.
Use cases:
-
Limit certain users or accounts to viewing only data rows that meet specific conditions based on field values.
-
Create or maintain the control fields, filter rules, and associated tables for a row-level security policy.
-
Find which row-level security policies apply to a specific table or user.
-
Query the accounts authorized for a specific row-level security rule.
Limitations: Row-level security does not provide separate commands for publishing or taking policies online or offline. Whether a policy takes effect at runtime depends on its configuration, authorization requests, approvals, and cache synchronization. A successful creation or update does not guarantee that the policy is immediately active at runtime. When updating, you must provide the complete set of control fields, rules, and associated tables; otherwise, you risk clearing the existing configuration. Deletions are irreversible. The agent typically confirms that there are no pending approval requests or downstream dependencies before deleting a policy.
Prerequisites
-
You have the target tenant ID.
-
The current caller has permissions to manage row-level security.
-
The target physical table must already have metadata. This includes its identifier, control fields, associated project, business segment, and data source.
Examples
You can describe your requirements to the agent directly in natural language. The following are example instructions you can copy and use:
-
Find row-level security policies in the current tenant whose names contain "East China orders".
-
Create a row-level security policy for the orders table to allow viewing only data rows where the region is East China.
-
Update the filter rule of a row-level security policy to expand visibility to include East China and South China.
-
Find which row-level security policies are bound to a specific table.
-
Find which row-level security policies a specific user has.
-
Query the authorized accounts for a specific row-level security rule.
-
Delete a row-level security policy that is no longer in use.
Interaction steps:
-
The agent typically starts by confirming the target tenant, the name of the row-level security policy, and the metadata of the associated table. This metadata includes the table identifier, control fields, project, business segment, and data source.
-
Before creating a policy, the agent usually checks if a policy with the same name already exists to avoid duplicate configurations.
-
After a successful creation, the agent typically queries for the new policy ID because the create operation returns only a success status, not the ID itself.
-
Before an update, the agent typically reads the existing configuration and repopulates the control fields, rules, and associated tables to avoid accidentally clearing existing content.
-
Before performing write operations such as create, update, or delete, the agent confirms the rule content, associated tables, and scope of impact with you. Before deletion, it also confirms there are no pending approval requests or downstream dependencies.
Execution results
Once the operation is complete, the following results are returned:
-
Return content: Create, update, and delete operations return a success or failure status. The create operation does not return a policy ID; you must query for it.
-
Completion status: The status is determined by the success flag returned by the command.
-
Viewing and verification: You can use a paginated query, a query by table, or a query by user to verify that the rules, control fields, associated tables, and authorized accounts are configured as expected.
A success message from the command line only indicates that the request has been accepted. The runtime filtering effect also depends on authorization requests, approvals, and cache synchronization. Always refer to the Dataphin UI for the final, effective status.
Appendix: Input information
The following table lists the information that you might need to manage row-level security. This list is for reference only. In practice, the agent automatically identifies the required information based on your instruction and prompts you if anything is missing. You do not need to provide items marked as not required because the system generates them automatically.
|
Parameter |
Required |
Description |
Example |
|
Tenant ID |
Conditionally required |
Omit this if it is already specified in your credentials. |
1234567890123456789 |
|
Row-level security ID |
Required for updates and deletions |
The create operation only returns a success status. You must query to obtain the ID. |
— |
|
Row-level security name |
Required for creation and updates |
The policy name. Before creating a policy, query by name to avoid duplicates. |
East China Orders RLS Policy |
|
Control field |
Required for creation and updates |
The field used to control the visibility of data rows. |
region |
|
Filter rule |
No |
The filter condition for data rows. Authorization can be granted based on a range of field values. |
region is 'East China' |
|
Associated table |
No |
The target table to which the policy applies. It must include metadata such as the table identifier, project, business segment, and data source. |
— |
|
User or operator |
Required when querying by user |
The user or account whose row-level security policies you want to query. |
— |