r4ntix commented on code in PR #7138:
URL: https://github.com/apache/arrow-datafusion/pull/7138#discussion_r1280076942
##########
datafusion-cli/src/exec.rs:
##########
@@ -192,17 +193,30 @@ async fn exec_and_print(
let now = Instant::now();
let sql = unescape_input(&sql)?;
- let plan = ctx.state().create_logical_plan(&sql).await?;
- let df = match &plan {
- LogicalPlan::Ddl(DdlStatement::CreateExternalTable(cmd)) => {
- create_external_table(ctx, cmd).await?;
- ctx.execute_logical_plan(plan).await?
- }
- _ => ctx.execute_logical_plan(plan).await?,
- };
+ let task_ctx = ctx.task_ctx();
+ let dialect = &task_ctx.session_config().options().sql_parser.dialect;
+ let dialect = dialect_from_str(dialect).ok_or_else(|| {
+ DataFusionError::Plan(format!(
+ "Unsupported SQL dialect: {dialect}. Available dialects: \
+ Generic, MySQL, PostgreSQL, Hive, SQLite, Snowflake,
Redshift, \
+ MsSQL, ClickHouse, BigQuery, Ansi."
+ ))
+ })?;
+ let statements = DFParser::parse_sql_with_dialect(&sql, dialect.as_ref())?;
+ for statement in statements {
+ let plan = ctx.state().statement_to_plan(statement).await?;
+ let df = match &plan {
+ LogicalPlan::Ddl(DdlStatement::CreateExternalTable(cmd)) => {
+ create_external_table(ctx, cmd).await?;
+ ctx.execute_logical_plan(plan).await?
+ }
+ _ => ctx.execute_logical_plan(plan).await?,
+ };
- let results = df.collect().await?;
- print_options.print_batches(&results, now)?;
+ let results = df.collect().await?;
+ print_options.print_batches(&results, now)?;
+ println!();
Review Comment:
The `println!();` here I would suggest to put in the code for `fn
print_timing_info()`. Because it will affect the output of `--quiet` mode.
suggestion:
```rust
fn print_timing_info(row_count: usize, now: Instant) {
println!(
"{} {} in set. Query took {:.3} seconds.\n",
row_count,
if row_count == 1 { "row" } else { "rows" },
now.elapsed().as_secs_f64()
);
}
```
--
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]