Skip to content

Commit 379cf39

Browse files
authored
fix: treat unsupported SQL plans as "not implemented" (apache#5159)
Use the correct error type because API users may rely on that (e.g. to generate appropriate HTTP error codes).
1 parent 1ec2a83 commit 379cf39

2 files changed

Lines changed: 12 additions & 15 deletions

File tree

datafusion/core/src/physical_plan/planner.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,15 +1114,15 @@ impl DefaultPhysicalPlanner {
11141114
// TABLE" -- it must be handled at a higher level (so
11151115
// that the appropriate table can be registered with
11161116
// the context)
1117-
Err(DataFusionError::Internal(
1117+
Err(DataFusionError::NotImplemented(
11181118
"Unsupported logical plan: CreateExternalTable".to_string(),
11191119
))
11201120
}
11211121
LogicalPlan::Prepare(_) => {
11221122
// There is no default plan for "PREPARE" -- it must be
11231123
// handled at a higher level (so that the appropriate
11241124
// statement can be prepared)
1125-
Err(DataFusionError::Internal(
1125+
Err(DataFusionError::NotImplemented(
11261126
"Unsupported logical plan: Prepare".to_string(),
11271127
))
11281128
}
@@ -1131,7 +1131,7 @@ impl DefaultPhysicalPlanner {
11311131
// It must be handled at a higher level (so
11321132
// that the schema can be registered with
11331133
// the context)
1134-
Err(DataFusionError::Internal(
1134+
Err(DataFusionError::NotImplemented(
11351135
"Unsupported logical plan: CreateCatalogSchema".to_string(),
11361136
))
11371137
}
@@ -1140,7 +1140,7 @@ impl DefaultPhysicalPlanner {
11401140
// It must be handled at a higher level (so
11411141
// that the schema can be registered with
11421142
// the context)
1143-
Err(DataFusionError::Internal(
1143+
Err(DataFusionError::NotImplemented(
11441144
"Unsupported logical plan: CreateCatalog".to_string(),
11451145
))
11461146
}
@@ -1149,7 +1149,7 @@ impl DefaultPhysicalPlanner {
11491149
// It must be handled at a higher level (so
11501150
// that the schema can be registered with
11511151
// the context)
1152-
Err(DataFusionError::Internal(
1152+
Err(DataFusionError::NotImplemented(
11531153
"Unsupported logical plan: CreateMemoryTable".to_string(),
11541154
))
11551155
}
@@ -1158,7 +1158,7 @@ impl DefaultPhysicalPlanner {
11581158
// It must be handled at a higher level (so
11591159
// that the schema can be registered with
11601160
// the context)
1161-
Err(DataFusionError::Internal(
1161+
Err(DataFusionError::NotImplemented(
11621162
"Unsupported logical plan: DropTable".to_string(),
11631163
))
11641164
}
@@ -1167,7 +1167,7 @@ impl DefaultPhysicalPlanner {
11671167
// It must be handled at a higher level (so
11681168
// that the schema can be registered with
11691169
// the context)
1170-
Err(DataFusionError::Internal(
1170+
Err(DataFusionError::NotImplemented(
11711171
"Unsupported logical plan: DropView".to_string(),
11721172
))
11731173
}
@@ -1176,13 +1176,13 @@ impl DefaultPhysicalPlanner {
11761176
// It must be handled at a higher level (so
11771177
// that the schema can be registered with
11781178
// the context)
1179-
Err(DataFusionError::Internal(
1179+
Err(DataFusionError::NotImplemented(
11801180
"Unsupported logical plan: CreateView".to_string(),
11811181
))
11821182
}
11831183
LogicalPlan::Dml(_) => {
11841184
// DataFusion is a read-only query engine, but also a library, so consumers may implement this
1185-
Err(DataFusionError::Internal(
1185+
Err(DataFusionError::NotImplemented(
11861186
"Unsupported logical plan: Dml".to_string(),
11871187
))
11881188
}

datafusion/core/tests/sql/errors.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ async fn unsupported_sql_returns_error() -> Result<()> {
146146
assert!(physical_plan.is_err());
147147
assert_eq!(
148148
format!("{}", physical_plan.unwrap_err()),
149-
"Internal error: Unsupported logical plan: CreateView. \
150-
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker"
149+
"This feature is not implemented: Unsupported logical plan: CreateView"
151150
);
152151
// // drop view
153152
let sql = "drop view test_view";
@@ -156,8 +155,7 @@ async fn unsupported_sql_returns_error() -> Result<()> {
156155
assert!(physical_plan.is_err());
157156
assert_eq!(
158157
format!("{}", physical_plan.unwrap_err()),
159-
"Internal error: Unsupported logical plan: DropView. \
160-
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker"
158+
"This feature is not implemented: Unsupported logical plan: DropView"
161159
);
162160
// // drop table
163161
let sql = "drop table aggregate_test_100";
@@ -166,8 +164,7 @@ async fn unsupported_sql_returns_error() -> Result<()> {
166164
assert!(physical_plan.is_err());
167165
assert_eq!(
168166
format!("{}", physical_plan.unwrap_err()),
169-
"Internal error: Unsupported logical plan: DropTable. \
170-
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker"
167+
"This feature is not implemented: Unsupported logical plan: DropTable"
171168
);
172169
Ok(())
173170
}

0 commit comments

Comments
 (0)