Dataform Javascript API Reference › Globals › "core/actions/table" › Table
Tables are the fundamental building block for storing data when using Dataform. Dataform compiles your Dataform core code into SQL, executes the SQL code, and creates your defined tables in BigQuery.
You can create tables in the following ways. Available config options are defined in TableConfig, and are shared across all the following ways of creating tables.
Using a SQLX file:
-- definitions/name.sqlx
config {
type: "table"
}
SELECT 1Using action configs files:
# definitions/actions.yaml
actions:
- table:
filename: name.sql-- definitions/name.sql
SELECT 1Using the Javascript API:
// definitions/file.js
table("name", { type: "table" }).query("SELECT 1 AS TEST")Note: When using the Javascript API, methods in this class can be accessed by the returned value.
This is where query comes from.
-
ActionBuilder‹Table›
↳ Table
- assertions
- bigquery
- columns
- database
- dependencies
- description
- disabled
- hermetic
- postOps
- preOps
- query
- schema
- setDependOnDependencyAssertions
- tags
- type
▸ assertions(assertions: TableAssertionsConfig): this
deprecated Deprecated in favor of
TableConfig.assertions.
Sets in-line assertions for this table.
Parameters:
| Name | Type |
|---|---|
assertions |
TableAssertionsConfig |
Returns: this
▸ bigquery(bigquery: IBigQueryOptions): this
deprecated Deprecated in favor of options available directly on
TableConfig. For example:
publish("name", { type: "table", partitionBy: "column" }).
Sets bigquery options for the action.
Parameters:
| Name | Type |
|---|---|
bigquery |
IBigQueryOptions |
Returns: this
▸ columns(columns: ColumnDescriptor[]): this
deprecated Deprecated in favor of
TableConfig.columns.
Sets the column descriptors of columns in this table.
Parameters:
| Name | Type |
|---|---|
columns |
ColumnDescriptor[] |
Returns: this
▸ database(database: string): this
deprecated Deprecated in favor of
TableConfig.project.
Sets the database (Google Cloud project ID) in which to create the output of this action.
Parameters:
| Name | Type |
|---|---|
database |
string |
Returns: this
▸ dependencies(value: Resolvable | Resolvable[]): this
deprecated Deprecated in favor of
TableConfig.dependencies.
Sets dependencies of the table.
Parameters:
| Name | Type |
|---|---|
value |
Resolvable | Resolvable[] |
Returns: this
▸ description(description: string): this
deprecated Deprecated in favor of
TableConfig.description.
Sets the description of this assertion.
Parameters:
| Name | Type |
|---|---|
description |
string |
Returns: this
▸ disabled(disabled: boolean): this
deprecated Deprecated in favor of
TableConfig.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
▸ hermetic(hermetic: boolean): void
deprecated Deprecated in favor of
TableConfig.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
▸ postOps(posts: Contextable‹ITableContext, string | string[]›): this
Sets a post-operation to run after the query is run. This is often used for revoking temporary permissions granted to access source tables.
Example:
// definitions/file.js
publish("example")
.preOps(ctx => `GRANT \`roles/bigquery.dataViewer\` ON TABLE ${ctx.ref("other_table")} TO "group:automation@example.com"`)
.query(ctx => `SELECT * FROM ${ctx.ref("other_table")}`)
.postOps(ctx => `REVOKE \`roles/bigquery.dataViewer\` ON TABLE ${ctx.ref("other_table")} TO "group:automation@example.com"`)Parameters:
| Name | Type |
|---|---|
posts |
Contextable‹ITableContext, string | string[]› |
Returns: this
▸ preOps(pres: Contextable‹ITableContext, string | string[]›): this
Sets a pre-operation to run before the query is run. This is often used for temporarily granting permission to access source tables.
Example:
// definitions/file.js
publish("example")
.preOps(ctx => `GRANT \`roles/bigquery.dataViewer\` ON TABLE ${ctx.ref("other_table")} TO "group:automation@example.com"`)
.query(ctx => `SELECT * FROM ${ctx.ref("other_table")}`)
.postOps(ctx => `REVOKE \`roles/bigquery.dataViewer\` ON TABLE ${ctx.ref("other_table")} TO "group:automation@example.com"`)Parameters:
| Name | Type |
|---|---|
pres |
Contextable‹ITableContext, string | string[]› |
Returns: this
▸ query(query: Contextable‹ITableContext, string›): this
Sets the query to generate the table from.
Parameters:
| Name | Type |
|---|---|
query |
Contextable‹ITableContext, string› |
Returns: this
▸ schema(schema: string): this
deprecated Deprecated in favor of
TableConfig.dataset.
Sets the schema (BigQuery dataset) in which to create the output of this action.
Parameters:
| Name | Type |
|---|---|
schema |
string |
Returns: this
▸ setDependOnDependencyAssertions(dependOnDependencyAssertions: boolean): this
deprecated Deprecated in favor of
TableConfig.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
TableConfig.tags.
Sets a list of user-defined tags applied to this action.
Parameters:
| Name | Type |
|---|---|
value |
string | string[] |
Returns: this
▸ type(type: TableType): this
deprecated
Deprecated in favor of action type can being set in the configs passed to action constructor
functions, for example publish("name", { type: "table" }).
Parameters:
| Name | Type |
|---|---|
type |
TableType |
Returns: this