Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support v1 query API GROUP BY semantics #25845

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

hiltontj
Copy link
Contributor

@hiltontj hiltontj commented Jan 16, 2025

Closes #25751
Closes #25831

This updates the v1 /query API handler to handle InfluxDB v1's unique query response structure when GROUP BY clauses are provided (#25751).

The distinction is in the addition of a "tags" field to the emitted series data that contains a map of the GROUP BY tags along with their distinct values associated with the data in the "values" field.

A set of snapshot tests were added to check that the structure of the data is correct when the carious kind of GROUP BY clauses are provided.

This required splitting the QueryExecutor into two query paths for InfluxQL and SQL, as this allowed for handling InfluxQL query parsing in advance of query planning (#25831).

@hiltontj hiltontj added the v3 label Jan 16, 2025
@hiltontj hiltontj self-assigned this Jan 16, 2025
@hiltontj hiltontj force-pushed the hiltontj/influxql-query-exec branch from 5dc5f3c to 9ca6f0b Compare January 16, 2025 02:45
@@ -292,6 +320,55 @@ async fn query_database(
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now, there is a bit of code repetition between this and the query_database_sql method.

}

// NOTE: the below code is currently copied from IOx and needs to be made pub so we can
// re-use it.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will open an issue in IOx to make these types visible from the appropriate crates.

@hiltontj hiltontj force-pushed the hiltontj/influxql-query-exec branch from 9ca6f0b to dceb6b6 Compare January 16, 2025 16:13
Comment on lines +968 to +971
// TODO: this is defined in schema crate, so needs to be made pub there:
const COLUMN_METADATA_KEY: &str = "iox::column::type";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to expose this in IOx as part of follow up work.

This updates the v1 /query API hanlder to handle InfluxDB v1's unique
query response structure when GROUP BY clauses are provided.

The distinction is in the addition of a "tags" field to the emitted series
data that contains a map of the GROUP BY tags along with their distinct
values associated with the data in the "values" field.

This required splitting the QueryExecutor into two query paths for InfluxQL
and SQL, as this allowed for handling InfluxQL query parsing in advance
of query planning.

A set of snapshot tests were added to check that it all works.
@hiltontj hiltontj force-pushed the hiltontj/influxql-query-exec branch from dceb6b6 to 6b6a555 Compare January 16, 2025 16:35
@hiltontj hiltontj requested a review from a team January 16, 2025 16:37
@hiltontj hiltontj marked this pull request as ready for review January 16, 2025 16:37
Copy link
Member

@pauldix pauldix left a comment

Choose a reason for hiding this comment

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

Tricky one, nice work 🚢

/// ```text
/// select * from foo group by t1, t2
/// ```
/// If `t1` is a tag in the table, but `t2` is not, nor is a field in the table, then the v1
Copy link
Member

Choose a reason for hiding this comment

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

This is super gnarly. Wow, the v1 API...

@hiltontj hiltontj merged commit b8a9448 into main Jan 16, 2025
13 checks passed
@hiltontj hiltontj deleted the hiltontj/influxql-query-exec branch January 16, 2025 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants