Skip to content

Commit 162e740

Browse files
committed
add config flag for recursive ctes
update docs from script update slt test for doc change
1 parent 8cf1abb commit 162e740

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

datafusion/common/src/config.rs

+5
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,11 @@ config_namespace! {
290290
/// Hive. Note that this setting does not affect reading partitioned
291291
/// tables (e.g. `/table/year=2021/month=01/data.parquet`).
292292
pub listing_table_ignore_subdirectory: bool, default = true
293+
294+
/// Should DataFusion support recursive CTEs
295+
/// Defaults to false since this feature is a work in progress and may not
296+
/// behave as expected
297+
pub enable_recursive_ctes: bool, default = false
293298
}
294299
}
295300

datafusion/sql/src/query.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,18 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
5454
// Process CTEs from top to bottom
5555
// do not allow self-references
5656
if with.recursive {
57-
return not_impl_err!("Recursive CTEs are not supported");
57+
if self
58+
.context_provider
59+
.options()
60+
.execution
61+
.enable_recursive_ctes
62+
{
63+
return plan_err!(
64+
"Recursive CTEs are enabled but are not yet supported"
65+
);
66+
} else {
67+
return not_impl_err!("Recursive CTEs are not supported");
68+
}
5869
}
5970

6071
for cte in with.cte_tables {

datafusion/sqllogictest/test_files/information_schema.slt

+2
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ datafusion.execution.aggregate.scalar_update_factor 10
150150
datafusion.execution.batch_size 8192
151151
datafusion.execution.coalesce_batches true
152152
datafusion.execution.collect_statistics false
153+
datafusion.execution.enable_recursive_ctes false
153154
datafusion.execution.listing_table_ignore_subdirectory true
154155
datafusion.execution.max_buffered_batches_per_output_file 2
155156
datafusion.execution.meta_fetch_concurrency 32
@@ -225,6 +226,7 @@ datafusion.execution.aggregate.scalar_update_factor 10 Specifies the threshold f
225226
datafusion.execution.batch_size 8192 Default batch size while creating new batches, it's especially useful for buffer-in-memory batches since creating tiny batches would result in too much metadata memory consumption
226227
datafusion.execution.coalesce_batches true When set to true, record batches will be examined between each operator and small batches will be coalesced into larger batches. This is helpful when there are highly selective filters or joins that could produce tiny output batches. The target batch size is determined by the configuration setting
227228
datafusion.execution.collect_statistics false Should DataFusion collect statistics after listing files
229+
datafusion.execution.enable_recursive_ctes false Should DataFusion support recursive CTEs Defaults to false since this feature is a work in progress and may not behave as expected
228230
datafusion.execution.listing_table_ignore_subdirectory true Should sub directories be ignored when scanning directories for data files. Defaults to true (ignores subdirectories), consistent with Hive. Note that this setting does not affect reading partitioned tables (e.g. `/table/year=2021/month=01/data.parquet`).
229231
datafusion.execution.max_buffered_batches_per_output_file 2 This is the maximum number of RecordBatches buffered for each output file being worked. Higher values can potentially give faster write performance at the cost of higher peak memory consumption
230232
datafusion.execution.meta_fetch_concurrency 32 Number of files to read in parallel when inferring schema and statistics

docs/source/user-guide/configs.md

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Environment variables are read during `SessionConfig` initialisation so they mus
8383
| datafusion.execution.soft_max_rows_per_output_file | 50000000 | Target number of rows in output files when writing multiple. This is a soft max, so it can be exceeded slightly. There also will be one file smaller than the limit if the total number of rows written is not roughly divisible by the soft max |
8484
| datafusion.execution.max_buffered_batches_per_output_file | 2 | This is the maximum number of RecordBatches buffered for each output file being worked. Higher values can potentially give faster write performance at the cost of higher peak memory consumption |
8585
| datafusion.execution.listing_table_ignore_subdirectory | true | Should sub directories be ignored when scanning directories for data files. Defaults to true (ignores subdirectories), consistent with Hive. Note that this setting does not affect reading partitioned tables (e.g. `/table/year=2021/month=01/data.parquet`). |
86+
| datafusion.execution.enable_recursive_ctes | false | Should DataFusion support recursive CTEs Defaults to false since this feature is a work in progress and may not behave as expected |
8687
| datafusion.optimizer.enable_distinct_aggregation_soft_limit | true | When set to true, the optimizer will push a limit operation into grouped aggregations which have no aggregate expressions, as a soft limit, emitting groups once the limit is reached, before all rows in the group are read. |
8788
| datafusion.optimizer.enable_round_robin_repartition | true | When set to true, the physical plan optimizer will try to add round robin repartitioning to increase parallelism to leverage more CPU cores |
8889
| datafusion.optimizer.enable_topk_aggregation | true | When set to true, the optimizer will attempt to perform limit operations during aggregations, if possible |

0 commit comments

Comments
 (0)