class_docstr: Represents a Spark dataset (e.g. data derived from a Spark Table / file directory or Delta
  Table) for use with MLflow Tracking.
class_docstr_tok: ["Represents","a","Spark","dataset","(","e.g",".","data","derived","from","a","Spark","Table","\/","file","directory","or","Delta","Table",")","for","use","with","MLflow","Tracking","."]
docstr: A profile of the dataset. May be None if no profile is available.
docstr_tok: ["A","profile","of","the","dataset",".","May","be","None","if","no","profile","is","available","."]
code: def profile(self) -> Optional[Any]:
      """
      A profile of the dataset. May be None if no profile is available.
      """
      try:
          from pyspark.rdd import BoundedFloat
  
          # Use Spark RDD countApprox to get approximate count since count() may be expensive.
          # Note that we call the Scala RDD API because the PySpark API does not respect the
          # specified timeout. Reference code:
          # https://spark.apache.org/docs/3.4.0/api/python/_modules/pyspark/rdd.html
          # #RDD.countApprox. This is confirmed to work in all Spark 3.x versions
          py_rdd = self.df.rdd
          drdd = py_rdd.mapPartitions(
              lambda it: [float(sum(1 for i in it))]
          )
          jrdd = drdd.mapPartitions(
              lambda it: [float(sum(it))]
          )._to_java_object_rdd()
          jdrdd = drdd.ctx._jvm.JavaDoubleRDD.fromRDD(jrdd.rdd())
          timeout_millis = 5000
          confidence = 0.9
          approx_count_operation = jdrdd.sumApprox(
              timeout_millis, confidence
          )
          approx_count_result = approx_count_operation.initialValue()
          approx_count_float = BoundedFloat(
              mean=approx_count_result.mean(),
              confidence=approx_count_result.confidence(),
              low=approx_count_result.low(),
              high=approx_count_result.high(),
          )
          approx_count = int(approx_count_float)
          if approx_count <= 0:
              # An approximate count of zero likely indicates that the count timed
              # out before an estimate could be made. In this case, we use the value
              # "unknown" so that users don't think the dataset is empty
              approx_count = "unknown"
  
          return {
              "approx_count": approx_count,
          }
      except Exception as e:
          _logger.warning(
              "Encountered an unexpected exception while computing Spark dataset profile."
              " Exception: %s",
              e,
          )
  
imports: import json
  import logging
  from functools import cached_property
  from typing import TYPE_CHECKING, Any, Dict, Optional, Union
  from mlflow.data.dataset import Dataset
  from mlflow.data.dataset_source import DatasetSource
  from mlflow.data.delta_dataset_source import DeltaDatasetSource
  from mlflow.data.digest_utils import compute_spark_df_digest
  from mlflow.data.pyfunc_dataset_mixin import PyFuncConvertibleDatasetMixin, PyFuncInputsOutputs
  from mlflow.data.spark_dataset_source import SparkDatasetSource
  from mlflow.exceptions import MlflowException
  from mlflow.models.evaluation.base import EvaluationDataset
  from mlflow.protos.databricks_pb2 import INTERNAL_ERROR, INVALID_PARAMETER_VALUE
  from mlflow.types import Schema
  from mlflow.types.utils import _infer_schema
  from mlflow.utils.annotations import experimental
label_desc: Use image node_id 7 for calling the SparkDataset obj's underlying member method code with example usage: obj.profile() and returns: dict