Commit 1073e49
authored
Fix
* Fix LLMSQLQueryOperator not stripping single-line markdown code fences
_strip_llm_output only removed ```sql fences when the LLM's response
spanned multiple lines. LLMs that wrap short queries in a fence on a
single line (e.g. "```SELECT 1```") passed the fenced text straight
into SQL validation/execution with the backticks still attached. Add
a fallback branch for the single-line case, alongside the existing
multi-line handling.
* Also strip a same-line language tag on single-line fences
Address review feedback: a single-line fence like "```sql SELECT 1```"
left "sql " stuck to the front of the query, since the earlier fix only
stripped the outer backticks. Drop the leading word too, but only when
it's "sql" or the resolved dialect, so a real leading SQL keyword is
never mistaken for a tag.LLMSQLQueryOperator not stripping single-line markdown code fences (#70137)1 parent f3edf4d commit 1073e49
2 files changed
Lines changed: 51 additions & 3 deletions
File tree
- providers/common/ai
- src/airflow/providers/common/ai/operators
- tests/unit/common/ai/operators
Lines changed: 13 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
181 | 180 | | |
| 181 | + | |
182 | 182 | | |
183 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
184 | 194 | | |
185 | 195 | | |
186 | 196 | | |
| |||
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
80 | 100 | | |
81 | 101 | | |
82 | 102 | | |
83 | 103 | | |
84 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
85 | 123 | | |
86 | 124 | | |
87 | 125 | | |
| |||
0 commit comments