STET

agent_patch

runs/2026-02-28__18-27-22__gpt-5-1-codex-mini/flux-pr-1526/flux-pr-1526.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/agent-logs/agent.patch

10498 bytes

Back to adjudication
diff --git a/tmp/agent-patch-flux-pr-1526.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/src/ast/mod.rs b/app/src/ast/mod.rs
index ad59f07..c0a41ba 100644
--- a/tmp/agent-patch-flux-pr-1526.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/src/ast/mod.rs
+++ b/app/src/ast/mod.rs
@@ -60,8 +60,8 @@ pub use self::query::{
     OrderBy, OrderByExpr, PivotValueSource, ProjectionSelect, Query, RenameSelectItem,
     RepetitionQuantifier, ReplaceSelectElement, ReplaceSelectItem, RowsPerMatch, Select,
     SelectInto, SelectItem, SetExpr, SetOperator, SetQuantifier, Setting, SymbolDefinition, Table,
-    TableAlias, TableFactor, TableFunctionArgs, TableVersion, TableWithJoins, Top, TopQuantity,
-    ValueTableMode, Values, WildcardAdditionalOptions, With, WithFill,
+    TableAlias, TableAliasColumn, TableFactor, TableFunctionArgs, TableVersion, TableWithJoins, Top,
+    TopQuantity, ValueTableMode, Values, WildcardAdditionalOptions, With, WithFill,
 };
 
 pub use self::trigger::{
diff --git a/tmp/agent-patch-flux-pr-1526.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/src/ast/query.rs b/app/src/ast/query.rs
index 2160da0..8e6e776 100644
--- a/tmp/agent-patch-flux-pr-1526.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/src/ast/query.rs
+++ b/app/src/ast/query.rs
@@ -544,9 +544,9 @@ impl fmt::Display for CteAsMaterialized {
     }
 }
 
-/// A single CTE (used after `WITH`): `<alias> [(col1, col2, ...)] AS <materialized> ( <query> )`
-/// The names in the column list before `AS`, when specified, replace the names
-/// of the columns returned by the query. The parser does not validate that the
+/// A single CTE (used after `WITH`): `<alias> [(col1 [type], col2 [type], ...)] AS <materialized> ( <query> )`
+/// The names (and optional type annotations) in the column list before `AS`, when specified,
+/// replace the names of the columns returned by the query. The parser does not validate that the
 /// number of columns in the query matches the number of columns in the query.
 #[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
 #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
@@ -1592,12 +1592,30 @@ impl fmt::Display for TableFactor {
     }
 }
 
+#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
+#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
+#[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
+pub struct TableAliasColumn {
+    pub name: Ident,
+    pub data_type: Option<DataType>,
+}
+
+impl fmt::Display for TableAliasColumn {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "{}", self.name)?;
+        if let Some(ref data_type) = self.data_type {
+            write!(f, " {data_type}")?;
+        }
+        Ok(())
+    }
+}
+
 #[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
 #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
 #[cfg_attr(feature = "visitor", derive(Visit, VisitMut))]
 pub struct TableAlias {
     pub name: Ident,
-    pub columns: Vec<Ident>,
+    pub columns: Vec<TableAliasColumn>,
 }
 
 impl fmt::Display for TableAlias {
diff --git a/tmp/agent-patch-flux-pr-1526.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/src/parser/mod.rs b/app/src/parser/mod.rs
index 0c82378..fcd912e 100644
--- a/tmp/agent-patch-flux-pr-1526.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/src/parser/mod.rs
+++ b/app/src/parser/mod.rs
@@ -8270,7 +8270,7 @@ impl<'a> Parser<'a> {
     ) -> Result<Option<TableAlias>, ParserError> {
         match self.parse_optional_alias(reserved_kwds)? {
             Some(name) => {
-                let columns = self.parse_parenthesized_column_list(Optional, false)?;
+                let columns = self.parse_parenthesized_table_alias_column_list(Optional)?;
                 Ok(Some(TableAlias { name, columns }))
             }
             None => Ok(None),
@@ -8607,6 +8607,37 @@ impl<'a> Parser<'a> {
         }
     }
 
+    /// Parse a parenthesized comma-separated list of table alias columns. Each column may optionally
+    /// include a data type annotation (e.g., `col1 int`).
+    pub fn parse_parenthesized_table_alias_column_list(
+        &mut self,
+        optional: IsOptional,
+    ) -> Result<Vec<TableAliasColumn>, ParserError> {
+        if self.consume_token(&Token::LParen) {
+            if self.peek_token().token == Token::RParen {
+                self.next_token();
+                Ok(vec![])
+            } else {
+                let cols = self.parse_comma_separated(|p| p.parse_table_alias_column())?;
+                self.expect_token(&Token::RParen)?;
+                Ok(cols)
+            }
+        } else if optional == Optional {
+            Ok(vec![])
+        } else {
+            self.expected("a list of columns in parentheses", self.peek_token())
+        }
+    }
+
+    fn parse_table_alias_column(&mut self) -> Result<TableAliasColumn, ParserError> {
+        let name = self.parse_identifier(false)?;
+        let data_type = match self.peek_token().token {
+            Token::Comma | Token::RParen => None,
+            _ => Some(self.parse_data_type()?),
+        };
+        Ok(TableAliasColumn { name, data_type })
+    }
+
     pub fn parse_precision(&mut self) -> Result<u64, ParserError> {
         self.expect_token(&Token::LParen)?;
         let n = self.parse_literal_uint()?;
@@ -9174,7 +9205,7 @@ impl<'a> Parser<'a> {
                 materialized: is_materialized,
             }
         } else {
-            let columns = self.parse_parenthesized_column_list(Optional, false)?;
+            let columns = self.parse_parenthesized_table_alias_column_list(Optional)?;
             self.expect_keyword(Keyword::AS)?;
             let mut is_materialized = None;
             if dialect_of!(self is PostgreSqlDialect) {
diff --git a/tmp/agent-patch-flux-pr-1526.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/tests/sqlparser_common.rs b/app/tests/sqlparser_common.rs
index 283071e..7e1feb2 100644
--- a/tmp/agent-patch-flux-pr-1526.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/tests/sqlparser_common.rs
+++ b/app/tests/sqlparser_common.rs
@@ -553,7 +553,20 @@ fn parse_select_with_table_alias() {
                 name: ObjectName(vec![Ident::new("lineitem")]),
                 alias: Some(TableAlias {
                     name: Ident::new("l"),
-                    columns: vec![Ident::new("A"), Ident::new("B"), Ident::new("C"),],
+                    columns: vec![
+                        TableAliasColumn {
+                            name: Ident::new("A"),
+                            data_type: None,
+                        },
+                        TableAliasColumn {
+                            name: Ident::new("B"),
+                            data_type: None,
+                        },
+                        TableAliasColumn {
+                            name: Ident::new("C"),
+                            data_type: None,
+                        },
+                    ],
                 }),
                 args: None,
                 with_hints: vec![],
@@ -566,6 +579,30 @@ fn parse_select_with_table_alias() {
     );
 }
 
+#[test]
+fn parse_table_alias_with_column_types() {
+    let sql = "SELECT * FROM (VALUES (1, 'a')) AS tbl (id int, name text)";
+    let select = verified_only_select(sql);
+    match only(select.from).relation {
+        TableFactor::Derived { alias: Some(alias), .. } => {
+            assert_eq!(
+                alias.columns,
+                vec![
+                    TableAliasColumn {
+                        name: Ident::new("id"),
+                        data_type: Some(DataType::Int(None)),
+                    },
+                    TableAliasColumn {
+                        name: Ident::new("name"),
+                        data_type: Some(DataType::Text),
+                    },
+                ]
+            );
+        }
+        other => panic!("Expected derived table, got {other:?}"),
+    }
+}
+
 #[test]
 fn parse_invalid_table_name() {
     let ast = all_dialects().run_parser_method("db.public..customer", |parser| {
@@ -6372,7 +6409,16 @@ fn parse_cte_renamed_columns() {
     let sql = "WITH cte (col1, col2) AS (SELECT foo, bar FROM baz) SELECT * FROM cte";
     let query = all_dialects().verified_query(sql);
     assert_eq!(
-        vec![Ident::new("col1"), Ident::new("col2")],
+        vec![
+            TableAliasColumn {
+                name: Ident::new("col1"),
+                data_type: None,
+            },
+            TableAliasColumn {
+                name: Ident::new("col2"),
+                data_type: None,
+            },
+        ],
         query
             .with
             .unwrap()
@@ -6401,9 +6447,12 @@ fn parse_recursive_cte() {
                 value: "nums".to_string(),
                 quote_style: None,
             },
-            columns: vec![Ident {
-                value: "val".to_string(),
-                quote_style: None,
+            columns: vec![TableAliasColumn {
+                name: Ident {
+                    value: "val".to_string(),
+                    quote_style: None,
+                },
+                data_type: None,
             }],
         },
         query: Box::new(cte_query),
diff --git a/tmp/agent-patch-flux-pr-1526.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/tests/sqlparser_postgres.rs b/app/tests/sqlparser_postgres.rs
index a6c480c..271a500 100644
--- a/tmp/agent-patch-flux-pr-1526.1-of-1.2026-02-28__18-27-22__gpt-5-1-codex-mini/app/tests/sqlparser_postgres.rs
+++ b/app/tests/sqlparser_postgres.rs
@@ -4419,6 +4419,34 @@ fn parse_mat_cte() {
     pg().verified_stmt(sql2);
 }
 
+#[test]
+fn parse_cte_column_type_annotations() {
+    let sql = "WITH cte (id int, name text) AS (SELECT 1, 'foo') SELECT * FROM cte";
+    let query = pg().verified_query(sql);
+    let columns = &query
+        .with
+        .as_ref()
+        .unwrap()
+        .cte_tables
+        .first()
+        .unwrap()
+        .alias
+        .columns;
+    assert_eq!(
+        columns,
+        &[
+            TableAliasColumn {
+                name: Ident::new("id"),
+                data_type: Some(DataType::Int(None)),
+            },
+            TableAliasColumn {
+                name: Ident::new("name"),
+                data_type: Some(DataType::Text),
+            },
+        ]
+    );
+}
+
 #[test]
 fn parse_at_time_zone() {
     pg_and_generic().verified_expr("CURRENT_TIMESTAMP AT TIME ZONE tz");