This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 4dc7908b37 Produce informative error message on insert plan type
mismatch (#12540)
4dc7908b37 is described below
commit 4dc7908b372dcafdb6a1f7bac89ea65c1b83f2f6
Author: Piotr Findeisen <[email protected]>
AuthorDate: Fri Sep 20 07:42:45 2024 -0700
Produce informative error message on insert plan type mismatch (#12540)
---
datafusion/core/src/datasource/listing/table.rs | 16 ++++++++++++++--
datafusion/core/src/datasource/memory.rs | 14 +++++++++++++-
2 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/datafusion/core/src/datasource/listing/table.rs
b/datafusion/core/src/datasource/listing/table.rs
index b91cc74d46..d2c2bd7a12 100644
--- a/datafusion/core/src/datasource/listing/table.rs
+++ b/datafusion/core/src/datasource/listing/table.rs
@@ -907,9 +907,21 @@ impl TableProvider for ListingTable {
.schema()
.logically_equivalent_names_and_types(&input.schema())
{
+ // Return an error if schema of the input query does not match
with the table schema.
return plan_err!(
- // Return an error if schema of the input query does not match
with the table schema.
- "Inserting query must have the same schema with the table."
+ "Inserting query must have the same schema with the table. \
+ Expected: {:?}, got: {:?}",
+ self.schema()
+ .fields()
+ .iter()
+ .map(|field| field.data_type())
+ .collect::<Vec<_>>(),
+ input
+ .schema()
+ .fields()
+ .iter()
+ .map(|field| field.data_type())
+ .collect::<Vec<_>>()
);
}
diff --git a/datafusion/core/src/datasource/memory.rs
b/datafusion/core/src/datasource/memory.rs
index cef7f210e1..70f3c36b81 100644
--- a/datafusion/core/src/datasource/memory.rs
+++ b/datafusion/core/src/datasource/memory.rs
@@ -274,7 +274,19 @@ impl TableProvider for MemTable {
.logically_equivalent_names_and_types(&input.schema())
{
return plan_err!(
- "Inserting query must have the same schema with the table."
+ "Inserting query must have the same schema with the table. \
+ Expected: {:?}, got: {:?}",
+ self.schema()
+ .fields()
+ .iter()
+ .map(|field| field.data_type())
+ .collect::<Vec<_>>(),
+ input
+ .schema()
+ .fields()
+ .iter()
+ .map(|field| field.data_type())
+ .collect::<Vec<_>>()
);
}
if overwrite {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]