A GitHub action to create or update a subsetting rule for a table in a Tonic Structural workspace.
The subsetting rule configures the table either as a target table or a lookup table.
For a target table, to specify how to select the rows to include in the subset, you either:
- Provide a
WHEREclause to identify the rows to select. - Specify a percentage of the rows.
| Input | Description | Required | Default |
|---|---|---|---|
structural-url |
URL to Tonic Structural. For example: https://app.tonic.ai |
No | https://app.tonic.ai |
structural-api-key |
API key for authentication. Stored as a secret. | Yes | - |
workspace-id |
Identifier of the workspace to apply the subsetting rule to. | Yes | - |
schema |
Name of the database schema that contains the affected table. Case-sensitive. | Yes | - |
table |
Name of the affected table. Case-sensitive. | Yes | - |
where-clause |
For a target table, a SQL WHERE clause to filter the included rows. Do not include the WHERE keyword. Mutually exclusive with percent and ignore-upstream-tables. |
No* | - |
percent |
For a target table, the percentage of rows to include. Value is 0-100, and decimal values are allowed. Mutually exclusive with where-clause and ignore-upstream-tables. |
No* | - |
ignore-upstream-tables |
If true, treats the table as a lookup table. A lookup table includes all rows and ignores upstream rules. Mutually exclusive with where-clause and percent. |
No* | false |
* Note: You must provide exactly one of either where-clause, percent, or ignore-upstream-tables.
- name: Update subsetting rule with WHERE clause
uses: TonicAI/structural-update-subsetting-rule@v1
with:
structural-api-key: ${{ secrets.TONIC_API_KEY }}
workspace-id: 'your-workspace-id'
schema: 'public'
table: 'users'
where-clause: 'created_at > NOW() - INTERVAL ''90 days'''- name: Update subsetting rule with percentage value
uses: TonicAI/structural-update-subsetting-rule@v1
with:
structural-api-key: ${{ secrets.TONIC_API_KEY }}
workspace-id: 'your-workspace-id'
schema: 'public'
table: 'users'
percent: '25.5'- name: Mark table as a lookup table
uses: TonicAI/structural-update-subsetting-rule@v1
with:
structural-api-key: ${{ secrets.TONIC_API_KEY }}
workspace-id: 'your-workspace-id'
schema: 'public'
table: 'countries'
ignore-upstream-tables: 'true'-
Mutually exclusive inputs: You must provide exactly one of:
where-clause: For conditional row filteringpercent: For percentage-based samplingignore-upstream-tables: For lookup tables that should include all rows
-
Schema/table matching: The action uses
schemaandtableto identify existing rules. If a rule exists for that combination of schema and table, it is updated. Otherwise, a new rule is created. -
Case sensitivity: Depending on your database type, schema and table names might be case-sensitive. Always match the exact case used in your database.
-
Child workspaces: When applying rules to a child workspace, inheritance from the parent workspace is automatically broken, and all of the inherited rules are copied to the child.
-
WHERE clause: Do not include the
WHEREkeyword in your clause. Only provide the condition. For example,id > 100, notWHERE id > 100. -
Percentage values: The
percentinput accepts decimal values. For example,25.5indicates to use 25.5% of the rows. -
Lookup tables: When
ignore-upstream-tablesistrue, the table is treated as a lookup or reference table. The subset includes all of the lookup table rows are included regardless of any upstream relationships.
npm installnpm run packageThis uses @vercel/ncc to compile the action into a single file in the dist folder.
Before you publish, make sure to:
- Build the action:
npm run package - Commit the
distfolder to the repository - Tag your release:
git tag -a v1 -m "Release v1" - Push the tag:
git push origin v1