AutoCommit
Specifies whether the Apache Kafka consumer automatically commits read offsets.
Data Type
bool
Default Value
false
Remarks
By default, the driver does not commit read offsets unless you invoke CommitOffset. When an offset is committed for a topic, the driver starts reading from that offset in future queries until the next call to CommitOffset. If no offsets are committed, each query begins reading from the position determined by OffsetResetStrategy.
When set to true, the driver commits offsets periodically and also at the end of each SELECT query. This causes each SELECT query to consume the messages it reads, preventing future queries in the same consumer group from returning those messages. A ConsumerGroupId is required because the committed offset is shared across the consumer group, allowing later connections with the same group ID to use the same offsets.
Consider the following when enabling AutoCommit:
- Queries with OFFSET: Some queries may consume more messages than they return. For example, a SELECT query with an OFFSET clause consumes messages up to the specified offset and then returns rows after that point. Messages consumed to satisfy the OFFSET are discarded and cannot be read again within the same consumer group.
- TypeDetectionScheme Behavior: The None and RowScan options in TypeDetectionScheme perform internal reads on the topic to identify available columns. Because AutoCommit relies on periodic commits performed by the underlying Apache Kafka client, offsets may be committed during these internal reads. To avoid this, use SchemaRegistry or MessageOnly in TypeDetectionScheme.
- Message-Based Offsets: AutoCommit operates on messages, not rows. Some SerializationFormat options can read multiple rows from a single Kafka message, such as when a Kafka message contains a JSON array. If a SELECT query reads only a subset of rows from that message, Kafka treats the entire message as consumed, meaning any unread rows within that message are discarded.