[SPARK-2041][SQL] Correctly analyze queries where columnName == tableName.

Author: Michael Armbrust <michael@databricks.com>

Closes #985 from marmbrus/tableName and squashes the following commits:

3caaa27 [Michael Armbrust] Correctly analyze queries where columnName == tableName.

(cherry picked from commit c7a183b2c2bca13565496495b4ae3a3a9f63f9ab)
Signed-off-by: Reynold Xin <rxin@apache.org>