Skip to content

feat: write column order#198

Merged
alespour merged 12 commits intomainfrom
feat/write-column-order
Mar 3, 2026
Merged

feat: write column order#198
alespour merged 12 commits intomainfrom
feat/write-column-order

Conversation

@alespour
Copy link
Contributor

@alespour alespour commented Mar 2, 2026

Proposed Changes

Adds support for specifying column (tag) order during ingestion via the new tag_order write option. This is primarily intended for the initial write, where sorting tags by query priority can significantly impact query performance:
https://docs.influxdata.com/influxdb3/enterprise/write-data/best-practices/schema-design/#sort-tags-by-query-priority

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • Tests pass
  • Commit messages are conventional

@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 97.22222% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.12%. Comparing base (2bfba51) to head (b68c657).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...fluxdb_client_3/write_client/client/write/point.py 97.50% 1 Missing ⚠️
...client/client/write/polars_dataframe_serializer.py 95.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #198      +/-   ##
==========================================
+ Coverage   70.89%   75.12%   +4.22%     
==========================================
  Files          35       35              
  Lines        2388     2420      +32     
==========================================
+ Hits         1693     1818     +125     
+ Misses        695      602      -93     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alespour alespour requested a review from Copilot March 2, 2026 14:36
@alespour alespour marked this pull request as ready for review March 2, 2026 14:36
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a tag_order write option to control tag serialization order in line protocol so users can influence first-write column order (notably for InfluxDB 3 Enterprise schema/query performance considerations).

Changes:

  • Introduces tag_order on WriteOptions and threads it through write paths to Point.to_line_protocol(...).
  • Updates Point tag serialization to honor a caller-specified tag priority order.
  • Adds/updates tests and documentation (README + CHANGELOG) for the new option.

Reviewed changes

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

Show a summary per file
File Description
tests/test_point.py Adds coverage for tag ordering behavior in Point.to_line_protocol(tag_order=...).
tests/test_influxdb_client_3.py Verifies WriteOptions.tag_order sanitization/defaults and exercises dict batching path.
influxdb_client_3/write_client/domain/write_precision.py Marks common model helpers as # pragma: no cover.
influxdb_client_3/write_client/client/write_api.py Adds tag_order to WriteOptions, sanitizes it, and plumbs it into serialization while filtering it from HTTP kwargs.
influxdb_client_3/write_client/client/write/point.py Implements ordered tag key selection based on tag_order before falling back to sorted remaining tags.
influxdb_client_3/write_client/client/_base.py Passes tag_order through _serialize() when serializing Point records.
README.md Documents how to configure tag_order via WriteOptions.
CHANGELOG.md Adds a feature entry for tag_order.

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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

Comments suppressed due to low confidence (1)

influxdb_client_3/write_client/client/write/polars_dataframe_serializer.py:104

  • self.tag_columns is used with + [self.timestamp_column] inside the fields comprehension, which will raise TypeError if callers pass a non-list iterable (e.g., set/tuple) for data_frame_tag_columns. Consider normalizing data_frame_tag_columns to a list in __init__ (or precomputing a set of excluded columns) and using membership checks against that set to avoid both type issues and repeated list allocations per column.
        fields = ",".join(
            f"{col}=\"{self.escape_value(row[self.column_indices[col]])}\"" if isinstance(row[self.column_indices[col]],
                                                                                          str)
            else f"{col}={str(row[self.column_indices[col]]).lower()}" if isinstance(row[self.column_indices[col]],
                                                                                     bool)  # Check for bool first
            else f"{col}={row[self.column_indices[col]]}i" if isinstance(row[self.column_indices[col]], int)
            else f"{col}={row[self.column_indices[col]]}"
            for col in self.column_indices
            if col not in self.tag_columns + [self.timestamp_column] and
            row[self.column_indices[col]] is not None and row[self.column_indices[col]] != ""
        )

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

@alespour alespour requested review from bednar and karel-rehor March 2, 2026 17:17
Copy link
Member

@bednar bednar left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@alespour alespour merged commit a055a0a into main Mar 3, 2026
16 checks passed
@alespour alespour deleted the feat/write-column-order branch March 3, 2026 08:56
@alespour alespour removed the request for review from karel-rehor March 3, 2026 08:57
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