liukun4515 commented on a change in pull request #1491: URL: https://github.com/apache/arrow-datafusion/pull/1491#discussion_r775305335
########## File path: datafusion/tests/sql/mod.rs ########## @@ -0,0 +1,728 @@ +// 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 std::convert::TryFrom; +use std::sync::Arc; + +use arrow::{ + array::*, datatypes::*, record_batch::RecordBatch, + util::display::array_value_to_string, +}; +use chrono::prelude::*; +use chrono::Duration; + +use datafusion::assert_batches_eq; +use datafusion::assert_batches_sorted_eq; +use datafusion::assert_contains; +use datafusion::assert_not_contains; +use datafusion::logical_plan::plan::{Aggregate, Projection}; +use datafusion::logical_plan::LogicalPlan; +use datafusion::logical_plan::TableScan; +use datafusion::physical_plan::functions::Volatility; +use datafusion::physical_plan::metrics::MetricValue; +use datafusion::physical_plan::ExecutionPlan; +use datafusion::physical_plan::ExecutionPlanVisitor; +use datafusion::prelude::*; +use datafusion::test_util; +use datafusion::{datasource::MemTable, physical_plan::collect}; +use datafusion::{ + error::{DataFusionError, Result}, + physical_plan::ColumnarValue, +}; +use datafusion::{execution::context::ExecutionContext, physical_plan::displayable}; + +/// A macro to assert that some particular line contains two substrings +/// +/// Usage: `assert_metrics!(actual, operator_name, metrics)` +/// +macro_rules! assert_metrics { + ($ACTUAL: expr, $OPERATOR_NAME: expr, $METRICS: expr) => { + let found = $ACTUAL + .lines() + .any(|line| line.contains($OPERATOR_NAME) && line.contains($METRICS)); + assert!( + found, + "Can not find a line with both '{}' and '{}' in\n\n{}", + $OPERATOR_NAME, $METRICS, $ACTUAL + ); + }; +} + +macro_rules! test_expression { + ($SQL:expr, $EXPECTED:expr) => { + let mut ctx = ExecutionContext::new(); + let sql = format!("SELECT {}", $SQL); + let actual = execute(&mut ctx, sql.as_str()).await; + assert_eq!(actual[0][0], $EXPECTED); + }; +} + +pub(crate) use assert_metrics; +pub(crate) use test_expression; +pub mod aggregates; +#[cfg(feature = "avro")] +pub mod avro; Review comment: The issue like above. If the mod is used in this model, we don't need to public them. -- 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...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org