Skip to content

Conversation

@dkropachev
Copy link
Collaborator

@dkropachev dkropachev commented Jan 31, 2026

Summary

  • Converts BatchQuery.execute() from CQL string serialization to protocol-level BatchStatement
  • Adds timestamp attribute to BatchStatement for batch-level timestamps
  • Fixes type detection issues (e.g., isinstance(query, BatchStatement) check at cluster.py:5332)

Changes

  1. cassandra/query.py: Added timestamp attribute to BatchStatement
  2. cassandra/cluster.py: Use BatchStatement.timestamp when available
  3. cassandra/cqlengine/connection.py: Handle BatchStatement in execute()
  4. cassandra/cqlengine/query.py: Refactor BatchQuery.execute() to use BatchStatement

Benefits

  • Better performance (no string serialization overhead)
  • Proper type detection (isinstance checks for BatchStatement now work)
  • Batch-level timestamps preserved through protocol

Fixes #208

Previously, BatchQuery.execute() serialized batches to CQL strings
(BEGIN BATCH ... APPLY BATCH). This changes it to use the protocol-level
BatchStatement from cassandra/query.py instead.

Changes:
- Add timestamp attribute to BatchStatement for batch-level timestamps
- Update Session._create_response_future() to use BatchStatement.timestamp
- Add BatchStatement handling to cqlengine execute()
- Refactor BatchQuery.execute() to build and execute a BatchStatement

Benefits:
- Better performance (no string serialization overhead)
- Proper type detection (isinstance checks for BatchStatement now work)
- Batch-level timestamps preserved through protocol

Fixes #208
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BatchQuery serializes batch to string instead of using BatchStatement

2 participants