alamb commented on code in PR #9907:
URL: https://github.com/apache/arrow-datafusion/pull/9907#discussion_r1547546059


##########
datafusion/core/benches/sql_planner.rs:
##########
@@ -48,116 +51,18 @@ fn physical_plan(ctx: &SessionContext, sql: &str) {
 }
 
 /// Create schema with the specified number of columns
-pub fn create_schema(column_prefix: &str, num_columns: usize) -> Schema {
+fn create_schema(column_prefix: &str, num_columns: usize) -> Schema {
     let fields: Fields = (0..num_columns)
         .map(|i| Field::new(format!("{column_prefix}{i}"), DataType::Int32, 
true))
         .collect();
     Schema::new(fields)
 }
 
-pub fn create_table_provider(column_prefix: &str, num_columns: usize) -> 
Arc<MemTable> {
+fn create_table_provider(column_prefix: &str, num_columns: usize) -> 
Arc<MemTable> {
     let schema = Arc::new(create_schema(column_prefix, num_columns));
     MemTable::try_new(schema, vec![]).map(Arc::new).unwrap()
 }
 
-pub fn create_tpch_schemas() -> [(String, Schema); 8] {

Review Comment:
   I just moved this code into test_utils.



##########
test-utils/src/tpcds.rs:
##########
@@ -0,0 +1,579 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::TableDef;

Review Comment:
   This code was moved from tpcds_planning



##########
datafusion/core/benches/sql_planner.rs:
##########
@@ -236,40 +144,83 @@ fn criterion_benchmark(c: &mut Criterion) {
         })
     });
 
+    // --- TPC-H ---
+
+    let tpch_ctx = register_defs(SessionContext::new(), tpch_schemas());
+
     let tpch_queries = [
         "q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q11", 
"q12", "q13",
         "q14", // "q15", q15 has multiple SQL statements which is not supported
         "q16", "q17", "q18", "q19", "q20", "q21", "q22",
     ];
 
     for q in tpch_queries {
-        let sql = 
std::fs::read_to_string(format!("../../benchmarks/queries/{}.sql", q))
-            .unwrap();
+        let sql =
+            
std::fs::read_to_string(format!("../../benchmarks/queries/{q}.sql")).unwrap();
         c.bench_function(&format!("physical_plan_tpch_{}", q), |b| {
-            b.iter(|| physical_plan(&ctx, &sql))
+            b.iter(|| physical_plan(&tpch_ctx, &sql))
         });
     }
 
     let all_tpch_sql_queries = tpch_queries
         .iter()
         .map(|q| {
-            std::fs::read_to_string(format!("../../benchmarks/queries/{}.sql", 
q))
-                .unwrap()
+            
std::fs::read_to_string(format!("../../benchmarks/queries/{q}.sql")).unwrap()
         })
         .collect::<Vec<_>>();
 
     c.bench_function("physical_plan_tpch_all", |b| {
         b.iter(|| {
             for sql in &all_tpch_sql_queries {
-                physical_plan(&ctx, sql)
+                physical_plan(&tpch_ctx, sql)
             }
         })
     });
 
     c.bench_function("logical_plan_tpch_all", |b| {
         b.iter(|| {
             for sql in &all_tpch_sql_queries {
-                logical_plan(&ctx, sql)
+                logical_plan(&tpch_ctx, sql)
+            }
+        })
+    });
+
+    // --- TPC-DS ---
+
+    let tpcds_ctx = register_defs(SessionContext::new(), tpcds_schemas());

Review Comment:
   Here is the new code



##########
datafusion/core/tests/tpcds_planning.rs:
##########
@@ -1066,577 +1066,3 @@ async fn regression_test(query_no: u8, create_physical: 
bool) -> Result<()> {
 
     Ok(())
 }
-

Review Comment:
   This code was just moved to test_utils



##########
datafusion/core/benches/sql_planner.rs:
##########
@@ -236,40 +144,83 @@ fn criterion_benchmark(c: &mut Criterion) {
         })
     });
 
+    // --- TPC-H ---
+
+    let tpch_ctx = register_defs(SessionContext::new(), tpch_schemas());

Review Comment:
   Rather than using the same context for all tests, I made separate contexts 
for TPCH and TPC-DS



##########
test-utils/src/tpch.rs:
##########
@@ -0,0 +1,118 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::TableDef;
+use arrow::datatypes::{DataType, Field, Schema};
+
+/// Schemas for the TPCH tables
+pub fn tpch_schemas() -> Vec<TableDef> {

Review Comment:
   Moved out of sql_planner



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