SQLSelectFrom type: sql_select_from#
- class lumen.transforms.sql.SQLSelectFrom(*, sql_expr, tables, parameters, comments, error_level, identify, optimize, pretty, read, unsupported_level, write, controls, name)#
Parameters#
type: bool
default: False
Whether to include comments in the output SQL
type: sqlglot.ErrorLevel
default: <ErrorLevel.RAISE: 'RAISE'>
Error level for parsing
type: bool
default: False
Delimit all identifiers, e.g. turn FROM database.table
into FROM "database"."table"
.This is useful for dialects that don’t support unquoted identifiers.
type: bool
default: False
Whether to optimize the generated SQL query; may produce invalid results, especially withduckdb’s read_* functions.
type: dict
default: {}
Dictionary of parameter names and values to replace in the SQL template.
type: bool
default: False
Prettify output SQL, i.e. add newlines and indentation
type: str
default: None
Source dialect for parsing; if None, automatically detects
type: str
default: 'SELECT * FROM {table}'
The SQL expression to useif the sql_in does NOTalready contain a SELECT statement.
type: list | dict
default: None
Dictionary of tables to replace or use in the SQL expression.If None, the original table will be used.
type: sqlglot.ErrorLevel
default: <ErrorLevel.WARN: 'WARN'>
When using to_sql
, how to handle unsupported dialect features.
type: str
default: None
Target dialect for output; if None, defaults to read dialect
Methods#
- SQLSelectFrom.apply(sql_in: str) str #
Apply the formatting to the input SQL, replacing placeholders with values.
- Parameters:
sql_in (str) – The input SQL query to format. This is used as a base query that will have the formatted sql_expr applied to it, typically as a subquery.
- Returns:
The formatted SQL query with all placeholders replaced.
- Return type:
str
- SQLSelectFrom.parse_sql(sql_in: str) Expression #
Parse SQL string into sqlglot AST.
- Parameters:
sql_in (string) – SQL string to parse
- Returns:
Parsed SQL expression
- Return type:
sqlglot.Expression
- SQLSelectFrom.to_spec(context: dict[str, Any] | None = None) dict[str, Any] #
Exports the full specification to reconstruct this component.
- Return type:
Resolved and instantiated Component object
- SQLSelectFrom.to_sql(expression: Expression) str #
Convert sqlglot expression back to SQL string.
- Parameters:
expression (sqlglot.Expression) – Expression to convert to SQL
- Returns:
SQL string representation
- Return type:
string