Skip to content

Commit 214f4a1

Browse files
committed
When trying to create subsources for single-output generators, display error instead of panicing
1 parent 8b9823d commit 214f4a1

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/sql/src/pure.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,13 +1056,13 @@ async fn purify_create_source(
10561056
// Filter to the references that need to be created as 'subsources', which
10571057
// doesn't include the default output for single-output sources.
10581058
// TODO(database-issues#8620): Remove once subsources are removed
1059-
let subsource_references = retrieved_source_references
1059+
let multi_output_sources = retrieved_source_references
10601060
.all_references()
10611061
.iter()
10621062
.filter(|r| {
10631063
r.load_generator_output().expect("is loadgen") != &LoadGeneratorOutput::Default
10641064
})
1065-
.collect::<Vec<_>>();
1065+
.any();
10661066

10671067
match external_references {
10681068
Some(requested)
@@ -1071,6 +1071,19 @@ async fn purify_create_source(
10711071
Err(PlanError::UseTablesForSources(requested.to_string()))?
10721072
}
10731073
Some(requested) => {
1074+
if !multi_output_sources {
1075+
match requested {
1076+
ExternalReferences::SubsetTables(_) => {
1077+
Err(LoadGeneratorSourcePurificationError::ForTables)?
1078+
}
1079+
ExternalReferences::SubsetSchemas(_) => {
1080+
Err(LoadGeneratorSourcePurificationError::ForSchemas)?
1081+
}
1082+
ExternalReferences::All => {
1083+
Err(LoadGeneratorSourcePurificationError::ForAllTables)?
1084+
}
1085+
}
1086+
}
10741087
let requested_exports = retrieved_source_references
10751088
.requested_source_exports(Some(requested), source_name)?;
10761089
for export in requested_exports {
@@ -1095,8 +1108,8 @@ async fn purify_create_source(
10951108
}
10961109
}
10971110
None => {
1098-
if matches!(reference_policy, SourceReferencePolicy::Required)
1099-
&& !subsource_references.is_empty()
1111+
if multi_output_sources
1112+
&& matches!(reference_policy, SourceReferencePolicy::Required)
11001113
{
11011114
Err(LoadGeneratorSourcePurificationError::MultiOutputRequiresForAllTables)?
11021115
}

0 commit comments

Comments
 (0)