[FLINK] Fix print connector: write to stdout/stderr instead of file#49
Merged
zhanglistar merged 1 commit intoJun 23, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: apache/gluten#12306
related pr: bigo-sg/velox4j#39 apache/gluten#12320
Summary
The print connector wrote rows through a dwio
Writeragainst a file path resolved by the planner (<logdir>/taskmanager.out). Under multi-parallelism every subtask opened the same file, and the writer truncated it on open — output from N-1 subtasks was lost, and the surviving stream was interleaved without serialization.This PR switches the sink to write to
std::cout/std::cerr(TM stdout is already redirected totaskmanager.outby Flink) and removes the file plumbing:PrintSinkno longer owns a dwioWriter.appendData()formats each row viaStringFormatterinto astd::stringstreamand, guarded by a process-widestd::mutex, writesprefix_ + body + '\n'to the stream selected byisStdErr_.PrintSink::computePrefix(printIdentifier, parallelism, taskIndex)mirrors Flink'sPrintSinkOutputWriter.open()prefix logic: empty whenparallelism == 1, otherwise<printIdentifier>:<taskIndex+1>>(or<taskIndex+1>>when the identifier is empty,<printIdentifier>>when parallelism is 1 and the identifier is non-empty).PrintTableHandledropspathand gainsprintIdentifier/isStdErr.serialize()now emits a"name": "PrintTableHandle"discriminator so the Java side (velox4jPolymorphicDeserializer) can round-trip the handle.parallelism/task_indexfromConnectorQueryCtx::sessionProperties()via a lambda IIFE in the member-init list, so the prefix isconstand computed exactly once.Test
parallelism.default = 2, nexmark q0, 10000 events): every bid row reaches<logdir>/flink-*-taskexecutor-x-*.out, no truncation, and each line carries the1>/2>subtask prefix.