influxdb/iox_query
Stuart Carnie 2b74f07fe5
feat: Support `GROUP BY` with tags in raw `SELECT` queries (#7109)
* chore: Normalise name of Call expression to lowercase

Simplifies matching functions in planner, as they are guaranteed to be
lowercase.

This also ensures compatibility with InfluxQL when generating column
alias names, which are reflected in updated tests.

* chore: Ensure aggregate functions fail gracefully.

* feat: GROUP BY tag support

* feat: Ensure schema-level metadata is propagated

Requires: https://github.com/apache/arrow-rs/issues/3779

* chore: Add some tests to validate GROUP BY output

* chore: Add clarifying comment

* chore: Declare message in flight.proto

The metadata is public API, so best practice is to encode this in a way
that is most compatible for clients in other languages, and will also
document the history of schema changes.

Added tests to validate the metadata is encoded correctly.

* chore: Placate linters

* chore: Use correct column in test cases

* chore: Add `is_projected` to the TagKeyColumn message

`is_projected` is necessary to inform a client whether it should include
the tag key is used exclusively for the group key (false) or also
projected in the `SELECT` column list.

* refactor: Move constants to `schema` crate per PR feedback

* chore: rustfmt 🙄

* chore: Update docs for InfluxQlMetadata

Co-authored-by: Andrew Lamb <alamb@influxdata.com>

---------

Co-authored-by: Andrew Lamb <alamb@influxdata.com>
2023-03-07 22:40:23 +00:00
..
src feat: Support `GROUP BY` with tags in raw `SELECT` queries (#7109) 2023-03-07 22:40:23 +00:00
Cargo.toml feat: Support `GROUP BY` with tags in raw `SELECT` queries (#7109) 2023-03-07 22:40:23 +00:00
README.md ci: fix cargo deny (#4629) 2022-05-18 09:38:35 +00:00

README.md

IOx Query Layer

The IOx query layer is responsible for translating query requests from different query languages and planning and executing them against Chunks stored across various IOx storage systems.

Query Frontends

  • SQL
  • Storage gRPC
  • Flux (possibly in the future)
  • InfluxQL (possibly in the future)
  • Others (possibly in the future)

Sources of Chunk data

  • ReadBuffer
  • MutableBuffer
  • Parquet Files
  • Others (possibly in the future, like Remote Chunk?)

The goal is to use the shared query / plan representation in order to avoid N*M combinations of language and Chunk source.

Thus query planning is implemented in terms of traits, and those traits are implemented by different chunk implementations.

Among other things, this means that this crate should not depend directly on the ReadBuffer or the MutableBuffer.

┌───────────────┐  ┌────────────────┐    ┌──────────────┐      ┌──────────────┐
│Mutable Buffer │  │  Read Buffer   │    │Parquet Files │  ... │Future Source │
│               │  │                │    │              │      │              │
└───────────────┘  └────────────────┘    └──────────────┘      └──────────────┘
        ▲                   ▲                    ▲                     ▲
        └───────────────────┴─────────┬──────────┴─────────────────────┘
                                      │
                                      │
                     ┌─────────────────────────────────┐
                     │          Shared Common          │
                     │   Predicate, Plans, Execution   │
                     └─────────────────────────────────┘
                                      ▲
                                      │
                                      │
               ┌──────────────────────┼─────────────────────────┐
               │                      │                         │
               │                      │                         │
               │                      │                         │
     ┌───────────────────┐  ┌──────────────────┐      ┌──────────────────┐
     │   SQL Frontend    │  │   gRPC Storage   │ ...  │ Future Frontend  │
     │                   │  │     Frontend     │      │ (e.g. InfluxQL)  │
     └───────────────────┘  └──────────────────┘      └──────────────────┘

We are trying to avoid ending up with something like this:

                          ┌─────────────────────────────────────────────────┐
                          │                                                 │
                          ▼                                                 │
                   ┌────────────┐                                           │
                   │Read Buffer │                  ┌────────────────────────┤
        ┌──────────┼────────────┼─────┬────────────┼────────────────────────┤
        │          └────────────┘     │            ▼                        │
        ▼                 ▲           │    ┌──────────────┐                 │
┌───────────────┐         │           │    │Parquet Files │                 │
│Mutable Buffer │         │           ├───▶│              │...              │
│               │◀────────┼───────────┤    └──────────────┘   ┌─────────────┼┐
└───────────────┘         │           │            ▲          │Future Source││
        ▲                 │           ├────────────┼─────────▶│             ││◀─┐
        │                 │           │            │          └─────────────┼┘  │
        │                 │           │            │                        │   │
        │                 │           │            │                        │   │
        │      ┌──────────┘           │            │                        │   │
        │      │                      │            │                        │   │
        │      ├──────────────────────┼────────────┘                        │   │
        └──────┤                      │                                     │   │
               │                      │                                     │   │
               │                      │                                     │   │
               │                      │                                     │   │
               │                      │                                     │   │
               │                      │                                     │   │
               │                      │                                     │   │
               │                      │                                     │   │
     ┌───────────────────┐  ┌──────────────────┐      ┌──────────────────┐  │   │
     │   SQL Frontend    │  │   gRPC Storage   │ ...  │ Future Frontend  │  │   │
     │                   │  │     Frontend     │      │ (e.g. InfluxQL)  │──┴───┘
     └───────────────────┘  └──────────────────┘      └──────────────────┘