-
Notifications
You must be signed in to change notification settings - Fork 3.8k
docs: add docs for projections #18056
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
Changes from 3 commits
867c141
b7d5bca
ef279e7
be26b1d
3e3657b
8ede737
67434d5
2c566ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -396,6 +396,46 @@ The `filter` conditionally filters input rows during ingestion. Only rows that p | |
| ingested. Any of Druid's standard [query filters](../querying/filters.md) can be used. Note that within a | ||
| `transformSpec`, the `transforms` are applied before the `filter`, so the filter can refer to a transform. | ||
|
|
||
| ### Projections | ||
|
|
||
| Projections are pre-aggregated segments that can speed up queries by reducing the number of rows that need to be processed. Use the `projectionsSpec` block to define projections for your data during ingestion or [create them afterwards](../querying/projections.md#after-ingestion). | ||
|
|
||
| Note that any projections you define becomes a dimension for your datasource. To remove a projection from your datasource, you need to reingest the data with the projection removed. Alternatively, you can use a query context parameter to not use projections for a specific query. | ||
|
||
|
|
||
| ```json | ||
| "projectionsSpec": { | ||
| "projections": [ | ||
| { | ||
| "name": "daily_channel_summary", | ||
| "dimensions": [ | ||
| "channel" | ||
| ], | ||
| "granularity": "DAY", | ||
| "metrics": [ | ||
| { | ||
| "type": "longSum", | ||
| "name": "total_added", | ||
| "fieldName": "added" | ||
| }, | ||
| { "type": "longSum", | ||
| "name": "total_deleted", | ||
| "fieldName": "deleted" | ||
| }, | ||
| { "type": "longSum", | ||
| "name": "total_delta", | ||
| "fieldName": "delta" | ||
| }, | ||
| { | ||
| "type": "cardinality", | ||
| "name": "distinct_users", | ||
| "fieldName": "user" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ### Legacy `dataSchema` spec | ||
|
|
||
| :::info | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,181 @@ | ||||||
| --- | ||||||
| id: projections | ||||||
| title: Query projections | ||||||
| sidebar_label: Projections | ||||||
| description: . | ||||||
| --- | ||||||
|
|
||||||
| import Tabs from '@theme/Tabs'; | ||||||
| import TabItem from '@theme/TabItem'; | ||||||
|
|
||||||
| <!-- | ||||||
| ~ Licensed to the Apache Software Foundation (ASF) under one | ||||||
| ~ or more contributor license agreements. See the NOTICE file | ||||||
| ~ distributed with this work for additional information | ||||||
| ~ regarding copyright ownership. The ASF licenses this file | ||||||
| ~ to you under the Apache License, Version 2.0 (the | ||||||
| ~ "License"); you may not use this file except in compliance | ||||||
| ~ with the License. You may obtain a copy of the License at | ||||||
| ~ | ||||||
| ~ http://www.apache.org/licenses/LICENSE-2.0 | ||||||
| ~ | ||||||
| ~ Unless required by applicable law or agreed to in writing, | ||||||
| ~ software distributed under the License is distributed on an | ||||||
| ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||||||
| ~ KIND, either express or implied. See the License for the | ||||||
| ~ specific language governing permissions and limitations | ||||||
| ~ under the License. | ||||||
| --> | ||||||
|
|
||||||
| Projections are a type of aggregation that is computed and stored as part of a segment. The pre-aggregated data can speed up queries by reducing the number of rows that need to be processed for any query shape that matches a projection. | ||||||
|
||||||
| Projections are a type of aggregation that is computed and stored as part of a segment. The pre-aggregated data can speed up queries by reducing the number of rows that need to be processed for any query shape that matches a projection. | |
| Projections are a type of aggregation that Druid computes and stores as part of a segment. The pre-aggregated data reduces the number of rows for the query engine to process. This can speed up queries for query shapes that match a projection. |
What type of "part" of the segment? Like a column? Or its own thing?
What does it mean to "match the projection?" An example might be in order.
317brian marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
317brian marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
317brian marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be at line 34. It follows directly from the heading. This also doesn't make sense b/c ingestion time and after the datasource is created are not exclusive.
Would it make sense to say a new datasource vs/ existing datasource?
You can create a projection:
- in the ingestion spec/query in an new datasource
- in the catalalog for an existing data source
- in the compaction spec in an existing datas source.
Note that the catalog is preferred over compaction spec for existing data sources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new/existing datasource doesn't make sense cause you can technically run the ingestion for a datasource again with the projection defined i think.
What about As part of your ingestion and Manually add a projection
317brian marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this just native json ingestion? I don't think of MSQ ingestion having an "ingestion spec"
I feel like both of these need examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, there's an example in the linked page. i can copy it over. an msq example is on my to do list
317brian marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw, this isn't strictly true - while i think in the future we want to recommend the catalog as the way to do things, it is also possible to define the projection specs in an 'inline' compaction spec as well in a projections property (where inline is what we call the class, the non-catalog based compaction spec).
It is also worth mentioning that the catalog compaction spec is not as fully featured as the inline compaction spec in terms of functionality, for example it can not change the schema of the base table like can be done with an inline spec, and some other things too, i forget off the top of my head.
The catalog is required to build projections for MSQ inserts/replaces though, so that should probably be
317brian marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
317brian marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
317brian marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - `noProjections`: `true` or `false`. The query engine won't use any projections. | |
| - `noProjections`: Set to `true` to prevent the query engine from using projections altogether. Defaults to `false`. |
seriously this should be useProjections which defaults to true and you could set to false to disable. @clintropolis :/
Uh oh!
There was an error while loading. Please reload this page.