  We study the thermal partition function of quantum field theories on
arbitrary stationary background spacetime, and with arbitrary stationary
background gauge fields, in the long wavelength expansion. We demonstrate that
the equations of relativistic hydrodynamics are significantly constrained by
the requirement of consistency with any partition function. In examples at low
orders in the derivative expansion we demonstrate that these constraints
coincide precisely with the equalities between hydrodynamical transport
coefficients that follow from the local form of the second law of
thermodynamics. In particular we recover the results of Son and Surowka on the
chiral magnetic and chiral vorticity flows, starting from a local partition
function that manifestly reproduces the field theory anomaly, without making
any reference to an entropy current. We conjecture that the relations between
transport coefficients that follow from the second law of thermodynamics agree
to all orders in the derivative expansion with the constraints described in
this paper.
