Usage
sql_create: {
SQL statement ;;
}
}
Hierarchysql_create |
Default ValueNoneAcceptsA SQL statement |
Definition
sql_create
enables custom Data Definition Language (DDL) commands for building persistent derived tables (PDTs). sql_create
will issue a statement as is, without Looker’s usual error checking. The only requirement is that the statement results in the creation and execution of a PDT. This lets you, for example, create PDTs that support Google’s BigQuery ML (BQML) machine learning models.
For PDTs defined using sql_create
, you cannot use any of the following parameters:
Examples
Create a PDT for BQML queries that predict likelihood of future purchases:
Things to consider
${SQL_TABLE_NAME}
substitution operator
You can use the ${SQL_TABLE_NAME}
substitution operator to substitute in the computed name of the PDT being created. This ensures the SQL statement will correctly include the PDT name given in the LookML view
parameter.
sql_create
must create a table with the name indicated by the${SQL_TABLE_NAME}
substitution operator, or it will be rebuilt from scratch on every trigger check interval specified in a connection’s PDT and Datagroup Maintenance Schedule setting (the default is five minutes). This can cause unexpected query traffic on your database or data warehouse.
Use create_process
to create a PDT in multiple steps
If your database dialect requires custom DDL commands, and you want to issue multiple commands to create a PDT, you can use create_process
to issue multiple custom DDL commands in a specific order.
Tables defined with sql_create
can’t be used for incremental PDTs
To be used as an incremental PDT, a SQL-based PDT must have a query defined using the sql
parameter. SQL-based PDTs that are defined with the sql_create
parameter or the create_process
parameter cannot be incrementally built.
This is because Looker uses an INSERT or a MERGE command to create the increments for an incremental PDT. The derived table cannot be defined using custom Data Definition Language (DDL) statements, since Looker wouldn’t be able to determine which DDL statements would be required to create an accurate increment.