Skip to content

fix(cpp): emit bare measurement names for tree-model result columns - #993

Merged
ColinLeeo merged 2 commits into
apache:developfrom
ColinLeeo:colin/tsfile-143-tree-column-names
Oct 9, 2026
Merged

ColinLeeo merged 2 commits into
apache:developfrom
ColinLeeo:colin/tsfile-143-tree-column-names

Conversation

@ColinLeeo

Copy link
Copy Markdown
Contributor

Tree-model head/cat/export emitted fully-qualified "device.measurement" column names (and NDJSON keys), but the CLI requirement specifies bare measurement names: e.g. head -d root.factory.d1 -m temp -m status should print time temp status, and head -m temp -f ndjson should emit {"time":"...","temp":...}.

Strip the device prefix at the output layer only for tree-model row queries, leaving the reader's get_column_name contract and the table model untouched.

Tree-model head/cat/export emitted fully-qualified "device.measurement"
column names (and NDJSON keys), but the CLI requirement specifies bare
measurement names: e.g. `head -d root.factory.d1 -m temp -m status`
should print `time temp status`, and `head -m temp -f ndjson` should
emit {"time":"...","temp":...}.

Strip the device prefix at the output layer only for tree-model row
queries, leaving the reader's get_column_name contract and the table
model untouched.
@ColinLeeo
ColinLeeo requested a balanced review from Copilot October 8, 2026 08:12

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open findings
What changed in this PR

Adjusts CLI output for tree-model row queries so result columns (headers and NDJSON keys) use bare measurement names instead of fully-qualified device.measurement, matching the CLI requirement examples.

Changes:

  • Adds an optional device-prefix stripping parameter to emit_result_set and applies it in the tree-model row_query command path.
  • Updates formatting logic to strip "<device>." from column names at output time.
  • Updates/extends CLI e2e + golden outputs to assert bare measurement names for CSV/table/NDJSON.
File Description
cpp/​tools/​format/​result_set_format.h Extends emit_result_set API with optional device-prefix stripping parameter.
cpp/​tools/​format/​result_set_format.cc Implements prefix stripping when building output headers.
cpp/​tools/​commands/​row_query.cc Passes resolved tree device into formatter to enable stripping for tree-model queries only.
cpp/​test/​tools/​model_format_e2e_test.cc Updates expected CSV header to bare measurement names.
cpp/​test/​tools/​command_e2e_test.cc Adds coverage for implicit device resolution still producing bare measurement output.
cpp/​test/​tools/​golden/​tree_* Updates golden outputs (table/csv/ndjson) to bare measurement names.

🧠 Review effort: Lite


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment on lines +81 to +82
const std::string device_prefix =
strip_device_prefix.empty() ? std::string() : strip_device_prefix + ".";
Comment on lines +88 to +93
std::string name = meta->get_column_name(i);
if (!device_prefix.empty() && name.size() > device_prefix.size() &&
name.compare(0, device_prefix.size(), device_prefix) == 0) {
name = name.substr(device_prefix.size());
}
header.push_back(std::move(name));
Comment on lines +38 to 39
const std::string& strip_device_prefix = "");

Comment on lines +81 to +82
const std::string device_prefix =
strip_device_prefix.empty() ? std::string() : strip_device_prefix + ".";
@ColinLeeo
ColinLeeo merged commit 0e2ceed into apache:develop Oct 9, 2026
42 of 43 checks passed
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.

2 participants