Skip to content

Conversation

@chenghao-intel
Copy link
Contributor

withTempTable("mytable") {
      sqlContext.sparkContext.parallelize(1 to 10).map(i => (i, i.toString))
        .toDF("key", "value")
        .registerTempTable("mytable")
      checkAnswer(sql(
        """select max(value) from mytable group by key % 2
          |order by max(concat(value,",", key)), min(substr(value, 0, 4))
          |""".stripMargin), Row("8") :: Row("9") :: Nil)
    }

Causes exception like:

cannot resolve '_aggOrdering' given input columns _c0, _aggOrdering, _aggOrdering;
org.apache.spark.sql.AnalysisException: cannot resolve '_aggOrdering' given input columns _c0, _aggOrdering, _aggOrdering;
    at org.apache.spark.sql.catalyst.analysis.package$AnalysisErrorAt.failAnalysis(package.scala:42)
    at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1$$anonfun$apply$2.applyOrElse(CheckAnalysis.scala:56)
    at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1$$anonfun$apply$2.applyOrElse(CheckAnalysis.scala:53)
    at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$transformUp$1.apply(TreeNode.scala:293)
    at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$transformUp$1.apply(TreeNode.scala:293)
    at org.apache.spark.sql.catalyst.trees.CurrentOrigin$.withOrigin(TreeNode.scala:51)
    at org.apache.spark.sql.catalyst.trees.TreeNode.transformUp(TreeNode.scala:292)
    at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$5.apply(TreeNode.scala:290)
    at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$5.apply(TreeNode.scala:290)
    at org.apache.spark.sql.catalyst.trees.TreeNode$$anonfun$4.apply(TreeNode.scala:249)
    at scala.collection.Iterator$$anon$11.next(Iterator.scala:328)
    at scala.collection.Iterator$class.foreach(Iterator.scala:727)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
    at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)
    at scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:103)
    at scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:47)
    at scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)
    at scala.collection.AbstractIterator.to(Iterator.scala:1157)
    at scala.collection.TraversableOnce$class.toBuffer(TraversableOnce.scala:265)
    at scala.collection.AbstractIterator.toBuffer(Iterator.scala:1157)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes exception with ambiguous references for _aggOrdering

@cloud-fan
Copy link
Contributor

Hi @chenghao-intel , thanks for working on this!

However, appending an index to the alising name is not enough to fix this bug, we also need to make sure the alising name is unique among existing aggregation expression names.
Actually I have already sent a PR to fix it at #8231, it would be good if you can review that, thanks!

@chenghao-intel
Copy link
Contributor Author

Yes, true, but I don't think we have to create an unique name to solve this. I will update the code soon.

@SparkQA
Copy link

SparkQA commented Aug 17, 2015

Test build #41007 has finished for PR 8234 at commit e9fc16c.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@chenghao-intel
Copy link
Contributor Author

@cloud-fan I thought we can avoid the explicit giving the name for the alias, however, it requires lots of code change, probably we'd better not to make happens in the release window.

As we did in lots of places, I gave the alias as it's expression value in string, which should solve this bug.

I like your idea to avoid giving the duplicate alias, but it will be great if you can make it a shared code as we do need it in lots of place.

@SparkQA
Copy link

SparkQA commented Aug 17, 2015

Test build #41016 has finished for PR 8234 at commit 8688ed0.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants