Skip to main content
Version: current [26.x Preview]

Manually Manage Reflections

With Autonomous Reflections reducing the need for manual work, you no longer need to create or manage reflections. However, when Autonomous Reflections are not enabled or for situations that require manual control, this page provides guidance on getting reflection recommendations, creating, managing, and testing reflections in Dremio.

When a reflection is created, Dremio runs a single job with two steps:

  • The first step writes the query results as a materialization to the distributed acceleration storage by running the REFRESH REFLECTION SQL command.
  • The second step registers the materialization table and its metadata with the catalog so that the query optimizer can find the reflection's definition and structure.

The following screenshot shows the REFRESH REFLECTION SQL command used to create the reflection named Super-duper reflection:

Reflection creation job listed on the Jobs page in the Dremio console

The reflection creation job is listed as a single job on the Jobs page, as shown in the example below:

Reflection creation job listed on the Jobs page in the Dremio console

Dremio creates all reflections as Apache Iceberg tables, and the metadata for the reflection is generated at the same time.

Reflection Recommendations

When Autonomous Reflections are not enabled, Dremio automatically provides recommendations to add and remove reflections based on query patterns to optimize performance for queries on Iceberg tables, Parquet datasets, and views based on them. Recommendations to add reflections are sorted by overall effectiveness, with the most effective recommendations shown on top. Effectiveness relates to metrics such as the estimated number of accelerated jobs, potential increase in query execution speedup, and potential time saved during querying. These are rough estimates based on past data that can give you insight into the potential benefits of each recommendation. Reflections created using these recommendations refresh automatically when source data changes on:

  • Iceberg tables: when the table is modified through Dremio or other engines. Dremio polls tables every 10 seconds.
  • Parquet datasets: when metadata is updated in Dremio. To view and apply reflection recommendations:
  1. Navigate to Project Settings
  2. Select Reflections.
  3. Click Reflections Recommendations to access the list of suggested reflections.
  4. To apply a recommendation, click on the plus icon at the end of the corresponding row.

Reflections created using usage based recommendations are only used when fully synchronized with their source data to ensure up-to-date query results.

Manually Requesting Recommendations for Specific Jobs

You can generate recommendations for default raw and aggregation reflections by submitting job IDs to accelerate specific SQL queries using either the SYS.RECOMMEND_REFLECTIONS table function or the Recommendations API. Obtain the job IDs by looking them up on the Jobs page.

Running the SYS.RECOMMEND_REFLECTIONS Table Function

The SYS.RECOMMEND_REFLECTIONS table function returns a table of one or more recommendations.

Syntax for the SYS.RECOMMEND_REFLECTIONS table function
SELECT * FROM TABLE(SYS.RECOMMEND_REFLECTIONS(ARRAY['<jobId>', '<jobId>']))

The SYS.RECOMMEND_REFLECTIONS function's argument must be an array literal.

Parameters

The SYS.RECOMMEND_REFLECTIONS table function has one parameter: an array that contains the job IDs for the SQL queries that you want to accelerate.

You can list up to 100 job IDs in each SYS.RECOMMEND_REFLECTIONS query. You must have permission to view every job you list in the query.

Output

The output for SYS.RECOMMEND_REFLECTIONS queries is a table that includes the following columns:

Column NameData TypeDescription
view_sqlvarcharIf the recommendation is for a default raw reflection:
The value in this field is --Default Raw Reflection.

If the recommendation is for an aggregation reflection:
An SQL command that creates a view based on the initial SQL query in the referenced job ID. Dremio uses this view to create an aggregation reflection when you run the SQL command from the reflection_sql column. Before running this command, ensure that you have already created an Arctic catalog or folder named recommended_view.
reflection_sqlvarcharIf the recommendation is for a default raw reflection:
An SQL command for defining the reflection on an existing view.

If the recommendation is for an aggregation reflection:
An SQL command that alters and adds an aggregation reflection to the view that is created when you run the SQL command in the view_sql column. Before running this command, ensure that you have run the corresponding command in the view_sql column.

Dremio automatically consolidates recommendations for aggregation reflections when possible to create a single recommendation for similar SQL queries, so the output table may not contain an individual row that corresponds to each job ID listed in the SYS.RECOMMEND_REFLECTIONS query.
job_idslistThe unique identifier of the jobs that ran the queries for which the recommendation is given.
reflection_scoredoubleDremio's score for the recommended reflection's quality, on a scale of 0 (worst) to 100 (best). The reflection_score value considers the recommended reflection's anticipated quality compared to existing reflections and other recommended reflections, as well as the likely improvement in query run times if the recommended reflection is implemented.
average_improvement_factordoubleThe likely average multiplicative rate of improvement for each query if you implement the recommended reflection. For example, if the average_improvement_factor value is 2.34, implementing the recommended reflection is likely to speed up each query by 2.34 times, on average.
average_improvement_msdoubleThe likely average improvement, in milliseconds, for each query if you implement the recommended reflection. For example, if the average_improvement_ms value is 5400, implementing the recommended reflection is likely to save an average of 5400 milliseconds for each query that uses the reflection.

Example Query and Output

To request a recommendation, you must have the job ID for at least one SQL query that you want to accelerate. For example, suppose this is the SQL query:

Example SQL Query
SELECT Max("p_size")
FROM s3.bucket1.tpch.sf10.parquet.part
JOIN s3.bucket1.tpch.sf10.parquet.lineitem
ON "p_partkey" = "l_partkey"
GROUP BY "p_brand"
Obtaining Recommendations
  1. Retrieve the job ID for the query.

  2. Run the SYS.RECOMMEND_REFLECTIONS query with the job ID. In the following example, the job ID is 844c0023-6272-8b16-aef3-aea289acadb1:

    Example SYS.RECOMMEND_REFLECTIONS Query
    SELECT * FROM TABLE(SYS.RECOMMEND_REFLECTIONS(ARRAY['844c0023-6272-8b16-aef3-aea289acadb1']))

The result of the query is returned in this table:

Example Results
view_sqlreflection_sqljob_idsreflection_scoreaverage_improvement_factoraverage_improvement_ms
CREATE VIEW "recommended_view"."Dataset_9d74a03b-747a-42a2-a5ca-7f9c6f77b55d" AS SELECT "part"."P_BRAND" AS "F0[P_BRAND]", "part"."P_SIZE" AS "F1[P_SIZE]", "part"."P_PARTKEY" AS "extra#0", "part"."P_NAME" AS "extra#1", "part"."P_MFGR" AS "extra#2", "part"."P_TYPE" AS "extra#4", "part"."P_CONTAINER" AS "extra#6", "part"."P_RETAILPRICE" AS "extra#7", "part"."P_COMMENT" AS "extra#8", "lineitem"."L_ORDERKEY" AS "extra#9", "lineitem"."L_PARTKEY" AS "extra#10", "lineitem"."L_SUPPKEY" AS "extra#11", "lineitem"."L_LINENUMBER" AS "extra#12", "lineitem"."L_QUANTITY" AS "extra#13", "lineitem"."L_EXTENDEDPRICE" AS "extra#14", "lineitem"."L_DISCOUNT" AS "extra#15", "lineitem"."L_TAX" AS "extra#16", "lineitem"."L_RETURNFLAG" AS "extra#17", "lineitem"."L_LINESTATUS" AS "extra#18", "lineitem"."L_SHIPDATE" AS "extra#19", "lineitem"."L_COMMITDATE" AS "extra#20", "lineitem"."L_RECEIPTDATE" AS "extra#21", "lineitem"."L_SHIPINSTRUCT" AS "extra#22", "lineitem"."L_SHIPMODE" AS "extra#23", "lineitem"."L_COMMENT" AS "extra#24"
FROM "s3"."bucket1"."tpch"."sf10"."parquet"."lineitem"
INNER JOIN "s3"."bucket1"."tpch"."sf10"."parquet"."part" ON "part"."P_PARTKEY" = "lineitem"."L_PARTKEY"
ALTER DATASET "recommended_view"."Dataset_9d74a03b-747a-42a2-a5ca-7f9c6f77b55d" CREATE AGGREGATE REFLECTION "agg_0e07a376-7f8e-4c68-b2ce-6f6e819bebe6" USING DIMENSIONS ("F0[P_BRAND]") MEASURES ("F1[P_SIZE]" (MAX))"6j6c34cf-9drf-b07a-5ab7-abea69a66d00", "1a3c67c0-aab0-f9fb-97b4-af374b520100", "1a3c67c0-db35-3645-9ef1-2a84e4d0ce00"50.0010.007196
Using the Recommendation
  1. If a recommendation is for an aggregation reflection:

    1. Create an Arctic catalog or folder named recommended_view.
    2. Run the query listed in the view_sql column to create a view based on the initial SQL query.
  2. Run the query listed in the reflection_sql column to create the recommended reflection and wait for the reflection to finish refreshing.

  3. When the reflection refresh is complete, run the SQL query to observe the acceleration due to the added reflection.

Limitations

The SYS.RECOMMEND_REFLECTIONS table function has the following limitations:

  • The function cannot provide recommendations for jobs with multiple nested queries that contain joins.
  • An SQL query can contain only inner joins. Outer joins that are part of a view definition are also supported. Other types of joins are not supported.
  • An SQL query cannot contain Window functions.

Sending Requests to the Recommendations API

You can use the Recommendations API to submit the job IDs of jobs that ran SQL queries and receive recommendations for reflections that can accelerate those queries.

Locations of the Reflections Editor

You use the reflections editor to create, edit, and remove raw and aggregation reflections.

If you know which table or view you want to create a reflection from, follow either of these steps to open the reflections editor:

  • In the space in which the anchor is located, click the gear icon in the Action field for the anchor. In the sidebar of the Dataset Settings window, select Reflections.
  • In the space in which the anchor is located, click the name of the anchor. Then, click Reflections in the bar at the top of the screen.

You can also open the reflections editor from an existing reflection that is listed in the Reflections page. Follow these steps to open the reflections editor:

  1. Open the Reflections page.
  2. Click the gear in the sidebar, and then select Reflections in the sidebar of the Settings page.
  3. Click the name of the reflection. The Acceleration window is opened. The editor appears in this window.

Creating Raw Reflections

You can use the reflections editor to create two types of raw reflection:

  • A default raw reflection that includes all of the columns of the anchor, but does not sort or horizontally partition on any columns

  • A raw reflection that includes all or a subset of the columns of the anchor, and that does one or both of the following things:

    • Sorts on one or more columns
    • Horizontally partitions the data according to the values in one or more columns
note

For creating reflections on views and tables with row-access and column-masking policies, see Using Reflections on Datasets with Policies.

Prerequisites

  • If you want to accelerate queries on unoptimized data or data in slow storage, create a view that is itself created from a table in a non-columnar format or on slow-scan storage. You can then create your raw reflection from that view.
  • If you want to accelerate "needle-in-a-haystack" queries, create a view that includes a predicate to include only the rows that you want to scan. You can then create your raw reflection from that view.
  • If you want to accelerate queries that perform expensive transformations, create a view that performs those transformations. You can then create your raw reflection from that view.
  • If you want to accelerate queries that perform joins, create a view that performs the joins. You can then create your raw reflection from that view.

Creating Default Raw Reflections

In the Basic view of the reflections editor, you can create a raw reflection that includes all of the fields that are in a table or view. Creating a basic raw reflection ensures that Dremio never runs user queries against the underlying table or view when the raw reflection is enabled.

Restrictions of the Basic View

  • You cannot select fields to sort or create horizontal partitions on.
  • The name of the reflection that you create is restricted to "Raw Reflection".
  • You can create only one raw reflection. If you want to create multiple raw reflections at a time, use the Advanced view.

To create a raw reflection in the Basic view of the reflections editor:

  1. Open the reflections editor.

See Locations of the Reflections Editor to find out where you can open the editor from.

  1. Click the toggle switch on the left side of the Raw Reflections bar.
  1. Click Save.
tip

You can also create raw reflections using SQL commands.

For tips on what to do now after your raw reflection is created and enabled, see What to Do Next.

Creating Customized Raw Reflections

In the Advanced view of the reflections editor, you can create one or more raw reflections that include all or a selection of the fields that are in the anchor or supported anchor. You can also choose sort fields and fields for partitioning horizontally.

Dremio recommends that you follow the best practices listed in Best Practices for Creating Raw and Aggregation Reflections when you create customized raw reflections.

If you make any of the following changes to a raw reflection when you are using the Advanced view, you cannot switch to the Basic view:

  • Deselect one or more fields in the Display column. By default, all of the fields are selected.
  • Select one or more fields in the Sort, Partition, or Distribute column.

To create a raw reflection in the Advanced view of the reflections editor:

  1. Open the reflections editor.

See Locations of the Reflections Editor to find out where you can open the editor from.

  1. If the Advanced view is not already displayed, click the Advanced View button in the top-right corner of the editor.
  2. Click the toggle switch in the table labeled Raw Reflection to enable the raw reflection.

Queries do not start using the reflection, however, until after you finished editing the reflection and click Save in a later step.

  1. (Optional) Click in the label to rename the reflection.

The purpose of the name is to help you understand, when you read job reports, which reflections the query optimizer considered and chose when planning queries.

  1. In the columns of the table, follow these steps, which you don't have to do in any particular order:
note

Ignore the Distribution column. Selecting fields in it has no effect on the reflection.

  • Click in the Display column to include fields in or exclude them from your reflection.

  • Click in the Sort column to select fields on which to sort the data in the reflection. For guidance in selecting a field on which to sort, see the section Sort Reflections on High-Cardinality Fields in Best Practices for Creating Raw and Aggregation Reflections.

  • Click in the Partition column to select fields on which to horizontally partition the rows in the reflection. For guidance in selecting fields on which to partition, and which partition transforms to apply to those fields, see the section Horizontally Partition Reflections that Have Many Rows.

    note

    If the reflection is based on an Iceberg table, a filesystem source, an AWS Glue source, or a Hive source, and that table is partitioned, recommended partition columns and transforms are selected for you. If you change the selection of columns, then this icon appears at the top of the table: This is the Recommendations icon.. You can click it to revert back to the recommended selection of partition columns.

  1. (Optional) Optimize the number of files used to store the reflection. You can optimize for fast refreshes or for fast read performance by queries. Follow these steps:

    a. Click the gear icon in the table in which you are defining the reflection.

    b. In the field Reflection execution strategy, select either of these options:

    • Select Minimize Time Needed To Refresh if you need the reflection to be created as fast as possible. This option can result in the data for the reflection being stored in many small files. This is the default option.
    • Select Minimize Number Of Files when you want to improve read performance of queries against the reflection. With this option, there tend to be fewer seeks performed for a given query.
  2. Click Save when you are finished.

What to Do Next

After you create a raw reflection that is enabled, test whether the query optimizer is making queries use it. See Testing Reflections for the steps.

When you are sure that the reflection is being used, follow one of these steps:

  • If the base table is in the Apache Iceberg format or the Delta Lake format: Set the schedule according to which all reflections on the table are refreshed.
  • For all other base tables: Set the refresh type for all reflections on the underlying table and set the schedule according to which they are refreshed.

See Refreshing Reflections.

Creating Aggregation Reflections

Aggregation reflections are summarized representations of data. Most BI tools generate aggregation and GROUP BY queries. Aggregation reflections optimize these kinds of query patterns.

When you create aggregation reflections, keep in mind these best practices:

  • Use dimensions that have relatively low cardinality in a table or view. The higher the cardinality of a dimension, the less benefit an aggregation reflection has on query performance. Lower cardinality aggregation reflections require less time to scan.

  • For a single table or view, create one aggregation reflection for each important subset of dimensions in your queries, rather than one aggregation reflection that includes all dimensions. Multiple small aggregation reflections (versus one large one) are good for isolated pockets of query patterns on the same table or view that do not overlap. If your query patterns overlap, use fewer larger aggregation reflections.

    There are two cautions that accompany this advice, however:

    • Be careful of creating aggregation reflections that have too few dimensions for your queries.

      If a query uses more dimensions than are included in an aggregation reflection, the reflection cannot satisfy the query and the query optimizer does not run the query against it.

    • Be careful of creating more aggregation reflections than are necessary to satisfy queries against a table or view.

      The more reflections you create, the more time the query optimizer requires to plan the execution of queries. Therefore, creating more aggregation reflections than you need can slow down query performance, even if your aggregation reflections are low-cardinality.

  • If you want to include a computed measure, first create a view with the computed column to use as a measure, and then create the aggregation reflection on the view.

Dremio recommends that you also follow the best practices listed in Best Practices for Creating Raw and Aggregation Reflections when you create customized aggregation reflections.

Creating Default Aggregation Reflections

You can use the Basic view of the reflections editor to create one aggregation reflection that includes fields, from the anchor or supported anchor, that are recommended for use as dimensions or measures. You can add or remove dimensions and measures, too.

Restrictions

  • You can create only one aggregation reflection in the Basic view. If you want to create multiple aggregations reflections at a time, use the Advanced view.
  • You cannot select fields for sorting or horizontally partitioning.
  • The name of the reflection is restricted to "Aggregation Reflection".

Procedure

To create an aggregation reflection in the Basic view of the reflections editor:

  1. Open the reflections editor.

See Locations of the Reflections Editor to find out where you can open the editor from.

In the Aggregations Reflections section of the editor, click Generate to get recommended fields to use as dimensions and measures. This will override any previously selected dimensions and measures. If you wish to proceed, click Continue in the confirmation dialog that follows.

  1. In the Aggregation Reflection section of the editor, modify or accept the recommended fields for dimensions and measures.

  2. To make the reflection available to the query optimizer after you create it, click the toggle switch on the left side of the Aggregation Reflections bar.

  1. Click Save.
tip

You can also create aggregation reflections using SQL commands.

For tips on what to do now after your aggregation reflection is created and enabled, see What to Do Next.

Creating Customized Aggregation Reflections

You can use the Advanced view of the reflections editor to create one or more aggregation reflections that select which fields in the anchor or supporting anchor to use as dimensions and measures. For each field that you use as a measure, you can use one or more of these SQL functions: APPROX_DISTINCT_COUNT, COUNT, MAX, and MIN. You can also choose sort fields and fields for partitioning horizontally.

Procedure

To create an aggregation reflection in the Advanced view of the reflections editor:

  1. Open the reflections editor.

See Locations of the Reflections Editor to find out where you can open the editor from.

  1. Click the Advanced View button in the top-right corner of the editor.

  2. Click Aggregation Reflections.

The Aggregation Reflections section is displayed, and one table for refining the aggregation reflection that appeared in the Basic view is ready.

  1. (Optional) Click in the name to rename the reflection.

The purpose of the name is to help you understand, when you read job reports, which reflections the query optimizer considered and chose when planning queries.

  1. In the columns of the table, follow these steps, which you don't have to do in any particular order:
note

Ignore the Distribution column. Selecting fields in it has no effect on the reflection.

  • Click in the Dimensions column to include or exclude fields to use as dimensions.

  • Click in the Measures field to include or exclude fields to use as measures. You can use one or more of these SQL functions for each measure: APPROX_DISTINCT_COUNT, COUNT, MAX, and MIN.

The full list of SQL aggregation functions that Dremio supports is not supported in the reflections editor. If you want to create a reflection that aggregates data by using the sQL function AVG, CORR, HLL, SUM, VAR_POP, or VAR_SAMP, you must create a view that uses the function, and then create a raw reflection from that view.

  • Click in the Sort column to select fields on which to sort the data in the reflection. For guidance in selecting a field on which to sort, see the section Sort Reflections on High-Cardinality Fields in Best Practices for Creating Raw and Aggregation Reflections.

  • Click in the Partition column to select fields on which to horizontally partition the rows in the reflection. For guidance in selecting fields on which to partition, and which partition transforms to apply to those fields, see the section Horizontally Partition Reflections that Have Many Rows.

    note

    If the reflection is based on an Iceberg table, a filesystem source, an AWS Glue source, or a Hive source, and that table is partitioned, recommended partition columns and transforms are selected for you. If you change the selection of columns, then this icon appears at the top of the table: This is the Recommendations icon.. You can click it to revert back to the recommended selection of partition columns.

  1. (Optional) Optimize the number of files used to store the reflection. You can optimize for fast refreshes or for fast read performance by queries. Follow these steps:

    a. Click the gear icon in the table in which you are defining the reflection.

    b. In the field Reflection execution strategy, select either of these options:

    • Select Minimize Time Needed To Refresh if you need the reflection to be created as fast as possible. This option can result in the data for the reflection being stored in many small files. This is the default option.
    • Select Minimize Number Of Files when you want to improve read performance of queries against the reflection. With this option, there tend to be fewer seeks performed for a given query.
  2. Click Save when you are finished.

What to Do Next

After you create an aggregation reflection that is enabled, test whether the query optimizer is making queries use it. See Testing Reflections for the steps.

When you are sure that the reflection is being used, follow one of these steps:

  • If the base table is in the Apache Iceberg format or the Delta Lake format: Set the schedule according to which all reflections on the table are refreshed.
  • For all other base tables: Set the refresh type for all reflections on the underlying table and set the schedule according to which they are refreshed.

See Refreshing Reflections.

Editing Raw Reflections

You can edit an existing raw reflection. You might want to do so if you are iteratively designing and testing a raw reflection, if the definition of the view that the reflection was created from was changed, or if the schema of the underlying table was changed.

If you created a raw reflection in the Basic view of the reflections editor, you must use the Advanced view to edit it.

Dremio runs the job or jobs to recreate the reflection after you click Save.

Procedure

  1. Open the reflections editor.

See Locations of the Reflections Editor to find out where you can open the editor from.

  1. Click the Advanced View button in the top-right corner of the editor.

  2. In the Raw Reflections section of the Advanced view, locate the table that shows the definition of your reflection.

  3. (Optional) Click in the label to rename the reflection.

The purpose of the name is to help you understand, when you read job reports, which reflections the query optimizer considered and chose when planning queries.

  1. In the columns of the table, follow these steps, which you don't have to do in any particular order:
note

Ignore the Distribution column. Selecting fields in it has no effect on the reflection.

  • Click in the Display column to include fields in or exclude them from your reflection.

  • Click in the Sort column to select fields on which to sort the data in the reflection. For guidance in selecting a field on which to sort, see the section Sort Reflections on High-Cardinality Fields in Best Practices for Creating Raw and Aggregation Reflections.

  • Click in the Partition column to select fields on which to horizontally partition the rows in the reflection. For guidance in selecting fields on which to partition, and which partition transforms to apply to those fields, see the section Horizontally Partition Reflections that Have Many Rows.

    note

    If the reflection is based on an Iceberg table, a filesystem source, an AWS Glue source, or a Hive source, and that table is partitioned, partition columns and transforms are recommended for you. Hover over the This is the Recommendations icon. icon at the top of the table to see the recommendation. Click the icon to accept the recommendation.

  1. (Optional) Optimize the number of files used to store the reflection. You can optimize for fast refreshes or for fast read performance by queries. Follow these steps:

    a. Click the gear icon in the table in which you are defining the reflection.

    b. In the field Reflection execution strategy, select either of these options:

    • Select Minimize Time Needed To Refresh if you need the reflection to be created as fast as possible. This option can result in the data for the reflection being stored in many small files. This is the default option.
    • Select Minimize Number Of Files when you want to improve read performance of queries against the reflection. With this option, there tend to be fewer seeks performed for a given query.
  2. Click Save when you are finished.

Editing Aggregation Reflections

You might want to edit an aggregation reflection if you are iteratively designing and testing an aggregation reflection, if the definition of the view that the reflection was created from was changed, if the schema of the underlying table was changed, or if you want to revise one or more aggregations defined in the reflection.

If you created an aggregation reflection in the Basic view of the reflections editor, you can edit that reflection either in the Basic view or in the Advanced view.

Dremio runs the job or jobs to recreate the reflection after you click Save.

Editing Aggregation Reflections in the Basic View of the Reflections Editor

  1. Open the reflections editor.

See Locations of the Reflections Editor to find out where you can open the editor from.

  1. In the Aggregation Reflection section of the editor, modify or accept the recommendation for dimension fields and measure fields.

  2. Click Save.

Editing Aggregation Reflections in the Advanced View of the Reflections Editor

  1. Open the reflections editor.

See Locations of the Reflections Editor to find out where you can open the editor from.

  1. Click the Advanced View button in the top-right corner of the editor.

  2. Click Aggregation Reflections.

  3. (Optional) Click in the name to rename the reflection.

The purpose of the name is to help you understand, when you read job reports, which reflections the query optimizer considered and chose when planning queries.

  1. In the columns of the table, follow these steps, which you don't have to do in any particular order:
note

Ignore the Distribution column. Selecting fields in it has no effect on the reflection.

  • Click in the Dimensions column to include or exclude fields to use as dimensions.

  • Click in the Measures field to include or exclude fields to use as measures. You can use one or more of these SQL functions for each measure: APPROX_DISTINCT_COUNT, COUNT, MAX, and MIN.

The full list of SQL aggregation functions that Dremio supports is not supported in the reflections editor. If you want to create a reflection that aggregates data by using the sQL function AVG, CORR, HLL, SUM, VAR_POP, or VAR_SAMP, you must create a view that uses the function, and then create a raw reflection from that view.

  • Click in the Sort column to select fields on which to sort the data in the reflection. For guidance in selecting a field on which to sort, see the section Sort Reflections on High-Cardinality Fields in Best Practices for Creating Raw and Aggregation Reflections.

  • Click in the Partition column to select fields on which to horizontally partition the rows in the reflection. For guidance in selecting fields on which to partition, and which partition transforms to apply to those fields, see the section Horizontally Partition Reflections that Have Many Rows.

    note

    If the reflection is based on an Iceberg table, a filesystem source, an AWS Glue source, or a Hive source, and that table is partitioned, partition columns and transforms are recommended for you. Hover over the This is the Recommendations icon. icon at the top of the table to see the recommendation. Click the icon to accept the recommendation.

  1. (Optional) Optimize the number of files used to store the reflection. You can optimize for fast refreshes or for fast read performance by queries. Follow these steps:

    a. Click the gear icon in the table in which you are defining the reflection.

    b. In the field Reflection execution strategy, select either of these options:

    • Select Minimize Time Needed To Refresh if you need the reflection to be created as fast as possible. This option can result in the data for the reflection being stored in many small files. This is the default option.
    • Select Minimize Number Of Files when you want to improve read performance of queries against the reflection. With this option, there tend to be fewer seeks performed for a given query.
  2. Click Save when you are finished.

Creating External Reflections

See External Reflections for a description of what external reflections are and their benefits.

To create an external reflection:

  1. Follow these steps in the data source:

    a. Select your source table.

    b. Create a table that is derived from the source table, such as an aggregation table, if you do not already have one.

  2. Follow these steps in Dremio:

    a. Define a view on the derived table in the data source. The definition must match that of the derived table.

b. Define a new external reflection that maps the view to the derived table.

note

The data types and column names in the external reflection must match those in the view that the external reflection is mapped to.

Example

Suppose you have a data source named mySource that is connected to Dremio. In that data source, there are (among all of your other tables) these two tables:

  • sales, which is a very large table of sales data.
  • sales_by_region, which aggregates by region the data that is in sales. You want to make the data in sales_by_region available to data analysts who use Dremio. However, because you already have the sales_by_region table created, you do not see the need to create a Dremio table from sales, then create a Dremio view that duplicates sales_by_region, and finally create a reflection on the view. You would like instead to make sales_by_region available to queries run from Bi tools through Dremio.

To do that, you follow these steps:

  1. Create a view in Dremio that has the same definition as sales_by_region. Notice that the FROM clause points to the sales table that is in your data source, not to a Dremio table.
Example View
CREATE VIEW "myWorkspace"."sales_by_region" AS
SELECT
AVG(sales_amount) average_sales,
SUM(sales_amount) total_sales,
COUNT(*) sales_count,
region
FROM mySource.sales
GROUP BY region
  1. Create an external reflection that maps the view above to sales_by_region in mySource.
Example External Reflection
ALTER DATASET "myWorkspace"."sales_by_region"
CREATE EXTERNAL REFLECTION "external_sales_by_region"
USING "mySource"."sales_by_region"

The external reflection lets Dremio's query planner know that there is a table in mySource that matches the Dremio view myWorkplace.sales_by_region and that can be used to satisfy queries against the view. When Dremio users query myWorkspace.sales_by_region, Dremio routes the query to the data source mySource, which runs the query against mySource.sales_by_region.

Editing External Reflections

If you have modified the DDL of a derived table in your data source, follow these steps in Dremio to update the corresponding external reflection:

  1. Replace the view with one that has a definition that matches the definition of the derived table. When you do so, the external reflection is dropped.

  2. Define a new external reflection that maps the view to the derived table.

Viewing Whether Queries Used Reflections

You can view the list of jobs on the Jobs page to find out whether queries were accelerated by reflections. The Jobs page lists the jobs that ran queries, both queries from your data consumers and queries run within the Dremio user interface.

