Packages

  • package root
    Definition Classes
    root
  • package org
    Definition Classes
    root
  • package apache
    Definition Classes
    org
  • package spark
    Definition Classes
    apache
  • package sql
    Definition Classes
    spark
  • package artifact
    Definition Classes
    sql
  • package avro
    Definition Classes
    sql
  • package catalyst
    Definition Classes
    sql
  • package classic

    Allows the execution of relational queries, including those expressed in SQL using Spark.

    Allows the execution of relational queries, including those expressed in SQL using Spark.

    Definition Classes
    sql
  • package columnar
    Definition Classes
    sql
  • package connector
    Definition Classes
    sql
  • package execution

    The physical execution component of Spark SQL.

    The physical execution component of Spark SQL. Note that this is a private package. All classes in catalyst are considered an internal API to Spark SQL and are subject to change between minor releases.

    Definition Classes
    sql
  • package internal

    All classes in this package are considered an internal API to Spark and are subject to change between minor releases.

    All classes in this package are considered an internal API to Spark and are subject to change between minor releases.

    Definition Classes
    sql
  • package jdbc
    Definition Classes
    sql
  • package scripting
    Definition Classes
    sql
  • package sources

    A set of APIs for adding data sources to Spark SQL.

    A set of APIs for adding data sources to Spark SQL.

    Definition Classes
    sql
  • package streaming
    Definition Classes
    sql
  • TestGroupState
  • package util
    Definition Classes
    sql

package streaming

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. Protected

Type Members

  1. trait TestGroupState[S] extends GroupState[S]

    :: Experimental ::

    :: Experimental ::

    The extended version of GroupState interface with extra getters of state machine fields to improve testability of the GroupState implementations which inherit from the extended interface.

    Scala example of using TestGroupState:

    // Please refer to ScalaDoc of `GroupState` for the Scala definition of `mappingFunction()`
    
    import org.apache.spark.api.java.Optional
    import org.apache.spark.sql.streaming.GroupStateTimeout
    import org.apache.spark.sql.streaming.TestGroupState
    // other imports
    
    // test class setups
    
    test("MapGroupsWithState state transition function") {
      // Creates the prevState input for the state transition function
      // with desired configs. The `create()` API would guarantee that
      // the generated instance has the same behavior as the one built by
      // engine with the same configs.
      val prevState = TestGroupState.create[Int](
        optionalState = Optional.empty[Int],
        timeoutConf = NoTimeout,
        batchProcessingTimeMs = 1L,
        eventTimeWatermarkMs = Optional.of(1L),
        hasTimedOut = false)
    
      val key: String = ...
      val values: Iterator[Int] = ...
    
      // Asserts the prevState is in init state without updates.
      assert(!prevState.isUpdated)
    
      // Calls the state transition function with the test previous state
      // with desired configs.
      mappingFunction(key, values, prevState)
    
      // Asserts the test GroupState object has been updated but not removed
      // after calling the state transition function
      assert(prevState.isUpdated)
      assert(!prevState.isRemoved)
    }

    Java example of using TestGroupSate:

    // Please refer to ScalaDoc of `GroupState` for the Java definition of `mappingFunction()`
    
    import org.apache.spark.api.java.Optional;
    import org.apache.spark.sql.streaming.GroupStateTimeout;
    import org.apache.spark.sql.streaming.TestGroupState;
    // other imports
    
    // test class setups
    
    // test `MapGroupsWithState` state transition function `mappingFunction()`
    public void testMappingFunctionWithTestGroupState() {
      // Creates the prevState input for the state transition function
      // with desired configs. The `create()` API would guarantee that
      // the generated instance has the same behavior as the one built by
      // engine with the same configs.
      TestGroupState<Int> prevState = TestGroupState.create(
        Optional.empty(),
        GroupStateTimeout.NoTimeout(),
        1L,
        Optional.of(1L),
        false);
    
      String key = ...;
      Integer[] values = ...;
    
      // Asserts the prevState is in init state without updates.
      Assertions.assertFalse(prevState.isUpdated());
    
      // Calls the state transition function with the test previous state
      // with desired configs.
      mappingFunction.call(key, Arrays.asList(values).iterator(), prevState);
    
      // Asserts the test GroupState object has been updated but not removed
      // after calling the state transition function
      Assertions.assertTrue(prevState.isUpdated());
      Assertions.assertFalse(prevState.isRemoved());
    }
    S

    User-defined type of the state to be stored for each group. Must be encodable into Spark SQL types (see Encoder for more details).

    Annotations
    @Evolving()
    Since

    3.2.0

Value Members

  1. object TestGroupState

Ungrouped