You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to insert data with the INSERT INTO SQL syntax (see reproduction code below), I get the error: Inserting query must have the same schema with the table.
As logged above, the problem seems to be in the discrepancy between the table schema, which is qualified with the table name, and the query schema, which is not.
The code I'm using is about as simple as I can imagine. Am I missing something? Is there some example code that demonstrates how to use INSERT INTO SQL correctly? Or is this a bug?
To Reproduce
async fn df_test() {
let ctx = SessionContext::new();
let sql = "CREATE EXTERNAL TABLE test (k VARCHAR PRIMARY KEY NOT NULL, v VARCHAR NOT NULL) STORED AS CSV LOCATION './store/test/'";
let df = ctx.sql(sql).await.unwrap();
df.collect().await.unwrap();
let table_df = ctx.table("test").await.unwrap();
info!("TABLE SCHEMA: {:?}", table_df.schema());
let sql = "INSERT INTO test (k, v) VALUES ('foo', 'bar')";
let query_df = ctx.sql(sql).await.unwrap();
info!("DATAFRAME SCHEMA: {:?}", query_df.schema());
let _result = query_df.write_table("test", DataFrameWriteOptions::default()).await.unwrap();
}
Expected behavior
Insertion of the row ('foo', 'bar') is successful. DataFusion creates a CSV file in the filesystem corresponding to the inserted data.
Additional context
[dependencies]
datafusion = "37.1.0"
The text was updated successfully, but these errors were encountered:
Describe the bug
Hello,
When I try to insert data with the
INSERT INTO
SQL syntax (see reproduction code below), I get the error:Inserting query must have the same schema with the table.
As logged above, the problem seems to be in the discrepancy between the table schema, which is qualified with the table name, and the query schema, which is not.
The code I'm using is about as simple as I can imagine. Am I missing something? Is there some example code that demonstrates how to use
INSERT INTO
SQL correctly? Or is this a bug?To Reproduce
Expected behavior
Insertion of the row
('foo', 'bar')
is successful. DataFusion creates a CSV file in the filesystem corresponding to the inserted data.Additional context
The text was updated successfully, but these errors were encountered: