Mix both types of flour, polenta, thyme, sugar, salt, pepper and oil in a large bowl. Add the butter and stir gently by crushing each cube between your fingers. Add water and collect the dough with your hands - it will be quite sticky. Transfer to a well-floured surface and knead a little more. Shape the dough in a circle, wrap it tightly with cling film and place in the refrigerator for 30 minutes.
In a small bowl, mix the ricotta, a pinch of salt, pepper to taste and lemon zest and set aside. Cut the tomatoes in half (if they are small - cherry or plum) or into slices if they are large and season with salt. Drain them.
Roll out the dough between two baking papers and transfer to a pie mould. Place the cheese filling on the bottom and arrange the drained tomatoes on it. Place them closely together as they will shrink when cooking.
Bake for 30-40 minutes at 180 degrees.