title: Cannot resolve column name in dataframe - pyspark 1.6
body: <p>We have few dataframes created from hive tables.When joining two dataframes among them,throws pyspark.sql.utils.AnalysisException: u'Cannot resolve column name ". But the prinSchema() prints the columns correctly. I can't provide the entire code, but those dataframes used for joining,</p>
  
  <pre><code> &gt;&gt;&gt; scoreitemavail.printSchema()
   root
     |-- key: string (nullable = true)
     |-- item_nbr: string (nullable = true)
     |-- cat_nbr: string (nullable = true)
     |-- score: double (nullable = true)
  
  &gt;&gt;&gt; itemagg=scoreitemavail.groupBy('tem_nbr','cat_nbr').agg({"score":"count"})
  &gt;&gt;&gt; itemagg.printSchema()
  root
    |-- item_nbr: string (nullable = true)
    |-- cat_nbr: string (nullable = true)
    |-- count(score): long (nullable = false)
  &gt;&gt;&gt;subcatagg=scoreitemavail.groupBy('cat_nbr').agg(F.countDistinct('key').alias('count_cat'))
  &gt;&gt;&gt; subcatagg.printSchema()
  root
    |-- cat_nbr: string (nullable = true)
    |-- count_cat: long (nullable = false)
  
  &gt;&gt;&gt;itemsubcatjoin1=subcatagg.join(itemagg,itemagg['cat_nbr']==subcatagg['cat_nbr'],'inner')
  
  17/05/03 17:55:47 WARN Column: Constructing trivially true equals predicate, 'cat_nbr#43 = cat_nbr#43'. Perhaps you need to use aliases.
  Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "/usr/hdp/2.4.2.0-258/spark/python/pyspark/sql/dataframe.py", line 653, in join
  jdf = self._jdf.join(other._jdf, on._jc, how)
  File "/usr/hdp/2.4.2.0-258/spark/python/lib/py4j-0.9-src.zip/py4j/java_gateway.py", line 813, in __call__
  File "/usr/hdp/2.4.2.0-258/spark/python/pyspark/sql/utils.py", line 51, in deco
  raise AnalysisException(s.split(': ', 1)[1], stackTrace)
  pyspark.sql.utils.AnalysisException: u'Cannot resolve column name "cat_nbr" among (_col7, _col6, count(score));'
  </code></pre>
  
  <p>Any suggestions will be helpful. Thanks !</p>