You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+96-11Lines changed: 96 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,32 @@ This package is designed to optimize BigQuery resource usage by automatically as
13
13
***Automated re-assignement**: Once configured, reservations are applied automatically based on action categorization
14
14
***Flexible configuration**: Easy adjustment of reservation policies through configuration updates
15
15
16
+
## Compatibility
17
+
18
+
This package is tested and compatible with:
19
+
20
+
***Dataform v2.4.2** (v2.x series)
21
+
***Dataform v3.0.42** (v3.x series)
22
+
23
+
### Testing Across Versions
24
+
25
+
To verify compatibility locally across all supported Dataform versions:
26
+
27
+
```bash
28
+
npm test
29
+
```
30
+
31
+
This command runs the matrix test suite which automatically:
32
+
1. Iterates through all supported Dataform versions (v2 and v3).
33
+
2. Manages configuration file conflicts (e.g., hiding `dataform.json` for v3).
34
+
3. Executes unit tests and integration tests.
35
+
36
+
For faster iteration on the currently installed version in `test-project`, you can run:
37
+
38
+
```bash
39
+
npm run test:single
40
+
```
41
+
16
42
## Getting Started
17
43
18
44
### Initial Setup
@@ -29,28 +55,56 @@ Add the dependency to your `package.json`:
29
55
30
56
and click **Install Packages** in Dataform UI.
31
57
32
-
Then, import the package and create a setter function in your global scope under `/includes` directory:
58
+
### Recommended: Automatic Application
59
+
60
+
The easiest way to integrate this package is to use automatic reservation application. Create a configuration file (e.g., `definitions/_reservations.js`) that will automatically apply reservations to all matching actions:
**Note:** If you have many files in the project we recommend to start the filename with an underscore (e.g., `_reservations.js`) to ensure it runs first in the Dataform queue.
85
+
86
+
With automatic application, you don't need to add any reservation code to your individual action files — the package handles everything globally.
87
+
88
+
### Alternative: Manual Application
89
+
90
+
For more granular control, you can manually apply reservations per file. Create a setter function in your global scope under `/includes` directory:
***actions**: Array of Dataform action names that are assigned to the reservation
90
144
91
-
### Usage examples
145
+
### Usage Examples (Manual Application)
146
+
147
+
**Note:** These examples are only needed if you're using the manual application approach. With automatic application via `applyAutomaticReservations()`, reservations are applied automatically and you don't need to add these calls to your action files.
92
148
93
149
#### `publish` actions
94
150
@@ -154,7 +210,36 @@ WHEN NOT MATCHED THEN INSERT (id, value) VALUES (S.id, S.value);
154
210
`);
155
211
```
156
212
157
-
Example implementation can be found in [https://github.com/HTTPArchive/dataform](https://github.com/HTTPArchive/dataform).
213
+
## API Reference
214
+
215
+
### `applyAutomaticReservations(config)`
216
+
217
+
**Primary Method** - Automatically applies reservation configurations to all actions in your Dataform project.
218
+
219
+
***Parameters:**
220
+
*`config` (Array): Array of reservation configuration objects
221
+
***Returns:**`void`
222
+
***Usage:** Call once in a definitions file (e.g., `definitions/_reservations.js`)
223
+
***Behavior:** Automatically intercepts all `publish()`, `operate()`, and `assert()` calls and applies appropriate reservations based on action names
224
+
225
+
### `createReservationSetter(config)`
226
+
227
+
**Secondary Method** - Creates a reservation setter function for manual application per action.
228
+
229
+
***Parameters:**
230
+
*`config` (Array): Array of reservation configuration objects
231
+
***Returns:**`Function` - A setter function that accepts a Dataform context and returns the appropriate `SET @@reservation` SQL statement
232
+
***Usage:** Create in an includes file, then call in individual action files using `${reservation_setter(ctx)}`
233
+
***Use Case:** When you need fine-grained control over which actions get reservations
234
+
235
+
### `getActionName(ctx)`
236
+
237
+
**Utility Method** - Extracts the action name from a Dataform context object.
238
+
239
+
***Parameters:**
240
+
*`ctx` (Object): Dataform context object
241
+
***Returns:**`string|null` - The action name in format `database.schema.name`, or `null` if not found
242
+
***Usage:** Advanced use cases where you need to programmatically determine action names
0 commit comments