jayzhan211 commented on code in PR #12864: URL: https://github.com/apache/datafusion/pull/12864#discussion_r1812157465
########## datafusion/expr/src/logical_plan/builder.rs: ########## @@ -196,16 +224,58 @@ impl LogicalPlanBuilder { } } - let empty_schema = DFSchema::empty(); + // Check the type of value against the schema + if let Some(schema) = schema { + Self::infer_values_from_schema(values, schema) + } else { + // Infer from data itself + Self::infer_data(values) + } + } + + fn infer_values_from_schema( + values: Vec<Vec<Expr>>, + schema: &DFSchema, + ) -> Result<Self> { + let n_cols = values[0].len(); + let mut field_types: Vec<DataType> = Vec::with_capacity(n_cols); + for j in 0..n_cols { + let field_type = schema.field(j).data_type(); + for row in values.iter() { + let value = &row[j]; + let data_type = value.get_type(schema)?; + + if !data_type.equals_datatype(field_type) { Review Comment: I fix the regression -- 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