sqlmesh.core.engine_adapter._typing API documentation

Edit on GitHub

# sqlmesh.core.engine_adapter._typing

View Source

     1import typing as t
     2
     3import pandas as pd
     4from sqlglot import exp
     5
     6TARGET_ALIAS = "__MERGE_TARGET__"
     7SOURCE_ALIAS = "__MERGE_SOURCE__"
     8DF_TYPES: t.Tuple = (pd.DataFrame,)
     9Query = t.Union[exp.Subqueryable, exp.DerivedTable]
    10QUERY_TYPES: t.Tuple = (exp.Subqueryable, exp.DerivedTable)
    11
    12
    13if t.TYPE_CHECKING:
    14    import pyspark
    15
    16    PySparkSession = pyspark.sql.SparkSession
    17    PySparkDataFrame = pyspark.sql.DataFrame
    18    DF = t.Union[pd.DataFrame, PySparkDataFrame]
    19    QueryOrDF = t.Union[Query, DF]
    20else:
    21    try:
    22        import pyspark
    23
    24        PySparkSession = pyspark.sql.SparkSession
    25        PySparkDataFrame = pyspark.sql.DataFrame
    26        DF_TYPES += (PySparkDataFrame,)
    27    except ImportError:
    28        PySparkSession = None
    29        PySparkDataFrame = None