Yup. It should slide back on. If the plastic part is broken see if you can get somebody to crimp or solder a new female spade connector to the male (metal) connector that is connected to the window defogger tape. A female spade connector looks like this and it's probably behind the black plastic protector: ...and you can usually get a hand-full for a buck. Those don't usually "just fall off" and the rear defrosters aren't really a high failure item. If you just bought the car, and looking at your avatar, I'm thinking that you just did, I'd go poking around down inside the wheel well and see if you can find some itty bitty square pieces of glass indicating a rear window replacement following something REALLY interesting in your car's past. Good Luck!
You are right, there is glass, how much does this cost to get it fixed? by a mechanic? So was the car in a wreck or what? got the car pre inspected and the dude said car was fine.
Car is fine, cable got yanked. Who knows when it happened... Should just slide back on as mentioned above. Solution is there.
The car might not have been in a wreck, but it's a sure bet that the back glass was replaced, and whoever did it wasn't competent enough to replace the connector for the rear glass defroster. Since it seems that you just bought the car I'm betting it was wrecked, maybe even totaled and rebuilt - which would trigger a sale. NOTE this is not a reason to miss trust the car or think that it's in any way unreliable, but it's something that you should not have had to discover forensically. AND...you have a powerful incentive in a four year old car with a lot of hybrid components to close the loop on that question since cars with sketchy titles have sketchy warranties. As far as the connector is concerned, it should re-attachable to the spade connector on the glass - PRESUMING that it's a properly fitted factory replacement. This isn't a 'mechanic' thing, its an electrical thing. If you cannot do this, take it somewhere that does aftermarket sound or alarm systems - or - some place like AutoZone or Pep Boys. I'm thinking that a $20 tip to whoever is running the counter will get your rear defroster back in battery. Good Luck!!
Or... and hear me out because this is crazy... or maybe the cable got pulled on by something in the luggage compartment and nothing nefarious is actually occurring.