def METHOD_NAME(
    self, df: pyspark.DataFrame, batch_spec: BatchSpec
) -> pyspark.DataFrame:
    """Take a random sample of rows, retaining proportion p.
    Args:
        df: dataframe to sample
        batch_spec: Can contain keys `p` (float), `seed` (int) which
            default to 0.1 and 1 respectively if not provided.
    Returns:
        Sampled dataframe
    Raises:
        SamplerError
    """
    p: float = self.get_sampling_kwargs_value_or_default(
        batch_spec=batch_spec, sampling_kwargs_key="p", default_value=0.1
    )
    seed: int = self.get_sampling_kwargs_value_or_default(
        batch_spec=batch_spec, sampling_kwargs_key="seed", default_value=1
    )
    res = (
        df.withColumn("rand", F.rand(seed=seed))
        .filter(F.col("rand") < p)
        .drop("rand")
    )
    return res