sqlmesh.core.config.format
1from __future__ import annotations 2 3import typing as t 4 5from sqlmesh.core.config.base import BaseConfig 6 7 8class FormatConfig(BaseConfig): 9 """The format configuration for SQL code. 10 11 Args: 12 normalize: Whether to normalize the SQL code or not. 13 pad: The number of spaces to use for padding. 14 indent: The number of spaces to use for indentation. 15 normalize_functions: Whether or not to normalize all function names. Possible values are: 'upper', 'lower' 16 leading_comma: Whether to use leading commas or not. 17 max_text_width: The maximum text width in a segment before creating new lines. 18 append_newline: Whether to append a newline to the end of the file or not. 19 no_rewrite_casts: Preserve the existing casts, without rewriting them to use the :: syntax. 20 """ 21 22 normalize: bool = False 23 pad: int = 2 24 indent: int = 2 25 normalize_functions: t.Optional[str] = None 26 leading_comma: bool = False 27 max_text_width: int = 80 28 append_newline: bool = False 29 no_rewrite_casts: bool = False 30 31 @property 32 def generator_options(self) -> t.Dict[str, t.Any]: 33 """Options which can be passed through to the SQLGlot Generator class. 34 35 Returns: 36 The generator options. 37 """ 38 return self.dict(exclude={"append_newline", "no_rewrite_casts"})
9class FormatConfig(BaseConfig): 10 """The format configuration for SQL code. 11 12 Args: 13 normalize: Whether to normalize the SQL code or not. 14 pad: The number of spaces to use for padding. 15 indent: The number of spaces to use for indentation. 16 normalize_functions: Whether or not to normalize all function names. Possible values are: 'upper', 'lower' 17 leading_comma: Whether to use leading commas or not. 18 max_text_width: The maximum text width in a segment before creating new lines. 19 append_newline: Whether to append a newline to the end of the file or not. 20 no_rewrite_casts: Preserve the existing casts, without rewriting them to use the :: syntax. 21 """ 22 23 normalize: bool = False 24 pad: int = 2 25 indent: int = 2 26 normalize_functions: t.Optional[str] = None 27 leading_comma: bool = False 28 max_text_width: int = 80 29 append_newline: bool = False 30 no_rewrite_casts: bool = False 31 32 @property 33 def generator_options(self) -> t.Dict[str, t.Any]: 34 """Options which can be passed through to the SQLGlot Generator class. 35 36 Returns: 37 The generator options. 38 """ 39 return self.dict(exclude={"append_newline", "no_rewrite_casts"})
The format configuration for SQL code.
Arguments:
- normalize: Whether to normalize the SQL code or not.
- pad: The number of spaces to use for padding.
- indent: The number of spaces to use for indentation.
- normalize_functions: Whether or not to normalize all function names. Possible values are: 'upper', 'lower'
- leading_comma: Whether to use leading commas or not.
- max_text_width: The maximum text width in a segment before creating new lines.
- append_newline: Whether to append a newline to the end of the file or not.
- no_rewrite_casts: Preserve the existing casts, without rewriting them to use the :: syntax.
generator_options: Dict[str, Any]
32 @property 33 def generator_options(self) -> t.Dict[str, t.Any]: 34 """Options which can be passed through to the SQLGlot Generator class. 35 36 Returns: 37 The generator options. 38 """ 39 return self.dict(exclude={"append_newline", "no_rewrite_casts"})
Options which can be passed through to the SQLGlot Generator class.
Returns:
The generator options.
model_config =
{'json_encoders': {<class 'sqlglot.expressions.core.Expr'>: <function _expression_encoder>, <class 'sqlglot.expressions.datatypes.DataType'>: <function _expression_encoder>, <class 'sqlglot.expressions.query.Tuple'>: <function _expression_encoder>, typing.Union[sqlglot.expressions.query.Query, sqlmesh.core.dialect.JinjaQuery]: <function _expression_encoder>, typing.Union[sqlglot.expressions.query.Query, sqlmesh.core.dialect.JinjaQuery, sqlmesh.core.dialect.MacroFunc]: <function _expression_encoder>, <class 'datetime.tzinfo'>: <function PydanticModel.<lambda>>}, 'arbitrary_types_allowed': True, 'extra': 'forbid', 'protected_namespaces': ()}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Inherited Members
- pydantic.main.BaseModel
- BaseModel
- model_fields
- model_computed_fields
- model_extra
- model_fields_set
- model_construct
- model_copy
- model_dump
- model_dump_json
- model_json_schema
- model_parametrized_name
- model_post_init
- model_rebuild
- model_validate
- model_validate_json
- model_validate_strings
- parse_file
- from_orm
- construct
- schema
- schema_json
- validate
- update_forward_refs