Describe the bug
Most SQL databases (PG, MSSQL, ClickHouse, ...) allow to do INSERTS without resort to providing all the columns.
This is allowed by insert into TABLE(columns) VALUES (values) syntax when nullable columns could be omited.
It's important for upgrading schema of tables systems with zero downtime: on the first step we add new column and on the second we deploy new app code that deals with new schema.
Now it's impossible add column to schema without downtime due to logical planner error:
Error during planning: Inserting query must have the same schema with the table.
To Reproduce
create table foo(x int, y int);
insert into foo(x) values (10);
Expected:
(10, NULL) is inserted
Actual:
DataFusion CLI v32.0.0
❯ create table foo(x int, y int);
0 rows in set. Query took 0.002 seconds.
❯ insert into foo(x) values (10);
Error during planning: Inserting query must have the same schema with the table.
Expected behavior
row (10, NULL) is inserted
Additional context
Minimal repro without CLI:
use datafusion::prelude::*;
#[tokio::main]
async fn main() -> datafusion::error::Result<()> {
let ctx = SessionContext::new();
let queries = [
"create table foo(x int, y int);",
"insert into foo(x) values (10);",
"insert into foo(x, y) values (10, 11);",
];
for query in queries {
let df = ctx.sql(query).await?;
println!("> {query}");
if let Err(err) = df.show().await {
println!("{}", err);
}
}
Ok(())
}
> create table foo(x int, y int);
++
++
> insert into foo(x) values (10);
Error during planning: Inserting query must have the same schema with the table.
> insert into foo(x, y) values (10, 11);
+-------+
| count |
+-------+
| 1 |
+-------+
Describe the bug
Most SQL databases (PG, MSSQL, ClickHouse, ...) allow to do INSERTS without resort to providing all the columns.
This is allowed by
insert into TABLE(columns) VALUES (values)syntax when nullable columns could be omited.It's important for upgrading schema of tables systems with zero downtime: on the first step we add new column and on the second we deploy new app code that deals with new schema.
Now it's impossible add column to schema without downtime due to logical planner error:
Error during planning: Inserting query must have the same schema with the table.To Reproduce
Expected:
(10, NULL) is inserted
Actual:
Expected behavior
row (10, NULL) is inserted
Additional context
Minimal repro without CLI: