kedro/extras/datasets/spark/spark_dataset.py
def _get_dbutils(spark: SparkSession) -> Optional[Any]:
    """Get the instance of 'dbutils' or None if the one could not be found."""
    dbutils = globals().get("dbutils")
    if dbutils:
        return dbutils

    try:
        from pyspark.dbutils import DBUtils  # pylint: disable=import-outside-toplevel

        dbutils = DBUtils(spark)
    except ImportError:
        try:
            import IPython  # pylint: disable=import-error,import-outside-toplevel
        except ImportError:
            pass
        else:
            ipython = IPython.get_ipython()
            dbutils = ipython.user_ns.get("dbutils") if ipython else None

    return dbutils
Get the instance of 'dbutils' or None if the one could not be found.
Get the instance of 'dbutils' or None if the one could not be found.
Get the instance of ' dbutils ' or None if the one could not be found .
def _get_dbutils(spark: SparkSession) -> Optional[Any]:
    dbutils = globals().get("dbutils")
    if dbutils:
        return dbutils
    try:
        from pyspark.dbutils import DBUtils  
        dbutils = DBUtils(spark)
    except ImportError:
        try:
            import IPython  
        except ImportError:
            pass
        else:
            ipython = IPython.get_ipython()
            dbutils = ipython.user_ns.get("dbutils") if ipython else None
    return dbutils
def _get_dbutils ( spark : SparkSession ) -> Optional [ Any ] : dbutils = globals ( ) . get ( "dbutils" ) if dbutils : return dbutils try : from pyspark . dbutils import DBUtils dbutils = DBUtils ( spark ) except ImportError : try : import IPython except ImportError : pass else : ipython = IPython . get_ipython ( ) dbutils = ipython . user_ns . get ( "dbutils" ) if ipython else None return dbutils
Get the instance of 'dbutils' or None if the one could not be found.
Get the instance of ' dbutils ' or None if the one could not be found .
"""Get the instance of 'dbutils' or None if the one could not be found.""" # pylint: disable=import-outside-toplevel # pylint: disable=import-error,import-outside-toplevel
spark
SparkSession