ralsei.task.add_columns_sql
¶
Module Contents¶
Classes¶
Adds the specified Columns to an existing Table and runs the SQL script to fill them with data |
API¶
- class ralsei.task.add_columns_sql.AddColumnsSql¶
Bases:
ralsei.task.base.TaskDef
Adds the specified Columns to an existing Table and runs the SQL script to fill them with data
Variables passed to the template:
table
Columns can be defined in the template itself, using{% set columns = [...] %}
Example
postprocess.sql
{% set columns = [Column("name_upper", "TEXT")] -%} UPDATE {{table}} SET name_upper = UPPER(name);
pipeline.py
"postprocess": AddColumnsSql( sql=Path("./postprocess.sql").read_text(), table=Table("people"), )
Note
You can use
ralsei.utils.folder()
to find SQL files relative to current file-
sql : str | list[str] =
None
¶ Sql template strings
Individual statements must be either separated by
{%split%}
tag or pre-split into a list
-
table : ralsei.graph.Resolves[ralsei.types.Table] =
None
¶ Table to add columns to
May be the output of another task
-
columns : Optional[Sequence[ralsei.types.ColumnBase]] =
None
¶ these column definitions take precedence over those defined in the template
-
sql : str | list[str] =