Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
marmbrus committed Jul 26, 2014
1 parent 033abc6 commit 1ec2d6e
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 12 deletions.
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<sbt.project.name>spark</sbt.project.name>
<scala.version>2.10.4</scala.version>
<scala.binary.version>2.10</scala.binary.version>
<scala.macros.version>2.0.1</scala.macros.version>
<mesos.version>0.18.1</mesos.version>
<mesos.classifier>shaded-protobuf</mesos.classifier>
<akka.group>org.spark-project.akka</akka.group>
Expand Down Expand Up @@ -818,6 +819,15 @@
<javacArg>-target</javacArg>
<javacArg>${java.version}</javacArg>
</javacArgs>
<!-- The following plugin is required to use quasiquotes in Scala 2.10 and is used
by Spark SQL for code generation. -->
<compilerPlugins>
<compilerPlugin>
<groupId>org.scalamacros</groupId>
<artifactId>paradise_${scala.version}</artifactId>
<version>${scala.macros.version}</version>
</compilerPlugin>
</compilerPlugins>
</configuration>
</plugin>
<plugin>
Expand Down
4 changes: 1 addition & 3 deletions project/SparkBuild.scala
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ object SparkBuild extends PomBuild {

object Catalyst {
lazy val settings = Seq(
addCompilerPlugin("org.scalamacros" % "paradise" % "2.0.1" cross CrossVersion.full),
libraryDependencies <+= scalaVersion(v => "org.scala-lang" % "scala-compiler" % v),
libraryDependencies += "org.scalamacros" %% "quasiquotes" % "2.0.1")
addCompilerPlugin("org.scalamacros" % "paradise" % "2.0.1" cross CrossVersion.full))
}

object SQL {
Expand Down
9 changes: 9 additions & 0 deletions sql/catalyst/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,19 @@
</properties>

<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
</dependency>
<dependency>
<groupId>org.scalamacros</groupId>
<artifactId>quasiquotes_${scala.binary.version}</artifactId>
<version>${scala.macros.version}</version>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_${scala.binary.version}</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,10 @@ abstract class CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Loggin
evaluateAs(expressions._1.dataType)(f)

def evaluateAs(resultType: DataType)(f: (TermName, TermName) => Tree): Seq[Tree] = {
// Right now some timestamp tests fail if we enforce this...
if (expressions._1.dataType != expressions._2.dataType)
// TODO: Right now some timestamp tests fail if we enforce this...
if (expressions._1.dataType != expressions._2.dataType) {
log.warn(s"${expressions._1.dataType} != ${expressions._2.dataType}")
}

val eval1 = expressionEvaluator(expressions._1)
val eval2 = expressionEvaluator(expressions._2)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
package org.apache.spark.sql
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.sql

package object catalyst {
/**
Expand All @@ -8,4 +24,4 @@ package object catalyst {
* 2.10.* builds. See SI-6240 for more details.
*/
protected[catalyst] object ScalaReflectionLock
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ object PhysicalOperation extends PredicateHelper {
}
}

/**
* Matches a logical aggregation that can be performed on distributed data in two steps. The first
* operates on the data in each partition performing partial aggregation for each group. The second
* occurs after the shuffle and completes the aggregation.
*
* This pattern will only match if all aggregate expressions can be computed partially and will
* return the rewritten aggregation expressions for both phases.
*
* The returned values for this match are as follows:
* - Grouping attributes for the final aggregation.
* - Aggregates for the final aggregation.
* - Grouping expressions for the partial aggregation.
* - Partial aggregate expressions.
* - Input to the aggregation.
*/
object PartialAggregation {
type ReturnType =
(Seq[Attribute], Seq[NamedExpression], Seq[Expression], Seq[NamedExpression], LogicalPlan)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,7 @@ abstract class NumericType extends NativeType with PrimitiveType {
}

object NumericType {
def unapply(a: Expression): Boolean = a match {
case e: Expression if e.dataType.isInstanceOf[NumericType] => true
case _ => false
}
def unapply(e: Expression): Boolean = e.dataType.isInstanceOf[NumericType]
}

/** Matcher for any expressions that evaluate to [[IntegralType]]s */
Expand Down
2 changes: 1 addition & 1 deletion sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ trait SQLConf {
private[spark] def numShufflePartitions: Int = get("spark.sql.shuffle.partitions", "200").toInt

/**
* When set to true, Spark SQL will use the scala compiler at runtime to generate custom bytecode
* When set to true, Spark SQL will use the Scala compiler at runtime to generate custom bytecode
* that evaluates expressions found in queries. In general this custom code runs much faster
* than interpreted evaluation, but there are significant start-up costs due to compilation.
* As a result codegen is only benificial when queries run for a long time, or when the same
Expand Down

0 comments on commit 1ec2d6e

Please sign in to comment.