Data FlowData Flow
DataFlow
  • User Manual
  • Developer Manual
  • Examples
  • API Reference
Overview
Getting Started
Pipeline Authoring
    Pipeline Spec OverviewConnections
    Sources
      SourcesJDBC SourcesNoSQL SourcesFile System SourcesObject Storage SourcesAPI SourcesStream Sources
    Transforms
    Destinations
    Execution Settings
Execution
Deployment
Troubleshooting
Examples
Sources

Stream Sources

Stream sources read from Kafka, Redis, Kinesis, or SQS with Spark Structured Streaming.

Providers: kafka | redis | kinesis | sqs

Asset fields

Every asset in this type carries these fields; provider and format values live under options.

FieldTypeDefaultNotes
name (required)string--

Settings options

These settings.options apply to every provider:

FieldTypeDefaultNotes
formatcsv or json or raw-Data format for stream processing.

Minimal example

A complete stream source with one asset, written for provider kafka:

Code
sources: - name: orders type: stream provider: kafka # Reuse a saved connection instead of the fields below: # connection_name: <name> settings: url: <host>:9092 assets: - name: orders_raw topic: <topic>

Providers

kafka

An example for provider kafka:

Code
sources: - name: orders type: stream provider: kafka # Reuse a saved connection instead of the fields below: # connection_name: <name> settings: url: <host>:9092 assets: - name: orders_raw topic: <topic>

Connection

Use settings.connection_name for a saved connection, or configure it inline:

FieldTypeDefaultNotes
url (required)string-Kafka bootstrap servers, for example kafka:9092 or host1:9092,host2:9092.

auth is one of:

PLAINTEXT

FieldTypeDefaultNotes
security_protocol (required)PLAINTEXT-Kafka security protocol.

SSL

FieldTypeDefaultNotes
security_protocol (required)SSL-Kafka security protocol.
ssl_truststore_locationstring-Path to Kafka SSL truststore.
ssl_truststore_passwordstring-Password for Kafka SSL truststore.

SASL_PLAINTEXT

FieldTypeDefaultNotes
security_protocol (required)SASL_PLAINTEXT-Kafka security protocol.
sasl_mechanism (required)PLAIN or SCRAM-SHA-256 or SCRAM-SHA-512-Kafka SASL mechanism.
user (required)string-Kafka SASL username.
password (required)string-Kafka SASL password.

SASL_SSL

FieldTypeDefaultNotes
security_protocol (required)SASL_SSL-Kafka security protocol.
sasl_mechanism (required)PLAIN or SCRAM-SHA-256 or SCRAM-SHA-512-Kafka SASL mechanism.
user (required)string-Kafka SASL username.
password (required)string-Kafka SASL password.
ssl_truststore_locationstring-Path to Kafka SSL truststore.
ssl_truststore_passwordstring-Password for Kafka SSL truststore.

Asset options

assets[].options:

FieldTypeDefaultNotes
subscribe_patternstring-Java regex string to subscribe to topics matching the pattern. Only one of 'assign', 'subscribe' or 'subscribePattern' options can be specified. Maps to subscribePattern.
assignstring-JSON string specifying specific TopicPartitions, e.g., {"topicA":[0,1],"topicB":[2,4]}. Only one of 'assign', 'subscribe' or 'subscribePattern' options can be specified.
starting_timestampstring-The start point of timestamp when a query is started, a string specifying a starting timestamp for all partitions in topics being subscribed. Takes precedence over startingOffsetsByTimestamp and startingOffsets. For streaming queries, this only applies when a new query is started. Requires Kafka 0.10.1.0 or higher. Maps to startingTimestamp.
starting_offsets_by_timestampstring-The start point of timestamp when a query is started, a JSON string specifying a starting timestamp for each TopicPartition, e.g., {"topicA":{"0":1000,"1":1000},"topicB":{"0":2000}}. Takes precedence over startingOffsets. Requires Kafka 0.10.1.0 or higher. Maps to startingOffsetsByTimestamp.
starting_offsetsstringlatestThe start point when a query is started. Options: 'earliest', 'latest' (streaming only), or JSON string specifying a starting offset for each TopicPartition, e.g., {"topicA":{"0":23,"1":-1}}. In JSON, -2 refers to earliest, -1 to latest. Default: 'latest' for streaming, 'earliest' for batch. Maps to startingOffsets.
ending_timestampstring-The end point when a batch query is ended, a string specifying an ending timestamp for all partitions in topics being subscribed. Takes precedence over endingOffsetsByTimestamp and endingOffsets. Batch queries only. Maps to endingTimestamp.
ending_offsets_by_timestampstring-The end point when a batch query is ended, a JSON string specifying an ending timestamp for each TopicPartition, e.g., {"topicA":{"0":1000,"1":1000}}. Takes precedence over endingOffsets. Batch queries only. Maps to endingOffsetsByTimestamp.
ending_offsetsstring-The end point when a batch query is ended. Options: 'latest' or JSON string specifying an ending offset for each TopicPartition, e.g., {"topicA":{"0":23,"1":-1}}. In JSON, -1 refers to latest, -2 (earliest) is not allowed. Batch queries only. Default: 'latest'. Maps to endingOffsets.
fail_on_data_lossboolean-Whether to fail the query when it's possible that data is lost (e.g., topics are deleted, or offsets are out of range). This may be a false alarm. Default: true. Maps to failOnDataLoss.
poll_timeoutnumber-The timeout in milliseconds to poll data from Kafka in executors. When not defined it falls back to spark.network.timeout. Default: 120000. Maps to kafkaConsumer.pollTimeoutMs.
fetch_offset_retries_numbernumber-Number of times to retry before giving up fetching Kafka offsets. Default: 3. Maps to fetchOffset.numRetries.
fetch_offset_retry_intervalnumber-Milliseconds to wait before retrying to fetch Kafka offsets. Default: 10. Maps to fetchOffset.retryIntervalMs.
max_offsets_per_triggernumber-Rate limit on maximum number of offsets processed per trigger interval. The specified total number of offsets will be proportionally split across topicPartitions of different volume. Streaming queries only. Maps to maxOffsetsPerTrigger.
min_offsets_per_triggernumber-Minimum number of offsets to be processed per trigger interval. The specified total number of offsets will be proportionally split across topicPartitions of different volume. Note, if the maxTriggerDelay is exceeded, a trigger will be fired even if the number of available offsets doesn't reach minOffsetsPerTrigger. Streaming queries only. Maps to minOffsetsPerTrigger.
max_trigger_delaystring-Maximum amount of time for which trigger can be delayed between two triggers provided some data is available from the source. This option is only applicable if minOffsetsPerTrigger is set. Streaming queries only. Default: 15m. Maps to maxTriggerDelay.
min_partitionsnumber-Desired minimum number of partitions to read from Kafka. By default, Spark has a 1-1 mapping of topicPartitions to Spark partitions consuming from Kafka. If you set this option to a value greater than your topicPartitions, Spark will divvy up large Kafka partitions to smaller pieces. The number of Spark tasks will be approximately minPartitions. Maps to minPartitions.
group_id_prefixstring-Prefix of consumer group identifiers (group.id) that are generated by structured streaming queries. If 'kafka.group.id' is set, this option will be ignored. Default: spark-kafka-source. Maps to groupIdPrefix.
kafka_group_idstring-The Kafka group id to use in Kafka consumer while reading from Kafka. Use this with extreme caution. By default, each query generates a unique group id for reading data. Concurrently running queries (both, batch and streaming) or sources with the same group id are likely interfere with each other causing each query to read only part of the data. When this is set, option 'groupIdPrefix' will be ignored. Maps to kafka.group.id.
include_headersboolean-Whether to include the Kafka headers in the row. Requires Kafka client version 0.11.0.0 or up. Default: false. Maps to includeHeaders.
header_namesarray of string-Kafka header names to extract as individual STRING columns (one column per name). Requires include_headers=true. Headers not present on a record yield NULL in their column. If omitted: in streaming mode all headers are exposed as a single 'headers' MapType<string,string> column (use headers['name'] in SQL); in test_limit batch mode header keys are auto-discovered and emitted as individual STRING columns.
starting_offsets_by_timestamp_strategyerror or latest-The strategy used when the specified starting offset by timestamp (either global or per partition) doesn't match with the offset Kafka returned. Options: 'error' (fail the query) or 'latest' (assigns the latest offset for these partitions). Default: error. Maps to startingOffsetsByTimestampStrategy.

redis

An example for provider redis:

Code
sources: - name: orders type: stream provider: redis # Reuse a saved connection instead of the fields below: # connection_name: <name> settings: url: <host>:6379 assets: - name: orders_raw stream: <stream>

Connection

Use settings.connection_name for a saved connection, or configure it inline:

FieldTypeDefaultNotes
url (required)string-Redis host or redis://host.
authobject--
auth.passwordstring-Redis password.

Asset options

assets[].options:

FieldTypeDefaultNotes
offsetsstring-JSON string specifying stream offset positions. Format: {"offsets":{"streamKey":{"groupName":"redis-source","offset":"1548083485360-0"}}}. Use '0-0' to process from the beginning. Default: starts from latest message. Maps to stream.offsets.
group_namestring-Consumer group name. Spark-Redis automatically creates this group if it doesn't exist. Default: 'spark-source'. Maps to stream.group.name.
consumer_prefixstring-Prefix for consumer names in the consumer group. Allows customization of consumer naming. Maps to stream.consumer.prefix.
batch_sizenumber-Maximum number of items to pull in a single XREADGROUP call. Default: 100. Maps to stream.read.batch.size.
block_timenumber-Blocking time (milliseconds) to wait for messages to appear in the Redis stream. Default: 0. Maps to stream.read.block.
parallelismnumber-Number of parallel consumers for reading from a single Redis key. Each consumer maps to a Spark partition. No ordering guarantees when using multiple consumers. Maps to stream.parallelism.
database_numbernumber-Redis database number (0-15). Overrides spark.redis.db configured in SparkSession. Default: 0. Maps to dbNum.
timeoutnumber-Connection timeout in milliseconds. Overrides spark.redis.timeout configured in SparkSession. Default: 2000.

kinesis

An example for provider kinesis:

Code
sources: - name: orders type: stream provider: kinesis # Reuse a saved connection instead of the fields below: # connection_name: <name> settings: url: https://kinesis.<region>.amazonaws.com auth: access_key: <access_key> secret_key: <secret_key> region: <region> assets: - name: orders_raw stream: <stream>

Connection

Use settings.connection_name for a saved connection, or configure it inline:

FieldTypeDefaultNotes
url (required)string-Kinesis endpoint or stream service URL.
auth (required)object--
auth.access_key (required)string--
auth.secret_key (required)string--
auth.region (required)string--

Asset options

assets[].options:

FieldTypeDefaultNotes
consumer_typestring-Consumer type. Possible values are 'GetRecords', 'SubscribeToShard'. Default: GetRecords. Maps to kinesis.consumerType.
fail_on_data_lossbooleanfalseFail the streaming job if any active shard is missing or expired. Default: false. Maps to kinesis.failOnDataLoss.
max_fetch_records_per_shardnumber100000Maximum number of records to fetch per shard per microbatch. Default: 100,000. Maps to kinesis.maxFetchRecordsPerShard.
max_fetch_time_per_shardnumber-Maximum time (seconds) to fetch records per shard per microbatch. If not defined, decision is based on kinesis.maxFetchRecordsPerShard. If defined, task terminates when either maxFetchRecordsPerShard or maxFetchTimePerShardSec is reached first. Must be no less than 10 seconds. Maps to kinesis.maxFetchTimePerShardSec.
starting_positionstring-Starting Position in Kinesis to fetch data from. Possible values are 'LATEST', 'TRIM_HORIZON', 'EARLIEST' (alias for TRIM_HORIZON), or 'AT_TIMESTAMP YYYY-MM-DDTHH:MM' (e.g. 2023-08-30T19:00:05Z). Default: LATEST. Maps to kinesis.startingPosition.
describe_shard_intervalstring1sMinimum Interval between two ListShards API calls to get latest shards. Possible values are time values such as 50s, 100ms. Default: 1s. Maps to kinesis.describeShardInterval.
min_batches_to_retainnumber-The minimum number of batches of kinesis metadata that must be retained and made recoverable. Default: same as spark.sql.streaming.minBatchesToRetain. Maps to kinesis.minBatchesToRetain.
check_new_record_threadsnumber8Number of threads in Spark driver to check if there are new records in Kinesis stream. Default: 8. Maps to kinesis.checkNewRecordThreads.
metadata_committer_typestringHDFSWhere to save Kinesis connector metadata. Possible values are 'HDFS', 'DYNAMODB'. Default: HDFS. Maps to kinesis.metadataCommitterType.
metadata_pathstring-A path to HDFS or S3. Only valid when kinesis.metadataCommitterType is HDFS. Default: same as checkpointLocation. Maps to kinesis.metadataPath.
metadata_retries_numbernumber5Maximum Number of retries for metadata requests. Default: 5. Maps to kinesis.metadataNumRetries.
metadata_retry_intervalsnumber1000Wait time before retrying metadata requests in milliseconds. Default: 1000. Maps to kinesis.metadataRetryIntervalsMs.
metadata_max_retry_intervalnumber10000Max wait time between 2 retries of metadata requests in milliseconds. Default: 10000. Maps to kinesis.metadataMaxRetryIntervalMs.
client_retries_numbernumber5Maximum Number of retries for Kinesis API requests. Default: 5. Maps to kinesis.clientNumRetries.
client_retry_intervalsnumber1000Wait time before retrying Kinesis requests in milliseconds. Default: 1000. Maps to kinesis.clientRetryIntervalsMs.
client_max_retry_intervalnumber10000Max wait time between 2 retries of Kinesis requests in milliseconds. Default: 10000. Maps to kinesis.clientMaxRetryIntervalMs.
consumer_namestring-Kinesis stream Enhanced Fan Out consumer name. Required when kinesis.consumerType is 'SubscribeToShard'. Maps to kinesis.consumerName.
sts_role_arnstring-AWS STS Role ARN for Kinesis operations describe, read record, etc. Used for cross-account access. Maps to kinesis.stsRoleArn.
sts_session_namestring-AWS STS Session name. Used for cross-account access. Maps to kinesis.stsSessionName.
sts_endpoint_urlstring-AWS STS Endpoint URL. Used for cross-account access. Maps to kinesis.stsEndpointUrl.
kinesis_regionstring-Region the Kinesis stream belongs to. Default: inferred value from kinesis.endpointUrl. Maps to kinesis.kinesisRegion.
credential_provider_classstring-Custom connector credential provider implements org.apache.spark.sql.connector.kinesis.ConnectorAwsCredentialsProvider. If the implementation returns temporary credentials, it is responsible for refreshing the credentials before they expire. Maps to kinesis.credentialProviderClass.
credential_provider_paramstring-Custom connector credential provider's input parameter. Maps to kinesis.credentialProviderParam.
dynamodb_table_namestring-DynamoDB table name. Required when kinesis.metadataCommitterType is 'DYNAMODB'. Maps to kinesis.dynamodb.tableName.
subscribe_to_shard_timeoutnumber60Timeout waiting for subscribeToShard finish (seconds). Default: 60. Maps to kinesis.subscribeToShard.timeoutSec.
subscribe_to_shard_max_retriesnumber10Max retries of subscribeToShard request. Default: 10. Maps to kinesis.subscribeToShard.maxRetries.
get_records_number_of_records_per_fetchnumber10000Maximum Number of records to fetch per getRecords API call. Default: 10,000. Maps to kinesis.getRecords.numberOfRecordsPerFetch.
get_records_fetch_intervalnumber200Minimum interval of two getRecords API calls in milliseconds. Default: 200. Maps to kinesis.getRecords.fetchIntervalMs.

sqs

An example for provider sqs:

Code
sources: - name: orders type: stream provider: sqs # Reuse a saved connection instead of the fields below: # connection_name: <name> settings: url: https://sqs.<region>.amazonaws.com auth: access_key: <access_key> secret_key: <secret_key> region: <region> assets: - name: orders_raw queue: <queue>

Connection

Use settings.connection_name for a saved connection, or configure it inline:

FieldTypeDefaultNotes
url (required)string-SQS queue URL.
auth (required)object--
auth.access_key (required)string--
auth.secret_key (required)string--
auth.region (required)string--

Asset options

assets[].options:

FieldTypeDefaultNotes
poll_intervalinteger1000Polling interval in milliseconds for SQS queue. Default: 1000. Maps to pollIntervalMs.

Related pages

  • Sources
  • Connections
  • Pipeline Spec Overview
  • API Reference
Suggest edit
Last modified on November 26, 2026
API SourcesTransforms
On this page
  • Asset fields
  • Settings options
  • Minimal example
  • Providers
    • kafka
    • redis
    • kinesis
    • sqs
  • Related pages
YAML
YAML
YAML
YAML
YAML