Phase 4: Spark backend implementation