fix: support aggregation with group-by on mixed tag and field columns#779
Open
oleksii-donets wants to merge 14 commits intodevelopmentfrom
Open
fix: support aggregation with group-by on mixed tag and field columns#779oleksii-donets wants to merge 14 commits intodevelopmentfrom
oleksii-donets wants to merge 14 commits intodevelopmentfrom
Conversation
…ueries (#768) Replace strings.containsStr/hasPrefix/hasSuffix with regexp.compile + =~/!~ operators for CONTAINS, NOT_CONTAINS, STARTS_WITH, ENDS_WITH, and LIKE filters. Regex is compiled into a separate variable before from() so InfluxDB can push the filter down to the storage engine. Add container tests for all partial search operators against both InfluxDB 2 and InfluxDB 3. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Add (?i) flag to Flux regex patterns and use ILIKE instead of LIKE in SQL queries for CONTAINS, NOT_CONTAINS, STARTS_WITH, ENDS_WITH, and LIKE operators. Add case-insensitive container tests for both engines. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…nflux2 (#768) Add new integration tests organized into @nested classes covering filters ($eq, $ne, $or), pagination (limit/offset), and edge cases (empty results, no-match count, expression aliases). Fix InfluxEngine to return a default row with zeros for ungrouped aggregation queries that produce empty results, aligning with SQL-standard behavior and InfluxDB 3. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…r across sub-queries (#768) The aggregation query builder was dropping the preamble (regex variable declarations like _re0 = regexp.compile(...)) when combining sub-queries, causing invalid Flux queries when using partial string filters (starts_with, contains, etc.) with aggregations. Also made the regex counter shared across all sub-queries to avoid variable name collisions. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Fix SqlQueryBuilder to only include expression columns in SELECT, preventing position mismatch when group-by has extra columns not in expressions. Fix FluxQueryBuilder to use fieldsAsCols pivot for aggregation queries and exclude group-by columns when selecting the count target field, enabling aggregation on field columns. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
Dependency ReviewThe following issues were found:
License Issuessettings.gradle
OpenSSF Scorecard
Scanned Files
|
After fieldsAsCols() pivot, tags are regular columns too, so they can be used as count() targets. This reduces the chance of hitting a "no eligible column" error when all fields are in the group key. Exclude only _time (Flux cannot aggregate time-type columns) and group-key columns. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…33-aggregation-on-multiple-columns Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
Dependency ReviewThe following issues were found:
License Issuessettings.gradle
OpenSSF Scorecard
Scanned Files
|
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
count() previously picked an arbitrary schema column (e.g. project_id) which may be absent from actual data in the queried time range, causing InfluxDB "column does not exist" errors. Use _measurement instead — it is always present after fieldsAsCols(), is a string type (Flux cannot aggregate time-type columns), and is never null. Add mcp_analytics container tests that seed data WITHOUT project_id tag to verify count() works when schema-defined columns are absent. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
KirylKurnosenka
previously approved these changes
Mar 23, 2026
Base automatically changed from
feat/768-regex-pushdown-for-partial-search
to
development
March 23, 2026 15:27
The base branch was changed.
siarhei-fedziukovich
approved these changes
Mar 23, 2026
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.
Applicable issues
Description of changes
Fix aggregation queries when group-by includes columns not present in the expressions list, when grouping by both tags and fields simultaneously, and when schema-defined columns are absent from actual data:
fieldsAsCols()pivot instead of field filtering, enabling group-by on field columns. Exclude group-by columns when selecting thecount()target field to avoid Flux's "cannot aggregate columns that are part of the group key" error._measurementas the column forcount()instead of picking an arbitrary schema column. Previously,count()could pick a column (e.g.project_id) that was absent from the actual data in the queried time range, causing InfluxDB "column does not exist" errors._measurementis always present afterfieldsAsCols(), is a string type (Flux cannot aggregate time-type columns), and is never null.aggregateWithFieldFilterAndGroupByTagAndFieldtest toAbstractInfluxContainerTest, verifying both InfluxDB 2 and InfluxDB 3 engines handle field filtering with mixed tag+field group-by correctly.mcp_analyticstable to test configs and seed data WITHOUTproject_idtag. NewMissingColumnTestscontainer tests verifycount()works when schema-defined columns are absent from actual data.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.