Reflections
A reflection is an optimized materialization of source data or a query, similar to a materialized view, that is derived from an existing table or view. For more information about reflections, see Accelerating Queries with Reflections.
Creating Raw Reflections
SyntaxALTER DATASET <dataset_path>
CREATE RAW REFLECTION <reflection_name>
USING
DISPLAY (
<field_name>,
<field_name>,
...
)
[PARTITION BY (<field_name>, <field_name>, ...)]
[LOCALSORT BY (<field_name>, <field_name>, ...)]
[ARROW CACHE]
Parameters
{{< sql-section file="data/sql/reflections.json" data="creatingRawReflectionsParameters" >}}
Example
Create a raw reflection that sorts customers by last name and partitions them by countryALTER DATASET "@user1"."customers"
CREATE RAW REFLECTION customers_by_country
USING
DISPLAY (
id,
lastName,
firstName,
address,
country
)
PARTITION BY (country)
LOCALSORT BY (lastName)
Creating Aggregation Reflections
SyntaxALTER TABLE <dataset_path>
CREATE AGGREGATE REFLECTION <reflection_name>
USING
DIMENSIONS (<field_name>, <field_name>, ...)
MEASURES (<field_name> (<aggregation_type), <field_name> (<aggregation_type), ...)
[PARTITION BY (<field_name>, <field_name>, ...)]
[LOCALSORT BY (<field_name>, <field_name>, ...)]
[ARROW CACHE]
Parameters
{{< sql-section file="data/sql/reflections.json" data="creatingAggReflectionsParameters" >}}
Example
Create an aggregation reflection that counts the number of cities per state in which a company has a franchise and sorts the result by stateALTER TABLE Samples."samples.dremio.com"."zips.json"
CREATE AGGREGATE REFLECTION per_state
USING
DIMENSIONS (state)
MEASURES (city (COUNT))
LOCALSORT BY (state)
Creating External Reflections
SyntaxALTER DATASET <source_dataset_path>
CREATE EXTERNAL REFLECTION <reflection_name>
USING <target_dataset_path>
Parameters
{{< sql-section file="data/sql/reflections.json" data="externalReflections" >}}