“Dancing with the Stars” producers are taking a HUUUGE gamble, because they just signed Andy Dick to join the cast … a notorious loose cannon whose last stint in TV was “Celebrity Rehab.”

Sources close to the production tell us … Andy was on the set today … along with Lisa Vanderpump, and D.L. Hughley (who are also believed to have signed contracts to compete on the show).

We”re told Andy has been paired up with one of the new dancers … and one connected source tells us, “He”s more for comedy … nobody expects much from him.”

Still, one source insists Andy is taking the competition very seriously and wants to prove that he”s for real.

Andy”s a risky cast choice for LIVE TV — to say the least — considering the troubled actor”s been in and out of rehab, has been arrested a whole bunch of times … and has a reputation for being unpredictable.