code: def _if_later(data1, data2):
      """Helper function to test if records in data1 are earlier than that in data2.
      Returns:
          bool: True or False indicating if data1 is earlier than data2.
      """
  
      max_times = data1.groupBy(DEFAULT_USER_COL).agg(
          F.max(DEFAULT_TIMESTAMP_COL).alias("max")
      )
      min_times = data2.groupBy(DEFAULT_USER_COL).agg(
          F.min(DEFAULT_TIMESTAMP_COL).alias("min")
      )
      all_times = max_times.join(min_times, on=DEFAULT_USER_COL).select(
          (F.col("max") <= F.col("min"))
      )
  
      return all([x[0] for x in all_times.collect()])
  
file_path: recommenders/tests/unit/recommenders/datasets/test_spark_splitter.py
imports: import pytest
  import numpy
  import pandas
  from recommenders.utils.constants import DEFAULT_USER_COL, DEFAULT_ITEM_COL, DEFAULT_RATING_COL, DEFAULT_TIMESTAMP_COL
label_desc: Use image node_id 2 for calling a global function with example usage: _if_later(data1, data2) and returns: all