The purpose of a fuel filter is to make sure that only clean fuel enters into the engine to be burned. Both petrol and diesel engines use fuel filters, however, in a diesel engine it is critical that the fuel is filtered for contaminants before entering the engine and for water to be filtered out to avoid any possible damage to the engine. This is not the same in the case of petrol engines.
This is why a fuel filter with a water trap is commonly used in private and commercial diesel engines. Typically the filtering of contaminants and water is done within the same fuel filter unit. The filter may have a bowl shaped reservoir at the bottom where the water will gather, as water is heavier than diesel.
The water then has to be removed, and this is normally achieved by using a valve at the bottom of the reservoir so the water can be drained away leaving just clean diesel fuel.
In many modern cars and commercial vehicles, sensors and electronic valves are used which drain the water automatically once it has reached a certain level in the reservoir of the filter.
Water contamination can be caused by a variety of things such as condensation which gathers inside the fuel tank due to humidity or temperature changes. As fuel is normally fed form the bottom of the fuel tank, and water is heavier than diesel, it means that the water will be sucked up first when you start your engine in the morning.
Typical sign of water contamination in fuel are when your engine runs rough, or idles with an uneven rhythm or loses power. This could be caused by either solid or water contamination but you should drain any accumulated water from the fuel filter water trap first or completely replace the fuel filter.