Repository navigation
Add FORMAT PNG support - #74691
Add FORMAT PNG support#74691
FORMAT PNG support#74691Conversation
fbffa70 to
0fcfe5e
Compare
|
@alexey-milovidov filed the fix as #106667. Both |
…racked per-row pointer table Two issues raised by the automated reviewer in the `FORMAT PNG` output path: - `PNGOutputFormat` accumulates rendered pixels and the implicit coordinate cursor in its `serializer`, but did not override `resetFormatterImpl`. Reusable output paths such as `MessageQueueSink` finalize one image, restart the buffer, and call `resetFormatter` for the next message; without a reset the next image carried over stale pixels and could throw `TOO_MANY_ROWS`. Override `resetFormatterImpl` to call the existing `PNGSerializer::reset`. - `PNGWriter::writeImage` built a `std::vector<png_bytep>` table of one pointer per row before encoding. Its size is proportional to the user-controlled `output_format_image_height`, and it was allocated outside the tracked ClickHouse allocator. Write the image one row at a time with `png_write_row` instead, pointing directly into the tightly packed pixel buffer, so no per-row pointer table is materialized. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Addressed the two remaining automated-review findings in
Both changed translation units compile cleanly. Did not merge |
… call The `arm_tidy` build failed with `readability-ambiguous-smartptr-reset-call`: calling `serializer->reset()` is ambiguous because both the `std::unique_ptr` and the pointee `PNGSerializer` expose a `reset` method. Dereference explicitly with `(*serializer).reset()` to call the pointee's `reset`, as suggested by the linter. Co-Authored-By: Claude Opus 4.8 <[email protected]>
After merging `master`, the `04305`/`04306`/`04307` prefixes were taken by unrelated tests. Renumber the `PNG` format tests to `04326`/`04327`/`04328` (next free numbers) and update the in-test temp-directory names accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Merged latest
Built with |
|
@groeneai, investigate "Logical error: 'this->visited_views == right->visited_views' (STID: 1288-3e19)" and provide a fix. |
|
@groeneai, check the message above ^ |
|
Reproduced and root-caused the Deterministic repro on current master (debug build), no fuzzing needed: CREATE TABLE source (a Int32) ENGINE=MergeTree ORDER BY tuple();
CREATE TABLE source_null AS source ENGINE=Null;
CREATE TABLE dest (c UInt64, cs UInt64) ENGINE=MergeTree ORDER BY tuple();
CREATE MATERIALIZED VIEW mv1 TO source_null AS SELECT * FROM source;
CREATE MATERIALIZED VIEW mv2 TO source_null AS SELECT * FROM source; -- 2nd MV, same target
CREATE MATERIALIZED VIEW mv_a TO dest AS
SELECT count() AS c, (SELECT count() FROM source_null) AS cs FROM source_null;
INSERT INTO source SELECT number FROM numbers(2000)
SETTINGS min_insert_block_size_rows=1500, max_insert_block_size=1500;Aborts with the identical CI stack: Root cause: when two materialized views write to the same target table, parallel-insert squashing (keyed per target table) merges their output chunks in Fix is being finalized (restrict the equality check to the dedup-enabled path, plus a regression test covering the two-MVs-to-same-target + chained-scalar-subquery scenario). Separate PR to follow shortly. |
|
The fix for the Status of this PR otherwise: all 30 review threads are resolved, the branch has |
|
📊 Cloud Performance Report 🟢 AI verdict: This PR adds a PNG output format (libpng) and ALTER ADD ENUM VALUES syntax, plus documentation — none of which touches the query-execution path that ClickBench or TPC-H exercise. The measured improvements (Q22 -24%, Q23 -33%, Q7 -36%, Q20 -50%) therefore cannot be attributed to this change. The largest, most consistent deltas (Q23, Q7, Q20) are large enough to stand as measured, but are most plausibly build or environment differences rather than a query-logic effect; Q22 falls below that threshold and is downgraded to not-sure. TPC-H Q4 is borderline and trending on master, so treat it as inconclusive. clickbench🟢 1 improved · Flagged queries (2 of 43)
q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 2 improved · Flagged queries (3 of 22)
q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. Debug info
|
…ngjmp The libpng error and warning callbacks ran `writer->error_message = error_msg`, where `error_message` was a `std::string`. That assignment may allocate, and on allocation failure it throws `std::bad_alloc`. Because the callbacks are invoked from libpng's C frames and finish with `png_longjmp`, an exception escaping the callback is undefined behavior. Store the message in a fixed-size `char` buffer instead and copy into it with a bounded `memcpy`, so the callbacks no longer allocate before `png_longjmp`. libpng's own messages are bounded (`PNG_MAX_ERROR_TEXT` is 196); a longer message is silently truncated. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Fast test now checks out contrib/libpng and configures the build with -DENABLE_LIBPNG=1 (see ci/jobs/fast_test.py), so the FORMAT PNG feature is available there. The no-fasttest tag on the PNG tests, whose stated rationale was "requires libpng (not built in fast test)", is no longer accurate and only removes these tests from the fastest CI signal. The tests rely only on standard utilities (python3 stdlib, od, file, base64, md5sum), all present in the Fast Test image. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`GH.get_changed_files` fetches the list of files a PR touches via `gh api .../pulls/<n>/files`. The result is stored once into the job KV data by the `store_data` pre-hook and read back by several other workflow hooks (`pr_labels_and_category`, `team_notifications`, `feature_docs`, ...). The function had a `for attempt in range(3)` retry loop, but for the PR path it was dead code: an `assert exit_code == 0` ran right after the `gh api` call, so the very first transient failure raised before any retry could happen. When the GitHub API hiccupped (rate limiting, a 5xx, or a GraphQL "Something went wrong" error), `store_data` aborted without populating `changed_files`, and every downstream hook then read `None` from the KV data and died far away with an opaque `TypeError: 'NoneType' object is not iterable` / `can only join an iterable`, with nothing in the report pointing at the real cause. Changes: - Make the retry actually retry: drop the premature `assert`, unify the PR and commit code paths into a single command, and retry every non-zero exit code (this is an idempotent read, so a spurious retry is cheap and the exit code alone does not reliably distinguish transient from permanent errors). Five attempts with a small linear backoff. - On final failure, print and (when `strict`) raise a message that includes the command, exit code, stderr and stdout, so the failure is diagnosable directly from the report. The non-strict contract of returning `None` is preserved for callers that tolerate it (`Runner` and the master/release path of `store_data`). - In the three consumer hooks, assert `changed_files is not None` with an actionable message instead of letting a missing value surface as a bare `TypeError`. Observed on PR ClickHouse#74691 (commit 8e08fc0), which blocked the whole pipeline because the failing pre-hooks were never able to dispatch the real jobs: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=74691&sha=8e08fc02490688916fb3bffe4e897cbe50f2702a&name_0=PR&name_1=Config%20Workflow Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 419/512 (81.84%) | Lost baseline coverage: none · Uncovered code |
| void PNGWriter::writeImage(const unsigned char * pixels) | ||
| { | ||
| if (initialized) | ||
| throw Exception(ErrorCodes::LOGICAL_ERROR, "PNG writer can encode only one image"); |
There was a problem hiding this comment.
Using LOGICAL_ERROR unnecessarily leads to aborts in debug:
SELECT toUInt8(number % 256) AS v
FROM numbers(10000000)
SETTINGS output_format_image_width = 10000000, output_format_image_height = 1
FORMAT PNG
| } | ||
|
|
||
| /// Sixels encode 6 vertical pixels at a time, so the image is processed in horizontal bands of 6 rows. | ||
| std::vector<int> band_colors(width * 6); |
There was a problem hiding this comment.
This should be tracked. It can allocate GBs of memory. Same for line
|
Follow up: #107537 |
| "contrib/StringZilla", | ||
| "contrib/rust_vendor", | ||
| "contrib/clickstack", | ||
| "contrib/libpng", |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Added the PNG output format support, allowing query output results to be directly rendered as PNG images
Documentation entry for user-facing changes
Motivation: This feature is useful as a built-in visualization tool
Documentation is written (mandatory for new features).
CI Settings (Only check the boxes if you know what you are doing):
Note
Medium Risk
Introduces a new output format backed by a new third-party dependency (
libpng) and new format settings, which can affect build/link behavior and output correctness across platforms.Overview
Adds
FORMAT PNGto render query results directly as PNG images, including support for RGB/RGBA/grayscale/binary modes and optional explicitx/ypixel coordinates.Introduces new format settings
output_format_image_width/output_format_image_height(wired throughFormatFactoryintoFormatSettings) and documents the format.Integrates
libpngas a new contrib submodule with CMake plumbing/feature flags (ENABLE_LIBPNG/USE_LIBPNG), updates CI fast-test configuration, adds stateless coverage tests, and extends license detection and spellcheck dictionaries for new terminology.Reviewed by Cursor Bugbot for commit 3ae65c2. Bugbot is set up for automated code reviews on this repo. Configure here.
Version info
26.6.1.779