Re-writing $f(x, y)$ as $g(x)h(y)$

decompose[
  expr_,
  vars_?(ListQ[#] && Length[#] >= 2 && VectorQ[#, AtomQ] &),
  dom_ : Reals
] := If[
        VectorQ[Keys[#], k \[Function] Length[k] <= 1],
                    {True, Times @@@ Apply[Power, #, {2}]},
        (* Else, do some math.
           True: Decomposable but `FactorList` failed.
           @PleaseCorrectGrammarMistakes *)
        (r \[Function] If[r,
                    {True, <||>},
        (* False: Undecomposable *)
                    {False, Null},
        (* Else: With condition *)
                    {ConditionalExpression[True, r],
                      Null}]
        )@ Resolve[ForAll[vars,
                     FunctionDomain[expr, vars, dom],
                     Reduce[
                       expr^(Length[vars] - 1)*D @@
                          Flatten[{expr, vars}]
                       == Times @@ (D[expr, #] & /@ vars),
                     dom]], dom]
      ] &@GroupBy[
            FactorList[expr],
            vars \[Intersection] Level[#[[1]], {-1}] &
      ]

For example:

decompose[(a y - x)/(y - 1), {x, y}]
{ConditionalExpression[True, a == 0], Null}
decompose[
 (Log[x] + (x - 1)/Sqrt[x]) (y^2 + Sqrt[y] + y) // Expand,
 {x, y}
 ]
{True, <|{} -> 1, {x} -> (-1 + x + Sqrt[x] Log[x])/Sqrt[x], {y} -> 
   Sqrt[y] (1 + Sqrt[y] + y^(3/2))|>}
decompose[
 (Log[x] + (x - 1)/Sqrt[x]) (y^2 + Sqrt[y] + x y) // Expand,
 {x, y}
 ]
{False, Null}
decompose[
 2 x^2 (1 + y) z Sqrt[z] // Expand,
 {x, y, z}]
{True, <|{} -> 2, {x} -> x^2, {z} -> z^(3/2), {y} -> 1 + y|>}
decompose[
 2 x^2 (1 + y) z Sqrt[x + z] // Expand,
 {x, y, z}]
{False, Null}

I found that there are similar questions in the course of mathematical analysis compiled by 史济怀 of China. I pasted the questions and the reference answers as follows:

enter image description here

On page 492 of this book, we can find a brief reference answer:

enter image description here

In short, if $u(x,y)$ can be decomposed into the product of two monomials, then the second mixed partial derivative of $\ln u(x,y)$ should be 0.