jayzhan211 commented on code in PR #12864: URL: https://github.com/apache/datafusion/pull/12864#discussion_r1810722867
########## datafusion/sql/src/values.rs: ########## @@ -41,6 +44,11 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { .collect::<Result<Vec<_>>>() }) .collect::<Result<Vec<_>>>()?; - LogicalPlanBuilder::values(values)?.build() + + if schema.fields().is_empty() { + LogicalPlanBuilder::values(values, None)?.build() + } else { + LogicalPlanBuilder::values(values, Some(&schema))?.build() Review Comment: > CREATE TABLE t AS SELECT a+1, 'foo' FROM (VALUES (3)) t(a) I think there is no schema in such query 🤔. > create table t(a int) as values (1); is the example that we have schema for values to infer the data type. I don't quite follow what #12104 is doing, but I think it makes sense to cast the values if the table schema exist and coerce values with `type_union_resolution` if there is no given schema. -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org