Skip to content

Conversation

@rxin
Copy link
Contributor

@rxin rxin commented Jul 15, 2015

This builds on #7433 but also removes LeafNode/UnaryNode. These are slightly more complicated to remove. I had to change some abstract classes to traits in order for it to work.

The problem with LeafNode/UnaryNode is that they are often mixed in at the end of an Expression, and then the toString function actually gets resolved to the ones defined in TreeNode, rather than in Expression.

@SparkQA
Copy link

SparkQA commented Jul 16, 2015

Test build #37427 has finished for PR 7434 at commit 43eeb12.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • abstract class StandaloneRecoveryModeFactory(conf: SparkConf, serializer: Serializer)
    • case class UnresolvedAttribute(nameParts: Seq[String]) extends Attribute
    • abstract class Star extends LeafExpression with NamedExpression
    • case class UnresolvedAlias(child: Expression) extends UnaryExpression with NamedExpression
    • abstract class LeafExpression extends Expression
    • abstract class UnaryExpression extends Expression
    • abstract class BinaryExpression extends Expression
    • case class SortOrder(child: Expression, direction: SortDirection) extends UnaryExpression
    • trait AggregateExpression extends Expression
    • trait PartialAggregate extends AggregateExpression
    • case class Min(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Max(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Count(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Average(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Sum(child: Expression) extends UnaryExpression with PartialAggregate
    • case class SumDistinct(child: Expression) extends UnaryExpression with PartialAggregate
    • case class First(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Last(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Pmod(left: Expression, right: Expression) extends BinaryArithmetic
    • final class SpecificRow extends $
    • trait Generator extends Expression
    • case class Explode(child: Expression) extends UnaryExpression with Generator
    • trait NamedExpression extends Expression
    • abstract class Attribute extends LeafExpression with NamedExpression
    • case class PrettyAttribute(name: String) extends Attribute
    • abstract class LeafNode extends LogicalPlan
    • abstract class UnaryNode extends LogicalPlan
    • abstract class BinaryNode extends LogicalPlan

@rxin rxin force-pushed the remove-binary-unary-leaf-node branch from 00faa74 to 2225331 Compare July 16, 2015 01:20
@rxin
Copy link
Contributor Author

rxin commented Jul 16, 2015

cc @marmbrus

@SparkQA
Copy link

SparkQA commented Jul 16, 2015

Test build #37435 has finished for PR 7434 at commit 2225331.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class UnresolvedAttribute(nameParts: Seq[String]) extends Attribute
    • abstract class Star extends LeafExpression with NamedExpression
    • case class UnresolvedAlias(child: Expression) extends UnaryExpression with NamedExpression
    • abstract class LeafExpression extends Expression
    • abstract class UnaryExpression extends Expression
    • abstract class BinaryExpression extends Expression
    • case class SortOrder(child: Expression, direction: SortDirection) extends UnaryExpression
    • trait AggregateExpression extends Expression
    • trait PartialAggregate extends AggregateExpression
    • case class Min(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Max(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Count(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Average(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Sum(child: Expression) extends UnaryExpression with PartialAggregate
    • case class SumDistinct(child: Expression) extends UnaryExpression with PartialAggregate
    • case class First(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Last(child: Expression) extends UnaryExpression with PartialAggregate
    • trait Generator extends Expression
    • case class Explode(child: Expression) extends UnaryExpression with Generator
    • trait NamedExpression extends Expression
    • abstract class Attribute extends LeafExpression with NamedExpression
    • case class PrettyAttribute(name: String) extends Attribute
    • abstract class LeafNode extends LogicalPlan
    • abstract class UnaryNode extends LogicalPlan
    • abstract class BinaryNode extends LogicalPlan

@SparkQA
Copy link

SparkQA commented Jul 16, 2015

Test build #37439 has finished for PR 7434 at commit 9c589cf.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class UnresolvedAttribute(nameParts: Seq[String]) extends Attribute
    • abstract class Star extends LeafExpression with NamedExpression
    • case class UnresolvedAlias(child: Expression) extends UnaryExpression with NamedExpression
    • abstract class LeafExpression extends Expression
    • abstract class UnaryExpression extends Expression
    • abstract class BinaryExpression extends Expression
    • case class SortOrder(child: Expression, direction: SortDirection) extends UnaryExpression
    • trait AggregateExpression extends Expression
    • trait PartialAggregate extends AggregateExpression
    • case class Min(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Max(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Count(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Average(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Sum(child: Expression) extends UnaryExpression with PartialAggregate
    • case class SumDistinct(child: Expression) extends UnaryExpression with PartialAggregate
    • case class First(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Last(child: Expression) extends UnaryExpression with PartialAggregate
    • trait Generator extends Expression
    • case class Explode(child: Expression) extends UnaryExpression with Generator
    • trait NamedExpression extends Expression
    • abstract class Attribute extends LeafExpression with NamedExpression
    • case class PrettyAttribute(name: String) extends Attribute
    • abstract class LeafNode extends LogicalPlan
    • abstract class UnaryNode extends LogicalPlan
    • abstract class BinaryNode extends LogicalPlan

@SparkQA
Copy link

SparkQA commented Jul 16, 2015

Test build #37440 has finished for PR 7434 at commit 3135a8b.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class UnresolvedAttribute(nameParts: Seq[String]) extends Attribute
    • abstract class Star extends LeafExpression with NamedExpression
    • case class UnresolvedAlias(child: Expression) extends UnaryExpression with NamedExpression
    • case class SortOrder(child: Expression, direction: SortDirection) extends UnaryExpression
    • trait AggregateExpression extends Expression
    • trait PartialAggregate extends AggregateExpression
    • case class Min(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Max(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Count(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Average(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Sum(child: Expression) extends UnaryExpression with PartialAggregate
    • case class SumDistinct(child: Expression) extends UnaryExpression with PartialAggregate
    • case class First(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Last(child: Expression) extends UnaryExpression with PartialAggregate
    • trait Generator extends Expression
    • case class Explode(child: Expression) extends UnaryExpression with Generator
    • trait NamedExpression extends Expression
    • abstract class Attribute extends LeafExpression with NamedExpression
    • case class PrettyAttribute(name: String) extends Attribute
    • abstract class LeafNode extends LogicalPlan
    • abstract class UnaryNode extends LogicalPlan

Copy link
Contributor

Choose a reason for hiding this comment

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

how about:

trait AggregateExpression {
  self: Expression =>
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it'd result in a lot more code changes to get it working. e.g.

abstract class AggregateFunction
  extends LeafExpression with AggregateExpression with Serializable {
  self: Product =>

  /** Base should return the generic aggregate expression that this function is computing */
  val base: AggregateExpression

  override def nullable: Boolean = base.nullable   <--- this won't work anymore
  override def dataType: DataType = base.dataType

@SparkQA
Copy link

SparkQA commented Jul 16, 2015

Test build #37458 has finished for PR 7434 at commit 9e8a4de.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class UnresolvedAttribute(nameParts: Seq[String]) extends Attribute
    • abstract class Star extends LeafExpression with NamedExpression
    • case class UnresolvedAlias(child: Expression) extends UnaryExpression with NamedExpression
    • case class SortOrder(child: Expression, direction: SortDirection) extends UnaryExpression
    • trait AggregateExpression extends Expression
    • trait PartialAggregate extends AggregateExpression
    • case class Min(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Max(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Count(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Average(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Sum(child: Expression) extends UnaryExpression with PartialAggregate
    • case class SumDistinct(child: Expression) extends UnaryExpression with PartialAggregate
    • case class First(child: Expression) extends UnaryExpression with PartialAggregate
    • case class Last(child: Expression) extends UnaryExpression with PartialAggregate
    • trait Generator extends Expression
    • case class Explode(child: Expression) extends UnaryExpression with Generator
    • trait NamedExpression extends Expression
    • abstract class Attribute extends LeafExpression with NamedExpression
    • case class PrettyAttribute(name: String) extends Attribute
    • abstract class LeafNode extends LogicalPlan
    • abstract class UnaryNode extends LogicalPlan

Copy link
Contributor

Choose a reason for hiding this comment

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

I remember we set a default parameter value for eval, so we can just write e.eval() here?

@rxin
Copy link
Contributor Author

rxin commented Jul 16, 2015

OK I'm going to merge this. I will try to get rid of the self types in a followup pr.

@asfgit asfgit closed this in fec10f0 Jul 16, 2015
asfgit pushed a commit that referenced this pull request Jul 17, 2015
Just a small change to add Product type to the base expression/plan abstract classes, based on suggestions on #7434 and offline discussions.

Author: Reynold Xin <[email protected]>

Closes #7479 from rxin/remove-self-types and squashes the following commits:

e407ffd [Reynold Xin] [SPARK-9142][SQL] Removing unnecessary self types in Catalyst.
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.

4 participants