DELTA_STAGE1_SQL = 'WITH RECURSIVE ancestors(
checkpoint_id,
parent_checkpoint_id,
type,
checkpoint) AS (SELECT checkpoint_id,
parent_checkpoint_id,
type,
checkpoint FROM checkpoints WHERE thread_id = ? AND checkpoint_ns = ? AND checkpoint_id = ? UNION ALL SELECT c.checkpoint_id,
c.parent_checkpoint_id,
c.type,
c.checkpoint FROM ancestors a CROSS JOIN checkpoints c ON c.checkpoint_id = a.parent_checkpoint_id WHERE c.thread_id = ? AND c.checkpoint_ns = ?
) SELECT checkpoint_id, type, checkpoint FROM ancestors'