You say 'recently bought', and 'dealer says it is just a sensor'.
How recently, days, weeks, months, years?
Is this the selling dealer? Is it under any warranty, or was it bought as a trade sale?
The dealer may have some responsibility to fix this.
The check engine light could be for a variety of reasons, but a common one is the oxygen sensor in the exhaust, that monitors the exhaust from the engine, and the computer uses this to adjust the fuelling. They do fail, and if they give the wrong reading, the computer will set fuelling to a standard setting. This should be temporary, as, if not fixed, can lead to damage to the catalytinc converter, which is expensive.
Alternatively, this could be an engine temperature sensor. If it is reporting wrongly, again the fuelling will be wrong. Possibly, it is reporting a hot engine when cold, so fuelling is reduced, leading to stalling. Or reporting a cold engine when warm, leading to overfuelling, which can also lead to stalling, and again, damage to the catalytic converter.
The dealer seems to know what the fault is, why is he not fixing it?
Your warning lights are colour-coded, like traffic lights.
Green is information, such as lights on, indicators, etc.
Yellow is a warning, danger, something that needs to be fixed soon, very soon. Such as oxygen or temp sensors, or a lamp failure.
Red, is probably too late. It is for serious issues, most of which require you to stop, before the light comes on. Such as loss of oil pressure, or battery not being charged.
There's one blue one, for headlamp high beam. If you see other blue lights, you're in trouble.