from typing import TYPE_CHECKING, cast

if TYPE_CHECKING:
    from pyspark.sql import SparkSession

def init_sess() -> "SparkSession":
    """Initialize a DuckDB session that mimics the SparkSession interface.
    
    Returns:
        A SparkSession-compatible object backed by DuckDB
    """
    from sqlframe import activate
    activate(engine="duckdb")
    from pyspark.sql import SparkSession

    # Use cast to ensure the return type is recognized as SparkSession
    sess = cast("SparkSession", SparkSession.builder.appName("test").getOrCreate())
    return sess