You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by ga...@apache.org on 2026/08/06 10:36:00 UTC
(datafusion) 02/07: Use parser for splitting statements
This is an automated email from the ASF dual-hosted git repository.
gabotechs pushed a commit to branch gabotechs/add-q-error-stats-benchmarks
in repository https://gitbox.apache.org/repos/asf/datafusion.git
commit a2123e70e7b8f76e24b996d6212c4f8793bdd41f
Author: Gabriel <ga...@datadoghq.com>
AuthorDate: Tue Aug 4 15:29:09 2026 +0200
Use parser for splitting statements
---
benchmarks/src/statistics.rs | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/benchmarks/src/statistics.rs b/benchmarks/src/statistics.rs
index eb9237b204..b7781dbd33 100644
--- a/benchmarks/src/statistics.rs
+++ b/benchmarks/src/statistics.rs
@@ -29,6 +29,7 @@ use datafusion::physical_plan::metrics::MetricValue;
use datafusion::physical_plan::operator_statistics::StatisticsRegistry;
use datafusion::physical_plan::{ExecutionPlan, collect};
use datafusion::prelude::{ParquetReadOptions, SessionConfig, SessionContext};
+use datafusion::sql::parser::DFParser;
use datafusion_common::stats::Precision;
use regex::Regex;
use serde::{Deserialize, Serialize};
@@ -84,11 +85,7 @@ impl RunOpt {
.to_string_lossy()
.to_string();
let sql = fs::read_to_string(query_path)?;
- for (statement, sql) in sql
- .split(';')
- .filter(|sql| !sql.trim().is_empty())
- .enumerate()
- {
+ for (statement, sql) in sql_statements(&sql)?.iter().enumerate() {
let statement = statement + 1;
let report = match self.report_query(&ctx, sql).await {
Ok(operators) => QueryReport {
@@ -570,6 +567,15 @@ fn serialize_report(report: &[QueryReport]) -> Result<String> {
.map_err(|error| DataFusionError::External(Box::new(error)))
}
+fn sql_statements(sql: &str) -> Result<Vec<String>> {
+ DFParser::parse_sql(sql).map(|statements| {
+ statements
+ .into_iter()
+ .map(|statement| statement.to_string())
+ .collect()
+ })
+}
+
fn query_files(path: &Path, query: Option<&str>) -> Result<Vec<PathBuf>> {
if path.is_file() {
return Ok(vec![path.to_path_buf()]);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org