Re: [PR] Schema adapter helper [datafusion]

2025-06-04 Thread via GitHub


kosiew commented on PR #16108:
URL: https://github.com/apache/datafusion/pull/16108#issuecomment-2942385599

   You're welcome @alamb 
   Thank you for the review.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Schema adapter helper [datafusion]

2025-06-04 Thread via GitHub


alamb merged PR #16108:
URL: https://github.com/apache/datafusion/pull/16108


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Schema adapter helper [datafusion]

2025-06-04 Thread via GitHub


alamb commented on PR #16108:
URL: https://github.com/apache/datafusion/pull/16108#issuecomment-2941357353

   Thanks again @kosiew and @adriangb 


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Schema adapter helper [datafusion]

2025-05-22 Thread via GitHub


kosiew commented on PR #16108:
URL: https://github.com/apache/datafusion/pull/16108#issuecomment-2902969236

   @adriangb 
   Thanks for the review.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Schema adapter helper [datafusion]

2025-05-20 Thread via GitHub


kosiew commented on code in PR #16108:
URL: https://github.com/apache/datafusion/pull/16108#discussion_r2097676700


##
datafusion/datasource/src/schema_adapter.rs:
##
@@ -248,29 +267,11 @@ impl SchemaAdapter for DefaultSchemaAdapter {
 &self,
 file_schema: &Schema,
 ) -> datafusion_common::Result<(Arc, Vec)> {
-let mut projection = Vec::with_capacity(file_schema.fields().len());
-let mut field_mappings = vec![None; 
self.projected_table_schema.fields().len()];
-
-for (file_idx, file_field) in file_schema.fields.iter().enumerate() {
-if let Some((table_idx, table_field)) =
-self.projected_table_schema.fields().find(file_field.name())
-{
-match can_cast_types(file_field.data_type(), 
table_field.data_type()) {
-true => {
-field_mappings[table_idx] = Some(projection.len());
-projection.push(file_idx);
-}
-false => {
-return plan_err!(
-"Cannot cast file schema field {} of type {:?} to 
table schema field of type {:?}",
-file_field.name(),
-file_field.data_type(),
-table_field.data_type()
-)
-}
-}
-}
-}
+let (field_mappings, projection) = create_field_mapping(
+file_schema,
+&self.projected_table_schema,
+can_cast_field,
+)?;

Review Comment:
   refactor into a helper function so that we can re-use it later for 
deep-nested SchemaAdapter



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



Re: [PR] Schema adapter helper [datafusion]

2025-05-20 Thread via GitHub


kosiew commented on code in PR #16108:
URL: https://github.com/apache/datafusion/pull/16108#discussion_r2097676700


##
datafusion/datasource/src/schema_adapter.rs:
##
@@ -248,29 +267,11 @@ impl SchemaAdapter for DefaultSchemaAdapter {
 &self,
 file_schema: &Schema,
 ) -> datafusion_common::Result<(Arc, Vec)> {
-let mut projection = Vec::with_capacity(file_schema.fields().len());
-let mut field_mappings = vec![None; 
self.projected_table_schema.fields().len()];
-
-for (file_idx, file_field) in file_schema.fields.iter().enumerate() {
-if let Some((table_idx, table_field)) =
-self.projected_table_schema.fields().find(file_field.name())
-{
-match can_cast_types(file_field.data_type(), 
table_field.data_type()) {
-true => {
-field_mappings[table_idx] = Some(projection.len());
-projection.push(file_idx);
-}
-false => {
-return plan_err!(
-"Cannot cast file schema field {} of type {:?} to 
table schema field of type {:?}",
-file_field.name(),
-file_field.data_type(),
-table_field.data_type()
-)
-}
-}
-}
-}
+let (field_mappings, projection) = create_field_mapping(
+file_schema,
+&self.projected_table_schema,
+can_cast_field,
+)?;

Review Comment:
   refactor into a helper function so that we can re-use in later PRs for 
deep-nested SchemaAdapter



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


-
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]