Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-8993][SQL] More comprehensive type checking in expressions. #7348

Closed
wants to merge 13 commits into from

Conversation

rxin
Copy link
Contributor

@rxin rxin commented Jul 10, 2015

This patch makes the following changes:

  1. ExpectsInputTypes only defines expected input types, but does not perform any implicit type casting.
  2. ImplicitCastInputTypes is a new trait that defines both expected input types, as well as performs implicit type casting.
  3. BinaryOperator has a new abstract function "inputType", which defines the expected input type for both left/right. Concrete BinaryOperator expressions no longer perform any implicit type casting.
  4. For BinaryOperators, convert NullType (i.e. null literals) into some accepted type so BinaryOperators don't need to handle NullTypes.

TODOs needed: fix unit tests for error reporting.

I'm intentionally not changing anything in aggregate expressions because @yhuai is doing a big refactoring on that right now.

@rxin
Copy link
Contributor Author

rxin commented Jul 10, 2015

cc @cloud-fan

I had this change on my laptop I didn't commit, which I believe actually encompasses your change. #7338

override def checkInputDataTypes(): TypeCheckResult = {
// First call the checker for ExpectsInputTypes, and then check whether left and right have
// the same type.
super.checkInputDataTypes() match {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note that this will use expects input types to do the type check, if available.

@rxin rxin changed the title [WIP] Improve expression type checking. [SPARK-8993][SQL] Leverage ExpectsInputTypes in as many expressions as possible Jul 10, 2015
@rxin rxin changed the title [SPARK-8993][SQL] Leverage ExpectsInputTypes in as many expressions as possible [SPARK-8993][SQL] [WIP] Leverage ExpectsInputTypes in as many expressions as possible Jul 10, 2015
@SparkQA
Copy link

SparkQA commented Jul 11, 2015

Test build #37063 has finished for PR 7348 at commit d915899.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class UnaryMinus(child: Expression) extends UnaryArithmetic with ExpectsInputTypes
    • case class Abs(child: Expression) extends UnaryArithmetic with ExpectsInputTypes
    • case class Add(left: Expression, right: Expression)
    • case class Subtract(left: Expression, right: Expression)
    • case class Multiply(left: Expression, right: Expression)
    • case class Divide(left: Expression, right: Expression)
    • case class Remainder(left: Expression, right: Expression)
    • case class BitwiseAnd(left: Expression, right: Expression)
    • case class BitwiseOr(left: Expression, right: Expression)
    • case class BitwiseXor(left: Expression, right: Expression)
    • case class BitwiseNot(child: Expression) extends UnaryArithmetic with ExpectsInputTypes

} else {
TypeCheckResult.TypeCheckSuccess
}
case TypeCheckResult.TypeCheckFailure(msg) => TypeCheckResult.TypeCheckFailure(msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we simplify this to case fail => fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's a good idea

@JoshRosen
Copy link
Contributor

I've started writing a very basic fuzz-testing suite to check that expression code generation does not fail if an expression is initialized with NullType-d expressions as children and passes type checks after type coercion is applied: master...JoshRosen:fuzz-test

Running that suite against this patch shows that it fixes 9 of my test's failures. I wouldn't read too much into this for now, since my suite needs some work to be more useful, but just thought I'd share since it's a neat testing technique and uncovered a few bugs that I had previously found via other methods (such as sum(null) with a null literal).

@JoshRosen
Copy link
Contributor

It's worth noting that a bunch of the errors in that fuzzing suite are caused by the fact that we skip type checks for certain internal expressions, such as UnscaledValue or AddItemToSet. Is there a good reason why we shouldn't add type checking to these expressions, if only to act as an internal sanity check?

@rxin
Copy link
Contributor Author

rxin commented Jul 12, 2015

Those two expressions should / will just go away.

*
* 1. The string representation is "x symbol y", rather than "funcName(x, y)".
* 2. Two inputs are expected to the be same type. If the two inputs have different types,
* the analyzer will find the tightest common type and do the proper type casting.
*/
abstract class BinaryOperator extends BinaryExpression {
self: Product =>

def symbol: String
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we remove this function if we removed the function toString. Let the subclass define the symbol as needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's a mistake actually. i'm adding tostirng back

@@ -48,6 +49,9 @@ case class UnaryMinus(child: Expression) extends UnaryArithmetic {
case class UnaryPositive(child: Expression) extends UnaryArithmetic {
override def prettyName: String = "positive"

override def checkInputDataTypes(): TypeCheckResult =
TypeUtils.checkForNumericExpr(child.dataType, "operator -")
Copy link
Contributor

Choose a reason for hiding this comment

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

should be "operator +"?

@SparkQA
Copy link

SparkQA commented Jul 14, 2015

Test build #37202 has finished for PR 7348 at commit e4727cc.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • case class And(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • case class Or(left: Expression, right: Expression) extends BinaryOperator with Predicate

@rxin rxin changed the title [SPARK-8993][SQL] [WIP] Leverage ExpectsInputTypes in as many expressions as possible [SPARK-8993][SQL] More comprehensive type checking in expressions. Jul 14, 2015
* Types that can be used in bitwise operations.
*/
val Bitwise = TypeCollection(
BooleanType,
Copy link
Contributor

Choose a reason for hiding this comment

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

Does boolean support bitwise?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does boolean support bitwise operations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

@SparkQA
Copy link

SparkQA commented Jul 14, 2015

Test build #37210 has finished for PR 7348 at commit 4932d57.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • trait ImplicitCastInputTypes extends ExpectsInputTypes
    • abstract class BinaryOperator extends BinaryExpression with ExpectsInputTypes
    • case class UnaryMinus(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class UnaryPositive(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Abs(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class BitwiseNot(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Factorial(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Hex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Unhex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Md5(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Sha1(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Crc32(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Not(child: Expression)
    • case class And(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • case class Or(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • trait StringRegexExpression extends ImplicitCastInputTypes
    • trait String2StringExpression extends ImplicitCastInputTypes
    • trait StringComparison extends ImplicitCastInputTypes
    • case class StringSpace(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class StringLength(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Ascii(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Base64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class UnBase64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes

@rxin
Copy link
Contributor Author

rxin commented Jul 14, 2015

Jenkins, retest this please.

@SparkQA
Copy link

SparkQA commented Jul 14, 2015

Test build #37248 has finished for PR 7348 at commit 4932d57.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • trait ImplicitCastInputTypes extends ExpectsInputTypes
    • abstract class BinaryOperator extends BinaryExpression with ExpectsInputTypes
    • case class UnaryMinus(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class UnaryPositive(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Abs(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class BitwiseNot(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Factorial(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Hex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Unhex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Md5(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Sha1(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Crc32(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Not(child: Expression)
    • case class And(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • case class Or(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • trait StringRegexExpression extends ImplicitCastInputTypes
    • trait String2StringExpression extends ImplicitCastInputTypes
    • trait StringComparison extends ImplicitCastInputTypes
    • case class StringSpace(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class StringLength(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Ascii(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Base64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class UnBase64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes

@SparkQA
Copy link

SparkQA commented Jul 14, 2015

Test build #37257 has finished for PR 7348 at commit 2e22330.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • trait ImplicitCastInputTypes extends ExpectsInputTypes
    • abstract class BinaryOperator extends BinaryExpression with ExpectsInputTypes
    • case class UnaryMinus(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class UnaryPositive(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Abs(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class BitwiseNot(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Factorial(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Hex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Unhex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Md5(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Sha1(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Crc32(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Not(child: Expression)
    • case class And(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • case class Or(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • trait StringRegexExpression extends ImplicitCastInputTypes
    • trait String2StringExpression extends ImplicitCastInputTypes
    • trait StringComparison extends ImplicitCastInputTypes
    • case class StringSpace(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class StringLength(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Ascii(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Base64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class UnBase64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes

@SparkQA
Copy link

SparkQA commented Jul 14, 2015

Test build #37273 has finished for PR 7348 at commit fb66657.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • trait ImplicitCastInputTypes extends ExpectsInputTypes
    • abstract class BinaryOperator extends BinaryExpression with ExpectsInputTypes
    • case class UnaryMinus(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class UnaryPositive(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Abs(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class BitwiseNot(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Factorial(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Hex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Unhex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Md5(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Sha1(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Crc32(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Not(child: Expression)
    • case class And(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • case class Or(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • trait StringRegexExpression extends ImplicitCastInputTypes
    • trait String2StringExpression extends ImplicitCastInputTypes
    • trait StringComparison extends ImplicitCastInputTypes
    • case class StringSpace(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class StringLength(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Ascii(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Base64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class UnBase64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes

@SparkQA
Copy link

SparkQA commented Jul 15, 2015

Test build #37280 has finished for PR 7348 at commit 360d124.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • trait ImplicitCastInputTypes extends ExpectsInputTypes
    • abstract class BinaryOperator extends BinaryExpression with ExpectsInputTypes
    • case class UnaryMinus(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class UnaryPositive(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Abs(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class BitwiseNot(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Factorial(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Hex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Unhex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Md5(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Sha1(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Crc32(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Not(child: Expression)
    • case class And(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • case class Or(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • trait StringRegexExpression extends ImplicitCastInputTypes
    • trait String2StringExpression extends ImplicitCastInputTypes
    • trait StringComparison extends ImplicitCastInputTypes
    • case class StringSpace(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class StringLength(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Ascii(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Base64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class UnBase64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes

@SparkQA
Copy link

SparkQA commented Jul 15, 2015

Test build #37294 has finished for PR 7348 at commit 438ea07.

  • This patch fails Scala style tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • trait ImplicitCastInputTypes extends ExpectsInputTypes
    • abstract class BinaryOperator extends BinaryExpression with ExpectsInputTypes
    • case class UnaryMinus(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class UnaryPositive(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Abs(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class BitwiseNot(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Factorial(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Hex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Unhex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Md5(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Sha1(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Crc32(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Not(child: Expression)
    • case class And(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • case class Or(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • trait StringRegexExpression extends ImplicitCastInputTypes
    • trait String2StringExpression extends ImplicitCastInputTypes
    • trait StringComparison extends ImplicitCastInputTypes
    • case class StringSpace(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class StringLength(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Ascii(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Base64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class UnBase64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes

@SparkQA
Copy link

SparkQA commented Jul 15, 2015

Test build #37296 has finished for PR 7348 at commit 3bb63e7.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • trait ImplicitCastInputTypes extends ExpectsInputTypes
    • abstract class BinaryOperator extends BinaryExpression with ExpectsInputTypes
    • case class UnaryMinus(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class UnaryPositive(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Abs(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class BitwiseNot(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Factorial(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Hex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Unhex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Md5(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Sha1(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Crc32(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Not(child: Expression)
    • case class And(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • case class Or(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • trait StringRegexExpression extends ImplicitCastInputTypes
    • trait String2StringExpression extends ImplicitCastInputTypes
    • trait StringComparison extends ImplicitCastInputTypes
    • case class StringSpace(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class StringLength(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Ascii(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Base64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class UnBase64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes

@SparkQA
Copy link

SparkQA commented Jul 15, 2015

Test build #37302 has finished for PR 7348 at commit 8fcf814.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • trait ImplicitCastInputTypes extends ExpectsInputTypes
    • abstract class BinaryOperator extends BinaryExpression with ExpectsInputTypes
    • case class UnaryMinus(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class UnaryPositive(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Abs(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class BitwiseNot(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Factorial(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Hex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Unhex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Md5(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Sha1(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Crc32(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Not(child: Expression)
    • case class And(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • case class Or(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • trait StringRegexExpression extends ImplicitCastInputTypes
    • trait String2StringExpression extends ImplicitCastInputTypes
    • trait StringComparison extends ImplicitCastInputTypes
    • case class StringSpace(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class StringLength(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Ascii(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Base64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class UnBase64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes

@rxin
Copy link
Contributor Author

rxin commented Jul 15, 2015

Jenkins, retest this please.

@rxin
Copy link
Contributor Author

rxin commented Jul 15, 2015

The test failure looks unrelated. I'm going to merge this and fix any problems later, since it changes a lot of code.

@rxin
Copy link
Contributor Author

rxin commented Jul 15, 2015

@cloud-fan can you review this and help me fix the ignored test cases? Thanks.

@asfgit asfgit closed this in f23a721 Jul 15, 2015
val children: Seq[Expression] = e.children.zip(e.inputTypes).map { case (in, expected) =>
if (in.dataType == NullType && !expected.acceptsType(NullType)) {
Cast(in, expected.defaultConcreteType)
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if expected.acceptsType(in.dateType) == false, probably we'd better to raise a TypeChecking exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that happens during CheckAnalysis when we report errors.

@SparkQA
Copy link

SparkQA commented Jul 15, 2015

Test build #37320 has finished for PR 7348 at commit 8fcf814.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
    • trait ImplicitCastInputTypes extends ExpectsInputTypes
    • abstract class BinaryOperator extends BinaryExpression with ExpectsInputTypes
    • case class UnaryMinus(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class UnaryPositive(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Abs(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class BitwiseNot(child: Expression) extends UnaryExpression with ExpectsInputTypes
    • case class Factorial(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Hex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Unhex(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Md5(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Sha1(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Crc32(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Not(child: Expression)
    • case class And(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • case class Or(left: Expression, right: Expression) extends BinaryOperator with Predicate
    • trait StringRegexExpression extends ImplicitCastInputTypes
    • trait String2StringExpression extends ImplicitCastInputTypes
    • trait StringComparison extends ImplicitCastInputTypes
    • case class StringSpace(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class StringLength(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Ascii(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class Base64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes
    • case class UnBase64(child: Expression) extends UnaryExpression with ImplicitCastInputTypes

asfgit pushed a commit that referenced this pull request Jul 16, 2015
based on #7348

Author: Wenchen Fan <cloud0fan@outlook.com>

Closes #7420 from cloud-fan/type-check and squashes the following commits:

7633fa9 [Wenchen Fan] revert
fe169b0 [Wenchen Fan] improve test
03b70da [Wenchen Fan] enhance implicit type cast
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants