Edit on GitHub

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    """
20
21    normalize: bool = False
22    pad: int = 2
23    indent: int = 2
24    normalize_functions: t.Optional[str] = None
25    leading_comma: bool = False
26    max_text_width: int = 80
27    append_newline: bool = False
28
29    @property
30    def generator_options(self) -> t.Dict[str, t.Any]:
31        """Options which can be passed through to the SQLGlot Generator class.
32
33        Returns:
34            The generator options.
35        """
36        return self.dict(exclude={"append_newline"})
class FormatConfig(sqlmesh.core.config.base.BaseConfig):
 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    """
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
30    @property
31    def generator_options(self) -> t.Dict[str, t.Any]:
32        """Options which can be passed through to the SQLGlot Generator class.
33
34        Returns:
35            The generator options.
36        """
37        return self.dict(exclude={"append_newline"})

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.
generator_options: Dict[str, Any]

Options which can be passed through to the SQLGlot Generator class.

Returns:

The generator options.

Inherited Members
pydantic.main.BaseModel
BaseModel
model_extra
model_fields_set
model_construct
model_copy
model_dump
model_dump_json
model_json_schema
model_parametrized_name
model_rebuild
model_validate
model_validate_json
model_validate_strings
parse_file
from_orm
construct
schema
schema_json
validate
update_forward_refs
sqlmesh.core.config.base.BaseConfig
update_with
model_post_init
sqlmesh.utils.pydantic.PydanticModel
dict
json
copy
parse_obj
parse_raw
missing_required_fields
extra_fields
all_fields
all_field_infos
required_fields