andygrove commented on code in PR #4050:
URL: https://github.com/apache/arrow-datafusion/pull/4050#discussion_r1011989255


##########
benchmarks/src/tpch.rs:
##########
@@ -456,16 +457,36 @@ pub async fn transform_actual_result(
 ) -> Result<Vec<RecordBatch>> {
     // to compare the recorded answers to the answers we got back from running 
the query,
     // we need to round the decimal columns and trim the Utf8 columns
+    // we also need to rewrite the batches to use a compatible schema
     let ctx = SessionContext::new();
-    let result_schema = result[0].schema();
+    let fields = result[0]
+        .schema()
+        .fields()
+        .iter()
+        .map(|f| {
+            let simple_name = match f.name().find('.') {
+                Some(i) => f.name()[i + 1..].to_string(),
+                _ => f.name().to_string(),
+            };
+            f.clone().with_name(simple_name)
+        })
+        .collect();
+    let result_schema = SchemaRef::new(Schema::new(fields));
+    let result = result
+        .iter()
+        .map(|b| {
+            RecordBatch::try_new(result_schema.clone(), b.columns().to_vec())
+                .map_err(|e| e.into())
+        })
+        .collect::<Result<Vec<_>>>()?;

Review Comment:
   we can't use the physical schema from query execution because it has 
`?table?` as the qualifier so this code just strips field names down to simple 
names



-- 
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]

Reply via email to