SQLLimit type: sql_limit#
- class lumen.transforms.sql.SQLLimit(*, limit, comments, error_level, identify, optimize, pretty, read, unsupported_level, write, controls, name)#
Performs a LIMIT SQL operation on the query. If the query already has a LIMIT clause, it will only be applied if the existing limit is less than the new limit.
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: int
default: 1000
bounds: None
Limit on the number of rows to return
type: bool
default: False
Whether to optimize the generated SQL query; may produce invalid results, especially withduckdb’s read_* functions.
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: 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#
- SQLLimit.apply(sql_in: str) str #
Given an SQL statement, manipulate it, and return a new SQL statement.
- Parameters:
sql_in (string) – The initial SQL query to be manipulated.
- Returns:
New SQL query derived from the above query.
- Return type:
string
- SQLLimit.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
- SQLLimit.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
- SQLLimit.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