Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,33 @@ jobs:
- name: Run examples docs check script
run: |
bash ci/scripts/check_examples_docs.sh

# This job ensures that sqllogictest (.slt) files do not leave
# DataFusion configuration options enabled (e.g. `set ... = true`)
# without resetting them back to their default state.
#
# It runs ci/scripts/check_slt_configs.sh and fails if any
# dangling configuration settings are detected.
sqllogictest-config-check:
name: check sqllogictest configs are properly reset
needs: linux-build-lib
runs-on: ubuntu-latest
container:
image: amd64/rust

steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: true
fetch-depth: 1

- name: Mark repository as safe for git
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"

- name: Run SLT config validation
run: |
bash ci/scripts/check_slt_configs.sh

# Verify MSRV for the crates which are directly used by other projects:
# - datafusion
# - datafusion-substrait
Expand Down
125 changes: 125 additions & 0 deletions ci/scripts/check_slt_configs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#!/usr/bin/env bash
#
# 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.

# Checks sqllogictest (.slt) files for dangling DataFusion configuration
# settings.
#
# Any configuration set with:
# set datafusion.<config> = true
# must be reset in the same file with:
# set datafusion.<config> = false
#
# This prevents configuration state from leaking into subsequent tests,
# which can cause nondeterministic or hard-to-debug failures.
#
# Usage:
# Check all .slt files under datafusion/sqllogictest/test_files:
# ./check_slt_configs.sh
#
# Check a specific file (repo-relative or absolute path):
# ./check_slt_configs.sh datafusion/sqllogictest/test_files/foo.slt
# ./check_slt_configs.sh /absolute/path/to/foo.slt
#
# Exit codes:
# 0 All checks passed
# 1 One or more files contain configs set to true but never reset

set -euo pipefail

# Resolve repository root
ROOT_DIR="$(git rev-parse --show-toplevel)"
TARGET_DIR="${ROOT_DIR}/datafusion/sqllogictest/test_files"

FAILED=0

resolve_file() {
local input="$1"

# If absolute and exists
if [[ -f "$input" ]]; then
realpath "$input"
return
fi

# If relative to repo root
if [[ -f "${ROOT_DIR}/${input}" ]]; then
realpath "${ROOT_DIR}/${input}"
return
fi

echo ""
}

# If file argument is passed, check only that file
if [[ $# -eq 1 ]]; then
RESOLVED_FILE="$(resolve_file "$1")"

if [[ -z "$RESOLVED_FILE" ]]; then
echo "❌ File does not exist: $1"
exit 1
fi

FILES="$RESOLVED_FILE"
else
FILES=$(find "$TARGET_DIR" -type f -name "*.slt")
fi

# Iterate safely even if filenames contain spaces
while IFS= read -r file; do
echo "Checking file: $file"

if [[ ! -f "$file" ]]; then
echo " ❌ File not found: $file"
FAILED=1
continue
fi

matches=$(grep -En \
'set[[:space:]]+datafusion\.[a-zA-Z0-9_.]+[[:space:]]*=[[:space:]]*true' \
"$file" || true)

[[ -z "$matches" ]] && continue

# Process each match line-by-line
while IFS= read -r match; do
line_number=$(echo "$match" | cut -d: -f1)
line_content=$(echo "$match" | cut -d: -f2-)

# Extract config name
config=$(echo "$line_content" \
| sed -E 's/set[[:space:]]+(datafusion\.[a-zA-Z0-9_.]+).*/\1/')

# Check if reset exists anywhere in file
if ! grep -Eq \
"set[[:space:]]+$config[[:space:]]*=[[:space:]]*false" \
"$file"; then
echo " ❌ $config set to true at line $line_number but never reset to false"
FAILED=1
fi

done <<< "$matches"

done <<< "$FILES"

if [[ $FAILED -eq 1 ]]; then
echo "Config reset check failed."
exit 1
else
echo "All SLT config checks passed."
fi
3 changes: 3 additions & 0 deletions datafusion/sqllogictest/test_files/ddl.slt
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,9 @@ DESCRIBE t2;
c1 Utf8View NO
c2 Utf8View YES

statement ok
set datafusion.sql_parser.map_string_types_to_utf8view = false;

statement ok
DROP TABLE t1;

Expand Down
6 changes: 6 additions & 0 deletions datafusion/sqllogictest/test_files/distinct_on.slt
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ logical_plan
03)----Aggregate: groupBy=[[t.a]], aggr=[[first_value(t.b) ORDER BY [t.a DESC NULLS FIRST, t.c ASC NULLS LAST]]]
04)------TableScan: t projection=[a, b, c]

statement ok
set datafusion.explain.logical_plan_only = false;

statement ok
drop table t;

Expand All @@ -189,5 +192,8 @@ logical_plan
01)Aggregate: groupBy=[[t.a, t.b]], aggr=[[]]
02)--TableScan: t projection=[a, b]

statement ok
set datafusion.explain.logical_plan_only = false;

statement ok
drop table t;
3 changes: 3 additions & 0 deletions datafusion/sqllogictest/test_files/floor_preimage.slt
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,6 @@ logical_plan

statement ok
DROP TABLE test_data;

statement ok
set datafusion.explain.logical_plan_only = false;
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,6 @@ web nike 700

statement ok
DROP TABLE sales;

statement ok
set datafusion.optimizer.repartition_aggregations = false;
3 changes: 3 additions & 0 deletions datafusion/sqllogictest/test_files/ident_normalization.slt
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,6 @@ drop table test_pk_constraint;
# Restore default setting
statement ok
set datafusion.sql_parser.enable_ident_normalization = true;

statement ok
set datafusion.catalog.information_schema = false;
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@ drop table t1

statement ok
drop table table_with_many_types

statement ok
set datafusion.catalog.information_schema = false;
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,6 @@ drop table t1

statement ok
drop table t2

statement ok
set datafusion.catalog.information_schema = false;
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ drop table physical

statement ok
drop view query

statement ok
set datafusion.catalog.information_schema = false;
3 changes: 3 additions & 0 deletions datafusion/sqllogictest/test_files/join_limit_pushdown.slt
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,6 @@ DROP TABLE t2;

statement ok
DROP TABLE t3;

statement ok
set datafusion.optimizer.prefer_hash_join = false;
3 changes: 3 additions & 0 deletions datafusion/sqllogictest/test_files/limit_pruning.slt
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ drop table tracking_data;

statement ok
reset datafusion.explain.analyze_level;

statement ok
set datafusion.execution.parquet.pushdown_filters = false;
11 changes: 11 additions & 0 deletions datafusion/sqllogictest/test_files/order.slt
Original file line number Diff line number Diff line change
Expand Up @@ -1584,3 +1584,14 @@ EXPLAIN SELECT * from ordered ORDER BY a;
physical_plan
01)SortExec: expr=[a@0 ASC NULLS LAST], preserve_partitioning=[false]
02)--DataSourceExec: file_groups={1 group: [[WORKSPACE_ROOT/datafusion/sqllogictest/data/composite_order.csv]]}, projection=[a, b], output_ordering=[a@0 + b@1 ASC NULLS LAST], file_type=csv, has_header=true

# Cleanup

statement ok
set datafusion.catalog.information_schema = false;

statement ok
set datafusion.optimizer.repartition_sorts = false;

statement ok
set datafusion.explain.physical_plan_only = false;
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,11 @@ logical_plan
physical_plan
01)SortPreservingMergeExec: [constant_col@0 ASC NULLS LAST]
02)--DataSourceExec: file_groups={2 groups: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet_sorted_statistics/test_table/partition_col=A/0.parquet, WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet_sorted_statistics/test_table/partition_col=B/1.parquet], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet_sorted_statistics/test_table/partition_col=C/2.parquet]]}, projection=[constant_col], output_ordering=[constant_col@0 ASC NULLS LAST], file_type=parquet

# Cleanup

statement ok
set datafusion.execution.collect_statistics = false;

statement ok
set datafusion.execution.split_file_groups_by_statistics = false;
9 changes: 8 additions & 1 deletion datafusion/sqllogictest/test_files/parquet_statistics.slt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ physical_plan
02)--RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=2, statistics=[Rows=Absent, Bytes=Absent, [(Col[0]:)]]
03)----DataSourceExec: file_groups={2 groups: [[WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet_statistics/test_table/0.parquet], [WORKSPACE_ROOT/datafusion/sqllogictest/test_files/scratch/parquet_statistics/test_table/1.parquet]]}, projection=[column1], file_type=parquet, predicate=column1@0 = 1, pruning_predicate=column1_null_count@2 != row_count@3 AND column1_min@0 <= 1 AND 1 <= column1_max@1, required_guarantees=[column1 in (1)], statistics=[Rows=Absent, Bytes=Absent, [(Col[0]:)]]

# cleanup
# Cleanup

statement ok
DROP TABLE test_table;

statement ok
set datafusion.explain.physical_plan_only = false;

statement ok
set datafusion.explain.show_statistics = false;
3 changes: 3 additions & 0 deletions datafusion/sqllogictest/test_files/predicates.slt
Original file line number Diff line number Diff line change
Expand Up @@ -866,3 +866,6 @@ WHERE NULL NOT IN (SELECT * FROM empty); -- all rows should be returned

statement ok
drop table t;

statement ok
set datafusion.catalog.information_schema = false;
16 changes: 16 additions & 0 deletions datafusion/sqllogictest/test_files/push_down_filter.slt
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ select * from t1 right anti join t2 on t1.k = t2.k where t2.k > 3 or t2.v > 20;
51 NULL
NULL 41

# Cleanup

statement ok
set datafusion.explain.logical_plan_only = false;
Expand All @@ -743,3 +744,18 @@ drop table t1;

statement ok
drop table t2;

statement ok
set datafusion.execution.parquet.pushdown_filters = false;

statement ok
set datafusion.execution.collect_statistics = false;

statement ok
set datafusion.execution.parquet.pushdown_filters = false;

statement ok
set datafusion.optimizer.enable_dynamic_filter_pushdown = false;

statement ok
set datafusion.optimizer.enable_aggregate_dynamic_filter_pushdown = false;
3 changes: 3 additions & 0 deletions datafusion/sqllogictest/test_files/set_variable.slt
Original file line number Diff line number Diff line change
Expand Up @@ -447,3 +447,6 @@ datafusion.runtime.max_temp_directory_size
datafusion.runtime.memory_limit
datafusion.runtime.metadata_cache_limit
datafusion.runtime.temp_directory

statement ok
set datafusion.catalog.information_schema = false
3 changes: 3 additions & 0 deletions datafusion/sqllogictest/test_files/string/string_view.slt
Original file line number Diff line number Diff line change
Expand Up @@ -1184,3 +1184,6 @@ logical_plan

statement ok
drop table test

statement ok
set datafusion.explain.logical_plan_only = false;
3 changes: 3 additions & 0 deletions datafusion/sqllogictest/test_files/type_coercion.slt
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,6 @@ SELECT true FROM t0 WHERE (REGEXP_MATCH(t0.v1, t0.v1)) NOT ILIKE [];

statement ok
DROP TABLE t0;

statement ok
set datafusion.explain.logical_plan_only = false;
3 changes: 3 additions & 0 deletions datafusion/sqllogictest/test_files/window.slt
Original file line number Diff line number Diff line change
Expand Up @@ -6081,3 +6081,6 @@ WHERE acctbal > (
);
----
1

statement ok
set datafusion.optimizer.prefer_existing_sort = false;