The title says it all, I am looking for a function that equals $y=x$ for every $x \in \mathbb{Q}$but that does not equals $y=x$ when the value of $x \notin \mathbb{Q}$.
The function does not necessarily have to be continuous.
It does not matter how the function behaves in the complex plane.
Define
$$f(x) = \begin{cases} x ~~~~~ \text{for}~~ x\in \mathbb{Q} \\ 0 ~~~~~ \text{for}~~ x \not\in \mathbb{Q} \end{cases} $$