code: def test_repartition_df_if_needed_max_num_df_rows():
      spark = (
          pyspark.sql.SparkSession.builder.master("local[*]")
          .appName("pyspark")
          .getOrCreate()
      )
      df = spark.range(100).repartition(1)
      spark_builder = Spark(df)
      # Choose a small max_shard_size for maximum partitioning.
      spark_builder._repartition_df_if_needed(max_shard_size=1)
      # The new number of partitions should not be greater than the number of rows.
      assert spark_builder.df.rdd.getNumPartitions() == 100
  
file_path: datasets/tests/packaged_modules/test_spark.py
imports: from unittest.mock import patch
  import pyspark
  from datasets.packaged_modules.spark.spark import Spark, SparkExamplesIterable, _generate_iterable_examples
  from ..utils import require_dill_gt_0_3_2, require_not_windows
label_desc: Use image node_id 7 for calling a global function with example usage: test_repartition_df_if_needed_max_num_df_rows() without return types