SKY-12070 mint requested-output criteria for quoted fields (#7227)

This commit is contained in:
Andrew Neilson 2026-07-08 20:54:49 -07:00 committed by GitHub
parent 33ee848e01
commit 65d28b1666
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 147 additions and 0 deletions

View file

@ -1020,6 +1020,7 @@ def _clean_requested_output_candidate(segment: str, aliases: dict[str, str] | No
if not candidate:
return None
candidate = _normalize_named_output_field_delimiter(candidate)
named_field = _OUTPUT_NAMED_FIELD_RE.search(candidate)
if named_field is not None:
return named_field.group(1)
@ -1093,6 +1094,27 @@ def _clean_requested_output_candidate(segment: str, aliases: dict[str, str] | No
return " ".join(phrase_words)
def _normalize_named_output_field_delimiter(candidate: str) -> str:
lowered = candidate.casefold()
for anchor in (" named", " called"):
token_start = lowered.find(anchor)
if token_start == -1:
continue
token_start += len(anchor)
while token_start < len(candidate) and candidate[token_start].isspace():
token_start += 1
if token_start >= len(candidate) or candidate[token_start] not in "'\"`":
continue
quote = candidate[token_start]
token_end = candidate.find(quote, token_start + 1)
if token_end == -1:
continue
field_name = candidate[token_start + 1 : token_end]
if _OUTPUT_EXPLICIT_FIELD_KEY_RE.fullmatch(field_name):
return f"{candidate[:token_start]}{field_name}{candidate[token_end + 1 :]}"
return candidate
def _matched_alias_phrase(candidate: str, alias_key: str) -> str | None:
alias_words = alias_key.split()
if not alias_words: