Operation
Class: Operation
Section titled “Class: Operation”Operations define custom SQL operations that don’t fit into the sqlanvil model of publishing a table or writing an assertion.
You can create operations in the following ways. Available config options are defined in OperationConfig, and are shared across all the following ways of creating operations.
Using a SQLX file:
-- definitions/name.sqlxconfig { type: "operations"}DELETE FROM dataset.table WHERE country = 'GB'Using action configs files:
actions:- operation: filename: name.sql-- definitions/name.sqlDELETE FROM dataset.table WHERE country = 'GB'Using the Javascript API:
operate("name").query("DELETE FROM dataset.table WHERE country = 'GB'")Note: When using the Javascript API, methods in this class can be accessed by the returned value.
This is where query comes from.
Hierarchy
Section titled “Hierarchy”-
ActionBuilder‹Operation›
↳ Operation
Methods
Section titled “Methods”- columns
- database
- dependencies
- description
- disabled
- hasOutput
- hermetic
- queries
- schema
- setDependOnDependencyAssertions
- tags
Methods
Section titled “Methods”columns
Section titled “columns”▸ columns(columns: ColumnDescriptor[]): this
deprecated Deprecated in favor of
OperationConfig.columns.
Sets the column descriptors of columns in this table.
Parameters:
| Name | Type |
|---|---|
columns | ColumnDescriptor[] |
Returns: this
database
Section titled “database”▸ database(database: string): this
deprecated Deprecated in favor of
OperationConfig.project.
Sets the database in which to create the corresponding view for this operation. For BigQuery targets this is the GCP project ID; for Postgres/Supabase targets this is the database name.
Parameters:
| Name | Type |
|---|---|
database | string |
Returns: this
dependencies
Section titled “dependencies”▸ dependencies(value: Resolvable | Resolvable[]): this
deprecated Deprecated in favor of
OperationConfig.dependencies.
Sets dependencies of the table.
Parameters:
| Name | Type |
|---|---|
value | Resolvable | Resolvable[] |
Returns: this
description
Section titled “description”▸ description(description: string): this
deprecated Deprecated in favor of
OperationConfig.description.
Sets the description of this assertion.
Parameters:
| Name | Type |
|---|---|
description | string |
Returns: this
disabled
Section titled “disabled”▸ disabled(disabled: boolean): this
deprecated Deprecated in favor of
OperationConfig.disabled.
If called with true, this action is not executed. The action can still be depended upon.
Useful for temporarily turning off broken actions.
Parameters:
| Name | Type | Default |
|---|---|---|
disabled | boolean | true |
Returns: this
hasOutput
Section titled “hasOutput”▸ hasOutput(hasOutput: boolean): this
deprecated Deprecated in favor of
OperationConfig.hasOutput.
Declares that this action creates a dataset which should be referenceable as a dependency
target, for example by using the ref function.
Parameters:
| Name | Type |
|---|---|
hasOutput | boolean |
Returns: this
hermetic
Section titled “hermetic”▸ hermetic(hermetic: boolean): void
deprecated Deprecated in favor of
OperationConfig.hermetic.
If true, this indicates that the action only depends on data from explicitly-declared dependencies. Otherwise if false, it indicates that the action depends on data from a source which has not been declared as a dependency.
Parameters:
| Name | Type |
|---|---|
hermetic | boolean |
Returns: void
queries
Section titled “queries”▸ queries(queries: Contextable‹IActionContext, string | string[]›): this
Sets the query/queries to generate the operation from.
Parameters:
| Name | Type |
|---|---|
queries | Contextable‹IActionContext, string | string[]› |
Returns: this
schema
Section titled “schema”▸ schema(schema: string): this
deprecated Deprecated in favor of
OperationConfig.dataset.
Sets the schema (BigQuery dataset / Postgres schema) in which to create the output of this action.
Parameters:
| Name | Type |
|---|---|
schema | string |
Returns: this
setDependOnDependencyAssertions
Section titled “setDependOnDependencyAssertions”▸ setDependOnDependencyAssertions(dependOnDependencyAssertions: boolean): this
deprecated Deprecated in favor of
OperationConfig.dependOnDependencyAssertions.
When called with true, assertions dependent upon any dependency will be add as dedpendency
to this action.
Parameters:
| Name | Type |
|---|---|
dependOnDependencyAssertions | boolean |
Returns: this
▸ tags(value: string | string[]): this
deprecated Deprecated in favor of
OperationConfig.tags.
Sets a list of user-defined tags applied to this action.
Parameters:
| Name | Type |
|---|---|
value | string | string[] |
Returns: this