Recent research on turbulent flow over heterogeneous rough walls have reported the occurrence of secondary motions which extend to the edge of the boundary layer. In this study, direct numerical simulations (DNSs) of turbulent flow in a rough-wall pipe are conducted where the pipe surface consists of a three-dimensional sinusoidal surface. The roughness semi-amplitude height (h+) is fixed at 60 viscous units while the wavelength of the roughness elements is varied to investigate the effects of solidity or effective slope (ES). The rough-wall cases, which vary from the wavy regime (ES = 0.18 with a viscous roughness wavelength, λ+ of 848) to the closely packed roughness/dense regime (ES = 0.72, λ+ = 212), have a staggered arrangement. Using the triple decomposition, the time-independent dispersive stresses, which arise due to the stationary features of the flow, are found to increase in magnitude with roughness wavelength. These dispersive stresses, which are maximum in the roughness canopy, are due to the occurrence of secondary flows. These secondary flows transport high-speed fluid from the outer region to the near-wall region and pump low-speed fluid from the near-wall region to the outer region. For the range of cases simulated here, the wall-normal and spanwise extent of these secondary motions are found to scale with the roughness spanwise wavelength. This gives an indication of how the roughness sublayer is related to the degree of surface heterogeneity, with spanwise homogeneous flow only observed once the distance from the wall exceeds the spanwise spacing of the roughness. For the case with the largest wavelength (ES = 0.18), the secondary flows occupy a significant portion of the pipe cross-section.