To find whether a query used a reflection:

  1. Find the job that ran the query by looking below the details in each row.
  2. Look for the indicator that one or more reflections were used. A lightning-bolt icon appears next to the job to indicate that a query was accelerated.
  3. View the job summary by clicking the row that represents the job that ran the query. The job summary appears in the pane to the right of the list of jobs.

Relationship between Reflections and Jobs

The relationship between a job and a reflection can be one of the following types:

  • CONSIDERED: the reflection is defined on a dataset that is used in the query but was determined to not cover the query (for example the reflection did not have a field that is used by the query).

  • MATCHED: a reflection could have been used to accelerate the query but Dremio determined that it would not provide any benefits or another reflection was determined to be a better choice.

  • CHOSEN: a reflection is used to accelerate the query. Note that multiple reflections can be used to accelerate queries.

Testing Reflections

You can test whether reflections that you created are used to satisfy a query without actually running the query. This practice can be helpful when the tables are very large and you want to avoid processing large queries unnecessarily.

To test whether one or more reflections are used by a query:

  1. In the side navigation bar, click the SQL Runner icon.
  2. In the SQL editor, type EXPLAIN PLAN FOR and then type or paste in your query.
  3. Click the Run button.
  4. When the query has finished, click the Run link found directly above the query results to view the job details. Any reflections used will be shown on the page.

Setting the Expiration Policy for Reflections

Rather than delete a reflection manually, you can specify how long you want Dremio to retain the reflection before deleting it automatically.

note

Dremio does not allow expiration policies to be set on external reflections or reflections that automatically refresh when Iceberg data changes according to the refresh policy.

To set the expiration policy for all reflections derived from tables in a data source:

  1. Right-click a data lake or external source.
  2. Select Edit Details.
  3. In the sidebar of the Edit Source window, click Reflection Refresh.
  4. After making your changes, click Save. The changes take effect on the next refresh.

To set the expiration policy on reflections derived from a particular table:

note

The table must be based on more than one file.

  1. Locate a table.
  2. Click the gear icon to its right.
  3. In the sidebar of the Dataset Settings window, click Reflection Refresh.
  4. After making your changes, click Save. The changes take effect on the next refresh.

Removing Reflections

You can choose to disable or delete reflections.

Disabling Reflections

Disabled reflections become unavailable for use by queries and will not be refreshed manually or according to their schedule.

note

Dremio does not disable external reflections.

To disable a reflection:

  1. Open the reflections editor for the reflection's anchor or supporting anchor. See Locations of the Reflections Editor.
  2. Follow one of these steps:
    • If there is only one raw reflection for the table or view, in the Basic view click the toggle switch in the Raw Reflections bar.
    • If there are two or more raw reflections for the table or view, in the Advanced view click the toggle switch for the individual raw reflection that you want to disable.
    • If there is only one aggregation reflection for the table or view, in the Basic view click the toggle switch in the Raw Reflections bar.
    • If there are two or more aggregation reflections for the table or view, in the Advanced view click the toggle switch for the individual aggregation reflection that you want to disable.
  3. Click Save. The changes take effect immediately.

Deleting Reflections

You can delete reflections individually, or all of the reflections on a table or view. When you delete a reflection, its definition, data, and metadata are entirely deleted.

To delete a single raw or aggregation reflection:

  1. Open the reflections editor for the reflection's anchor or supporting anchor. See Locations of the Reflections Editor.
  2. Open the Advanced view, if it is not already open.
  3. If the reflection is an aggregation reflection, click Aggregation Reflections.
  4. Click the trash can icon for the reflection that you want to delete.
  5. Click Save. The deletion takes effect immediately.

To delete all raw and aggregation reflections on a table or view:

  1. Open the reflections editor for the reflection's anchor or supporting anchor. See Locations of the Reflections Editor.
  2. Click Remove All Reflections.
  3. Click Save.

To delete an external reflection, or to delete a raw or aggregation reflection without using the reflections editor, run this SQL command:

Delete a reflection
ALTER DATASET <DATASET_PATH> DROP REFLECTION <REFLECTION_NAME>
  • DATASET_PATH: The path of the view on which the external reflection is based.
  • REFLECTION_NAME: The name of the external reflection.