Ergodicity of a skew product 
Let $a \in \Bbb{R}$ and $f:[0,1) \to \Bbb{R}$ a Lebesgue measurable function.
We define the transformation $T:[0,1)^2 \to [0,1)^2$ such that $$T(x,y)=(x+a,y+f(x))mod1=(\{x+a\},\{y+f(x)\})$$
Prove that the dynamical system $([0,1)^2,\mathcal{B},m_{[0,1)}\times m_{[0,1)},T)$,where $\mathcal{B}$ is the Borel sigma algebra on $[0,1)^2$, is $\text{ergodic}$ if and only if:
$a \in \Bbb{R}\setminus \Bbb{Q}$ and $\forall m\in \Bbb{N}$,the functonal equation $$mf(x)=h(x+a)-h(x)  (mod1)$$ does not have a measurable solution $h: [0,1) \to \Bbb{R}$.

My first though was to use Fourier expansions for the equation $$g(T(x,y))=g(x,y)$$
where $g$ is an arbitrary function in $L^2([0,1)^2)$ to check ergodicity.
In other words to show under which conditions the function $g$  is constant.
Also i was given a hint to consider expansions of the form $$\sum_{k \in \Bbb{Z}}a_k(x)e^{2\pi iky}$$.
But unfortunately i cannot reach the desired conclusion.
I would appreciate some help in this problem.
Thank you in advance.
 A: I believe I have a solution.
First direction : If there exists such $h$ we define $g(x,y) = e^{2\pi i (h(x)-my)}$
This is a measurable map and $Tg(x,y) = e^{2\pi i (h(x+a)+my-mf(x))}$
now $mf(x)=h(x+a)-h(x)$ so we have $Tg(x,y) = e^{2\pi i (h(x)-my)} = g(x,y)$ which is contradiction to ergodicity. (Hence ergodicity implies there is no such $h$).
Second direction: Suppose there is no such $h$, we show that $T$ is ergodic. Suppose by contradiction it is not, then there exists an invariant function $g(x,y)=\sum_{m} a_m(x) e^{-2\pi i m y}$ applying $T$ we have $Tg(x,y) = \sum_m a_m(x+a) e^{-2\pi i m f(x)} e^{-2\pi i m y}$
Since the Fourier coefficients unique we have $a_m(x)=a_m(x+a)e^{-2\pi i m f(x)}$, in particular $|a_m(x)| = |a_m(x+a)|$ as $a$ is irrational we have that $|a_m(x)|$ is a constant and we can assume it is equal $1$ for $m$ such that $a_m(x)\not = 0$.
Choose $m\not= 0$ such that $a_m(x)\not = 0$ (which exists, otherwise $g$ is a constant), and let $b_m(x)$ be such that $a_m(x) = e^{2\pi i b_m(x)}$ we conclude that  $mf(x)=b_m(x+a)-b_m(x) \text{ mod 1}$ which is a contradiction.
