The night before making the tart, wrap the butter for the pastry in foil, and freeze until solid – this will make it easier to grate. To make the pastry, put the flour in a large bowl and mix in half the polenta, the cheese, thyme (reserving a few leaves to serve) and a good pinch of salt. Using a coarse cheese grater, grate in the frozen butter – try to handle it as little as possible so it doesn’t get soft – and stir it in with a knife as you go. Give the mixture one last stir to make sure all the butter is coated with flour, then quickly stir in 125ml very cold water. Gently bring together with your hands (splashing in a little more water if it looks dry), then wrap in baking parchment
and chill for 30 mins.
Slice the tomatoes to roughly the thickness of a £1 coin (use a mandoline, if you have one). Reserve about half of the tomato slices for the top of the tart, then roughly chop the rest into chunks.
Heat the grill to high (or you can use the flame of a gas hob). Pierce the aubergine four or five times with the tip of a knife and grill (or hold over the gas flame using tongs), turning often, for 8-10 mins, or until the skin is charred and the aubergine is soft and collapsing. Leave to cool a little.
Heat half the oil in a pan over a low-medium heat, and cook the onions with a pinch of salt for 10 mins until the onions start to caramelise. Meanwhile, scrape the skin off the aubergine (don’t worry if some pieces cling to the flesh – it will add a smoky flavour). Roughly chop the aubergine flesh.
Add the garlic and aubergine to the onions and cook for another 5 mins, or until any liquid released from the aubergine has evaporated. Add the chopped tomatoes and sugar, season, and continue to cook for 5-10 mins until thickened. Leave to cool, then chill until ready to use. Can be prepared up to a day ahead.
Slice the courgettes to roughly the thickness of a £1 coin. Put in a bowl and toss with a good pinch of salt. Leave for 10 mins.
Remove the pastry from the fridge. Heat the oven to 200C/180C fan/gas 6 with a baking tray inside (or a 30cm shallow skillet pan, if you have one). Roll the pastry out on a large sheet of baking parchment dusted with a little flour, to a circle about 35cm wide. Trim the edge if you want a neat finish.
Drain any liquid from the courgettes, then tip onto a plate lined with kitchen paper. Pat dry to remove as much moisture as you can. Sprinkle the remaining polenta over the pastry, then top with the chilled tomato and aubergine mix. Spread it out using the back of a spoon, leaving a 3cm border around the edge.
Arrange the reserved tomato slices and the courgettes in overlapping concentric circles on top of the tart. Brush the vegetables with the remaining oil, season and sprinkle with the parmesan. Fold the pastry edge over the veg slightly, pressing gently to seal. Brush the pastry edge with the beaten yolk.
Carefully slide the tart, still on the baking parchment, onto the hot tray or into the skillet pan. Bake for 45 mins until golden, then scatter with the extra thyme leaves, if using. Leave to cool a little and serve just warm, or at room temperature.