Skip to content

Commit

Permalink
[SC-5704][REDSHIFT] Rename ExpressionToSQL test suite file and conver…
Browse files Browse the repository at this point in the history
…ter class. (apache#226)

## What changes were proposed in this pull request?
We merged in and closed PR apache#221 too soon, missing this commit that addressed the last review comments there.

## How was this patch tested?
Ran the existing unit tests.
  • Loading branch information
adrian-ionescu authored Feb 15, 2017
1 parent 1abda7f commit 118b4dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.catalyst.expressions.aggregate._
import org.apache.spark.sql.types._


private[pushdown] class ExpressionToSqlConverter(fields: Seq[Attribute]) {
/**
* Converter class to be used for turning a Catalyst `Expression` into a piece of SQL text
* that Redshift can digest.
*
* @param fields a set of "context" attributes to be used when resolving `AttributeReference`s
*/
private[pushdown] class ExpressionToSQL(fields: Seq[Attribute]) {
type ExpressionToSqlPF = PartialFunction[Expression, String]

private val literalExprs: ExpressionToSqlPF = {
Expand Down Expand Up @@ -202,11 +207,11 @@ private[pushdown] class ExpressionToSqlConverter(fields: Seq[Attribute]) {

private[pushdown] object ExpressionToSQL {
/**
* Helper function that instantiates an `ExpressionToSqlConverter` object
* Helper function that instantiates an `ExpressionToSQL` converter object
* and calls its `convertExpression()` method with the provided arguments.
*/
def convert(expr: Expression, fields: Seq[Attribute]): String = {
val converter = new ExpressionToSqlConverter(fields)
val converter = new ExpressionToSQL(fields)
converter.convertExpression(expr)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.apache.spark.sql.catalyst.expressions._
import org.apache.spark.sql.types._


class ExpressionToSqlSuite extends SparkFunSuite {
class ExpressionToSQLSuite extends SparkFunSuite {
def testExpr(expr: Expression, fields: Seq[Attribute], expected: String): Unit =
assertResult(expected)(ExpressionToSQL.convert(expr, fields))

Expand Down

0 comments on commit 118b4dd

Please sign in to comment.