On this page

SQL query (sql)

YAML location: an entry in a flowgroup’s actions list. Source selector: source.type: sql.

Materialize a SQL query into a temporary view. Fields live under source:; provide type: sql and exactly one of sql or sql_path.

Minimal example

Add this entry to the actions list in your flowgroup.

- name: load_summary
  type: load
  source:
    type: sql
    sql: "SELECT * FROM ${catalog}.${bronze_schema}.orders"
  target: v_orders

Source fields

Field

Type

Required

Default

Description

type

string

Yes

—

Must be sql.

sql

string

One of

—

Inline SQL query. Provide exactly one of sql / sql_path.

sql_path

string

One of

—

Path to an external .sql file. Provide exactly one of sql / sql_path.

readMode is ignored for SQL loads (always a spark.sql call). Substitution tokens (${token}, ${secret:scope/key}) resolve in both inline SQL and external files. A plain ${name} that is still in the sql_path file after substitution fails lhp validate and lhp generate with LHP-CFG-010. Dotted or prefixed Spark variables such as ${mypipeline.start} or ${hiveconf:x} are left as written. To read a pipeline configuration: parameter at runtime, give it a dotted key (for example mypipeline.start_date) and reference it as ${mypipeline.start_date}; a plain ${start_date} fails even when the configuration defines it.

In a template action, a sql_path file that contains {{, {% or {# is rendered with the template parameters before substitution, like the template’s inline SQL. See Parameters in SQL files.

Action-level fields

These fields apply to every load sub-type. name, type, source and target are required.

Field

Type

Required

Default

Description

name

string

Yes

—

Unique action name within the flowgroup.

type

string

Yes

—

Always load.

source

mapping

Yes

—

Source configuration. source.type selects the sub-type. Use a mapping for every load type, including SQL.

target

string

Yes

—

Name of the temporary view this action creates.

readMode

string

No

sub-type

batch or stream; selects spark.read vs spark.readStream. Default and constraints vary by sub-type (below). Ignored by sql, python, and jdbc. The view this action creates is a stream or a batch view, and later actions in the flowgroup must read it the same way (LHP-VAL-070); see Read mode.

description

string

No

auto

Docstring for the generated view function.

operational_metadata

bool or list[string]

No

—

Explicit column names to add; action-level false disables inherited selection. true alone adds no columns. See Operational metadata.

depends_on

list[string]

No

—

Extra upstream table or view references added to the dependency graph. See Dependency analysis reference.

See the worked guide or choose another load source.