The process has changed recently somewhat.
We typically dont don't bring milk for our 2-year-old, but often bring a little water in her soppy cup. as mentioned, you'll need to have it screened and separately (needs to come out of any bags). Often, if San agent sees you with a child, or a diaper bag on the belt, they'll ask if there's any liquids for the baby, but we always try to specify.
It will be screened throuh the X-ray, and then tested. Up until fairly recently, they'd just swab the outside of the cup - I think that's the pretty standard explosives swab, but not entirely sure if it might be somewhat different. I know at CVG on our most recent departure, they have a different kind of strip they use now - they insert it into the water, and then brush it with some chemical, I guess. At SJC, I think they put it some machine - I can't remember exactly.
Either way, it's pretty painless. Just takes a little bit of extra time, but no more than a minute or two.