agent_patch
runs/2026-02-21__03-36-16__gpt-5-1-codex-mini/flux-pr-1628/flux-pr-1628.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/agent-logs/agent.patch
7028 bytes
diff --git a/tmp/agent-patch-flux-pr-1628.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/src/ast/dml.rs b/app/src/ast/dml.rs
index d68a227..041475b 100644
--- a/tmp/agent-patch-flux-pr-1628.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/src/ast/dml.rs
+++ b/app/src/ast/dml.rs
@@ -35,8 +35,8 @@ use super::{
display_comma_separated, display_separated, Assignment, ClusteredBy, CommentDef, Expr,
FileFormat, FromTable, HiveDistributionStyle, HiveFormat, HiveIOFormat, HiveRowFormat, Ident,
InsertAliases, MysqlInsertPriority, ObjectName, OnCommit, OnInsert, OneOrManyWithParens,
- OrderByExpr, Query, RowAccessPolicy, SelectItem, SqlOption, SqliteOnConflict, TableEngine,
- TableObject, TableWithJoins, Tag, WrappedCollection,
+ OrderByExpr, FormatClause, Query, RowAccessPolicy, SelectItem, Setting, SqlOption,
+ SqliteOnConflict, TableEngine, TableObject, TableWithJoins, Tag, WrappedCollection,
};
/// CREATE INDEX statement.
@@ -491,6 +491,10 @@ pub struct Insert {
pub on: Option<OnInsert>,
/// RETURNING
pub returning: Option<Vec<SelectItem>>,
+ /// ClickHouse-specific SETTINGS.
+ pub settings: Option<Vec<Setting>>,
+ /// ClickHouse-specific FORMAT clause.
+ pub format_clause: Option<FormatClause>,
/// Only for mysql
pub replace_into: bool,
/// Only for mysql
@@ -571,6 +575,13 @@ impl Display for Insert {
if let Some(returning) = &self.returning {
write!(f, " RETURNING {}", display_comma_separated(returning))?;
}
+
+ if let Some(settings) = &self.settings {
+ write!(f, " SETTINGS {}", display_comma_separated(settings))?;
+ }
+ if let Some(format_clause) = &self.format_clause {
+ write!(f, " {format_clause}")?;
+ }
Ok(())
}
}
diff --git a/tmp/agent-patch-flux-pr-1628.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/src/ast/spans.rs b/app/src/ast/spans.rs
index 8a27c4a..1a2f39e 100644
--- a/tmp/agent-patch-flux-pr-1628.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/src/ast/spans.rs
+++ b/app/src/ast/spans.rs
@@ -26,7 +26,7 @@ use super::{
CopySource, CreateIndex, CreateTable, CreateTableOptions, Cte, Delete, DoUpdate,
ExceptSelectItem, ExcludeSelectItem, Expr, ExprWithAlias, Fetch, FromTable, Function,
FunctionArg, FunctionArgExpr, FunctionArgumentClause, FunctionArgumentList, FunctionArguments,
- GroupByExpr, HavingBound, IlikeSelectItem, Insert, Interpolate, InterpolateExpr, Join,
+ GroupByExpr, FormatClause, Ident, Setting, HavingBound, IlikeSelectItem, Insert, Interpolate, InterpolateExpr, Join,
JoinConstraint, JoinOperator, JsonPath, JsonPathElem, LateralView, MatchRecognizePattern,
Measure, NamedWindowDefinition, ObjectName, Offset, OnConflict, OnConflictAction, OnInsert,
OrderBy, OrderByExpr, Partition, PivotValueSource, ProjectionSelect, Query, ReferentialAction,
@@ -1152,6 +1152,8 @@ impl Spanned for Insert {
has_table_keyword: _, // bool
on,
returning,
+ settings,
+ format_clause,
replace_into: _, // bool
priority: _, // todo, mysql specific
insert_alias: _, // todo, mysql specific
@@ -1167,7 +1169,12 @@ impl Spanned for Insert {
.chain(partitioned.iter().flat_map(|i| i.iter().map(|k| k.span())))
.chain(after_columns.iter().map(|i| i.span))
.chain(on.as_ref().map(|i| i.span()))
- .chain(returning.iter().flat_map(|i| i.iter().map(|k| k.span()))),
+ .chain(returning.iter().flat_map(|i| i.iter().map(|k| k.span())))
+ .chain(settings.iter().flat_map(|vec| vec.iter().map(|setting| setting.key.span)))
+ .chain(format_clause.iter().flat_map(|format| match format {
+ FormatClause::Identifier(ident) => Some(ident.span),
+ FormatClause::Null => None,
+ })),
)
}
}
diff --git a/tmp/agent-patch-flux-pr-1628.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/src/parser/mod.rs b/app/src/parser/mod.rs
index b6e3fd1..b00240d 100644
--- a/tmp/agent-patch-flux-pr-1628.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/src/parser/mod.rs
+++ b/app/src/parser/mod.rs
@@ -12128,6 +12128,21 @@ impl<'a> Parser<'a> {
None
};
+ let settings = self.parse_settings()?;
+
+ let format_clause = if dialect_of!(self is ClickHouseDialect | GenericDialect)
+ && self.parse_keyword(Keyword::FORMAT)
+ {
+ if self.parse_keyword(Keyword::NULL) {
+ Some(FormatClause::Null)
+ } else {
+ let ident = self.parse_identifier()?;
+ Some(FormatClause::Identifier(ident))
+ }
+ } else {
+ None
+ };
+
Ok(Statement::Insert(Insert {
or,
table: table_object,
@@ -12143,6 +12158,8 @@ impl<'a> Parser<'a> {
has_table_keyword: table,
on,
returning,
+ settings,
+ format_clause,
replace_into,
priority,
insert_alias,
diff --git a/tmp/agent-patch-flux-pr-1628.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/tests/sqlparser_clickhouse.rs b/app/tests/sqlparser_clickhouse.rs
index 4fa657b..21da77d 100644
--- a/tmp/agent-patch-flux-pr-1628.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/tests/sqlparser_clickhouse.rs
+++ b/app/tests/sqlparser_clickhouse.rs
@@ -228,6 +228,38 @@ fn parse_insert_into_function() {
clickhouse().verified_stmt(r#"INSERT INTO FUNCTION remote('localhost', default.simple_table) VALUES (100, 'inserted via remote()')"#);
}
+#[test]
+fn parse_insert_with_settings_and_format() {
+ let sql = "INSERT INTO tbl SELECT 1 SETTINGS max_threads = 1, max_block_size = 100 FORMAT JSONEachRow";
+
+ match clickhouse().verified_stmt(sql) {
+ Statement::Insert(Insert {
+ settings,
+ format_clause,
+ ..
+ }) => {
+ pretty_assertions::assert_eq!(
+ Some(vec![
+ Setting {
+ key: Ident::new("max_threads"),
+ value: Value::Number("1".into()),
+ },
+ Setting {
+ key: Ident::new("max_block_size"),
+ value: Value::Number("100".into()),
+ },
+ ]),
+ settings
+ );
+ pretty_assertions::assert_eq!(
+ Some(FormatClause::Identifier(Ident::new("JSONEachRow"))),
+ format_clause
+ );
+ }
+ _ => unreachable!(),
+ }
+}
+
#[test]
fn parse_alter_table_attach_and_detach_partition() {
for operation in &["ATTACH", "DETACH"] {