o
    8Di                     @   s`   d Z ddlZddlZg dZdd eD Ze Zi edddZeeZ	e
 Zdd	 ZdS )
a}	  
## Dialects

While there is a SQL standard, most SQL engines support a variation of that standard. This makes it difficult
to write portable SQL code. SQLGlot bridges all the different variations, called "dialects", with an extensible
SQL transpilation framework.

The base `sqlglot.dialects.dialect.Dialect` class implements a generic dialect that aims to be as universal as possible.

Each SQL variation has its own `Dialect` subclass, extending the corresponding `Tokenizer`, `Parser` and `Generator`
classes as needed.

### Implementing a custom Dialect

Creating a new SQL dialect may seem complicated at first, but it is actually quite simple in SQLGlot:

```python
from sqlglot import exp
from sqlglot.dialects.dialect import Dialect
from sqlglot.generator import Generator
from sqlglot.tokens import Tokenizer, TokenType


class Custom(Dialect):
    class Tokenizer(Tokenizer):
        QUOTES = ["'", '"']  # Strings can be delimited by either single or double quotes
        IDENTIFIERS = ["`"]  # Identifiers can be delimited by backticks

        # Associates certain meaningful words with tokens that capture their intent
        KEYWORDS = {
            **Tokenizer.KEYWORDS,
            "INT64": TokenType.BIGINT,
            "FLOAT64": TokenType.DOUBLE,
        }

    class Generator(Generator):
        # Specifies how AST nodes, i.e. subclasses of exp.Expression, should be converted into SQL
        TRANSFORMS = {
            exp.Array: lambda self, e: f"[{self.expressions(e)}]",
        }

        # Specifies how AST nodes representing data types should be converted into SQL
        TYPE_MAPPING = {
            exp.DataType.Type.TINYINT: "INT64",
            exp.DataType.Type.SMALLINT: "INT64",
            exp.DataType.Type.INT: "INT64",
            exp.DataType.Type.BIGINT: "INT64",
            exp.DataType.Type.DECIMAL: "NUMERIC",
            exp.DataType.Type.FLOAT: "FLOAT64",
            exp.DataType.Type.DOUBLE: "FLOAT64",
            exp.DataType.Type.BOOLEAN: "BOOL",
            exp.DataType.Type.TEXT: "STRING",
        }
```

The above example demonstrates how certain parts of the base `Dialect` class can be overridden to match a different
specification. Even though it is a fairly realistic starting point, we strongly encourage the reader to study existing
dialect implementations in order to understand how their various components can be modified, depending on the use-case.

----
    N)AthenaBigQuery
ClickHouse
DatabricksDorisDremioDrillDruidDuckDBDuneFabricHiveMaterializeMySQLOraclePostgresPrestoPRQLRedshift
RisingWave	SnowflakeSparkSpark2SQLite	StarRocksTableauTeradataTrinoTSQLExasolc                 C   s   i | ]}||  qS  )lower).0namer    r    R/var/www/Datamplify/venv/lib/python3.10/site-packages/sqlglot/dialects/__init__.py
<dictcomp>d   s    r%   dialect)DialectDialectsc                 C   s`   t | }|r&t td| }W d    n1 sw   Y  t|| S tdt d|  )Nzsqlglot.dialects.zmodule z has no attribute )MODULE_BY_ATTRIBUTEget_import_lock	importlibimport_modulegetattrAttributeError__name__)r#   module_namemoduler    r    r$   __getattr__u   s   

r3   )__doc__r,   	threadingDIALECTSMODULE_BY_DIALECTvaluesDIALECT_MODULE_NAMESr)   list__all__RLockr+   r3   r    r    r    r$   <module>   s   >!