alamb commented on code in PR #4194:
URL: https://github.com/apache/arrow-datafusion/pull/4194#discussion_r1023050220
##########
datafusion/sql/src/planner.rs:
##########
@@ -180,12 +180,36 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
if_not_exists,
or_replace,
..
- } if columns.is_empty()
- && constraints.is_empty()
+ } if constraints.is_empty()
&& table_properties.is_empty()
&& with_options.is_empty() =>
{
- let plan = self.query_to_plan(*query, &mut HashMap::new())?;
+ let plan = self.query_to_plan(*query.clone(), &mut
HashMap::new())?;
+ let input_schema = plan.schema();
+
+ let plan = if !columns.is_empty() {
+ match *query.body {
+ SetExpr::Values(_) => {
+ let schema =
self.build_schema(columns)?.to_dfschema_ref()?;
+ if schema.fields().len() !=
input_schema.fields().len() {
+ return Err(DataFusionError::Plan("Mismatch
between schema and batches".to_string()))
Review Comment:
```suggestion
return
Err(DataFusionError::Plan(format!("Mismatch: {} columns specified, but result
has {} columns", schema.fields.len(), input_schema.fields().len()))
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]