Skip to content

refactor(exporter): remove dead MetricFixedString interface method + FixedStringCol class#114

Merged
JoshDreamland merged 1 commit into
mainfrom
delete-fixed-string-col
Jun 18, 2026
Merged

refactor(exporter): remove dead MetricFixedString interface method + FixedStringCol class#114
JoshDreamland merged 1 commit into
mainfrom
delete-fixed-string-col

Conversation

@JoshDreamland

@JoshDreamland JoshDreamland commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Remove the MetricFixedString interface method and the FixedStringCol class that implements it. Both became unreferenced when PR #99 changed err_sqlstate from FixedString(5) to LowCardinality(String). Pure deletion; no behavior change. -35 LOC, three files.

Why this is its own PR

MetricFixedString was added in commit 9f89f4 (Feb 25 2026, "Extract an interface for statistics reporting") as a one-liner over clickhouse::ColumnFixedString from the clickhouse-cpp library. It served exactly one column (err_sqlstate, width 5).

PR #104 (merged 2026-06-04) replaced clickhouse-cpp with clickhouse-c, which doesn't have a built-in fixed-string column class. To preserve the interface contract, the port hand-rolled a 27-line FixedStringCol class on top of clickhouse-c's lower-level AppendFixed primitive. At landing time this was correcterr_sqlstate was still FixedString(5) in the schema and the call site was still MetricFixedString(5, "err_sqlstate").

PR #99 (merged 2026-06-10, six days later) changed err_sqlstate to LowCardinality(String) because FixedString does not round-trip cleanly through the Arrow IPC pipeline that prod uses, and ~270 SQLSTATE codes are dictionary-friendly. The call site moved to TagString("err_sqlstate"). The interface method and the hand-rolled class became unreachable code in main. Nobody noticed at the time.

This PR removes both. The reasoning that pushed err_sqlstate to LowCardinality(String) in PR #99 also explains why we don't want to re-add FixedString support to clickhouse-c "for parity" — the only consumer in this codebase was already moved off it deliberately, and any future fixed-width-binary column would hit the same Arrow round-trip issue.

Why FixedString isn't the right type for SQLSTATE (in case the question comes up)

Property FixedString(5) LowCardinality(String) (~270 codes)
Bytes/row 5 raw bytes 2 (UInt16 dict index), shared per-part dict ~1.6 KB
Filter speed byte compare per row integer compare per row, dictionary-aware pushdown
Arrow IPC equivalent FixedSizeBinary — not transparently castable to FixedString(N) on the CH side DictionaryUtf8 — round-trips cleanly
Empty (success) value 5 NUL bytes empty string, single dict entry

The Arrow round-trip is the deciding factor; storage and query speed both happen to favor LC too.

Test plan

  • All builds pass on PG 16/17/18 × amd64/arm64 (CI)
  • Code Style + TAP suite pass — no behavior change so nothing should regress
  • PGXN check passes

This is a no-op refactor; the deleted code was unreachable.

🤖 Generated with Claude Code


Note

Low Risk
Pure deletion of unreachable interface and implementation code with no remaining call sites.

Overview
Removes MetricFixedString from StatsExporter and drops the ClickHouse-only FixedStringCol implementation that backed it. ClickHouseExporter and OTelExporter no longer declare that factory method.

This is cleanup after err_sqlstate moved to TagString / LowCardinality(String); nothing in the tree still calls the fixed-width metric path. Export behavior is unchanged.

Reviewed by Cursor Bugbot for commit 50bca23. Bugbot is set up for automated code reviews on this repo. Configure here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes dead fixed-width string metric support from the exporter abstraction after err_sqlstate moved to LowCardinality(String), leaving no remaining call sites for the fixed-string API.

Changes:

  • Removed MetricFixedString(int len, string_view name) from the StatsExporter interface.
  • Removed now-unused overrides from OTelExporter and ClickHouseExporter.
  • Deleted the ClickHouse-only FixedStringCol implementation class.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/export/exporter_interface.h Drops the MetricFixedString pure virtual from StatsExporter.
src/export/otel_exporter.cc Removes the MetricFixedString override (previously a string_view column).
src/export/clickhouse_exporter.cc Removes MetricFixedString override and deletes the unused FixedStringCol column implementation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…FixedStringCol class

`MetricFixedString` was added in Feb 2026 (commit 9f89f4) when err_sqlstate
was the only column in events_raw of type FixedString(5). It had exactly
one caller, exactly one width, and was always going to.

PR #99 (merged 2026-06-10) changed err_sqlstate from FixedString(5) to
LowCardinality(String) and updated the call site from
`exporter->MetricFixedString(5, "err_sqlstate")` to
`exporter->TagString("err_sqlstate")`. The interface method became
unreferenced.

PR #104 (merged 2026-06-04 — before #99) had to reproduce
MetricFixedString in clickhouse-c by hand-rolling a `FixedStringCol`
class, since clickhouse-c has no built-in FixedString column type
unlike clickhouse-cpp. That work was correct when authored — the
column was still live — but became orphaned a week later when #99
landed. Nobody noticed.

Deletes the now-dead virtual + both impls. The CH-native side loses
the 27-line FixedStringCol class entirely; the OTel side loses a
3-line forward to MakeSvCol; the interface loses one virtual
declaration. Stats_exporter.cc already doesn't reference it.

No behavior change — this was unreachable code. -35 LOC.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JoshDreamland JoshDreamland merged commit b8e49ba into main Jun 18, 2026
12 checks passed
@JoshDreamland JoshDreamland deleted the delete-fixed-string-col branch June 18, 2026 03:08
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.

3 participants