MCPcopy Create free account
hub / github.com/apache/datafusion / exec_and_print

Function exec_and_print

datafusion-cli/src/exec.rs:216–240  ·  view source on GitHub ↗
(
    ctx: &dyn CliSessionContext,
    print_options: &PrintOptions,
    sql: String,
)

Source from the content-addressed store, hash-verified

214}
215
216pub(super) async fn exec_and_print(
217 ctx: &dyn CliSessionContext,
218 print_options: &PrintOptions,
219 sql: String,
220) -> Result<()> {
221 let task_ctx = ctx.task_ctx();
222 let options = task_ctx.session_config().options();
223 let dialect = &options.sql_parser.dialect;
224 let dialect = dialect_from_str(dialect).ok_or_else(|| {
225 plan_datafusion_err!(
226 "Unsupported SQL dialect: {dialect}. Available dialects: \
227 Generic, MySQL, PostgreSQL, Hive, SQLite, Snowflake, Redshift, \
228 MsSQL, ClickHouse, BigQuery, Ansi, DuckDB, Databricks."
229 )
230 })?;
231
232 let statements = DFParser::parse_sql_with_dialect(&sql, dialect.as_ref())?;
233 for statement in statements {
234 StatementExecutor::new(statement)
235 .execute(ctx, print_options)
236 .await?;
237 }
238
239 Ok(())
240}
241
242/// Executor for SQL statements, including special handling for S3 region detection retry logic
243struct StatementExecutor {

Callers 3

executeMethod · 0.85
exec_from_commandsFunction · 0.85
exec_from_linesFunction · 0.85

Calls 6

newFunction · 0.85
session_configMethod · 0.80
task_ctxMethod · 0.45
optionsMethod · 0.45
as_refMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…