CCAR-F Prompt Engineering & Structured Output MEDIUM
PRODUCTION SCENARIO
An extraction schema has a delivery_date field with format date. Some purchase orders genuinely carry no delivery date. Downstream, the scheduler deserializes each record into a fixed struct where every key must be present, writes the value into a nullable DATE column, and has to tell an absent date from a real one before it schedules anything. It never needs to know why a date is missing.

Which output contract fits that consumer?

Answering here is anonymous. Nothing is saved unless you sign in.

Show answer and explanation

Answer: Type delivery_date as an anyOf of a date string and null, keeping it required

A union with null gives absence its own value: the key is present on every record, so the fixed struct deserializes, and the null lands in the nullable column as a null. Omitting the field from required is the right contract when the consumer inspects key presence, which this one cannot do, because a missing key breaks the struct it reads into. A sentinel is what you reach for when the sink forbids nulls; against a nullable column it hands the scheduler a real, orderable date it will treat as a delivery. An empty string is the same trick for a text column, and it is not a date, so the write fails on exactly the records the contract was meant to carry.
Free

Keep practicing CCAR-F

59 original CCAR-F practice questions, each with an explanation and a source link. No account needed.

Start free practice set → Timed, explained, free