| 214 | } |
| 215 | |
| 216 | pub(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 |
| 243 | struct StatementExecutor { |