Hydrolyzes UDP-glucose to glucose 1-phosphate and UMP and UDP-galactose to galactose 1-phosphate and UMP. Preferred substrate is UDP-glucose. UDP-sugar + H2O = UMP + alpha-D-aldose 1-phosphate. Belongs to the Nudix hydrolase family.