Skip to content
Prev Previous commit
Next Next commit
[SPARK-27931][SQL] add a negative test case for "o"
  • Loading branch information
younggyu chun committed Aug 30, 2019
commit 2ea551c728396881cfb05ed01f6179497bd3ceb5
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,7 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper {
checkCast("off", false)
checkCast("of", false)
Copy link
Member

Choose a reason for hiding this comment

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

@younggyuchun, just for doubly sure, did you double check the behaviours against PostgreSQL?

Copy link
Author

Choose a reason for hiding this comment

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

@HyukjinKwon Here it is:
image

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not documented: https://www.postgresql.org/docs/devel/datatype-boolean.html

Postgres may support of for history reasons, I don't think we have to follow it.

Copy link
Author

Choose a reason for hiding this comment

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

@cloud-fan @dongjoon-hyun @HyukjinKwon
This build accepts several unique prefixes for the boolean data type. For example, tru, tr, ye, fals, fal, fa and of, which are not documented. Do we want to not to accept these prefixes?

Copy link
Member

Choose a reason for hiding this comment

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

@cloud-fan . It's a documented feature in that document. We had better support it.

Unique prefixes of these strings are also accepted, for example t or n. Leading or trailing whitespace is ignored, and case does not matter.

cc @gatorsmile

Copy link
Member

@dongjoon-hyun dongjoon-hyun Aug 30, 2019

Choose a reason for hiding this comment

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

BTW, @younggyuchun . Please add a negative test case.
o is not supported because it's not unique. It's a common prefix for on and off.
It should be null.

Copy link
Member

Choose a reason for hiding this comment

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

Seems okay to me

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM


checkEvaluation(cast("o", BooleanType), null)
Copy link
Author

Choose a reason for hiding this comment

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

@dongjoon-hyun
Add a negative test for "o"

checkEvaluation(cast("abc", BooleanType), null)
checkEvaluation(cast("", BooleanType), null)
}
Expand Down