-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-21914][SQL][TESTS] Check results of expression examples #25942
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
Changes from all commits
5a80e69
1f52b75
d90a6ae
b0d2d4b
8abbd86
3dbb9cf
9834f04
c60bf69
201863c
6c158d8
3dd25a7
1216b02
4be0acd
4740c8d
3bc35f6
6e68f43
3f1e42c
c30195e
33665b7
2ca354e
4a328bb
dcd9816
41e4d7c
cee6709
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -631,7 +631,7 @@ case class DateFormatClass(left: Expression, right: Expression, timeZoneId: Opti | |||||
| examples = """ | ||||||
| Examples: | ||||||
| > SELECT _FUNC_('2016-04-08', 'yyyy-MM-dd'); | ||||||
| 1460041200 | ||||||
| 1460098800 | ||||||
| """, | ||||||
| since = "1.6.0") | ||||||
| case class ToUnixTimestamp( | ||||||
|
|
@@ -842,7 +842,7 @@ abstract class UnixTime extends ToTimestamp { | |||||
| examples = """ | ||||||
| Examples: | ||||||
| > SELECT _FUNC_(0, 'yyyy-MM-dd HH:mm:ss'); | ||||||
| 1970-01-01 00:00:00 | ||||||
| 1969-12-31 16:00:00 | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, surprising.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And you can change your current time zone to spark-sql> set spark.sql.session.timeZone=UTC;
spark.sql.session.timeZone UTC
spark-sql> SELECT from_unixtime(0, 'yyyy-MM-dd HH:mm:ssXXX');
1970-01-01 00:00:00Z
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ya. The timezone issue will make a failure on different timezone machines.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but the time zone is forcibly set to
|
||||||
| """, | ||||||
| since = "1.5.0") | ||||||
| case class FromUnixTime(sec: Expression, format: Expression, timeZoneId: Option[String] = None) | ||||||
|
|
@@ -1766,10 +1766,10 @@ case class MakeDate(year: Expression, month: Expression, day: Expression) | |||||
| > SELECT _FUNC_(2014, 12, 28, 6, 30, 45.887); | ||||||
| 2014-12-28 06:30:45.887 | ||||||
| > SELECT _FUNC_(2014, 12, 28, 6, 30, 45.887, 'CET'); | ||||||
| 2014-12-28 10:30:45.887 | ||||||
| > SELECT _FUNC_(2019, 6, 30, 23, 59, 60) | ||||||
| 2014-12-27 21:30:45.887 | ||||||
| > SELECT _FUNC_(2019, 6, 30, 23, 59, 60); | ||||||
| 2019-07-01 00:00:00 | ||||||
| > SELECT _FUNC_(2019, 13, 1, 10, 11, 12, 13); | ||||||
| > SELECT _FUNC_(2019, 13, 1, 10, 11, 12, 'PST'); | ||||||
| NULL | ||||||
| > SELECT _FUNC_(null, 7, 22, 15, 30, 0); | ||||||
| NULL | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -96,7 +96,7 @@ abstract class StringRegexExpression extends BinaryExpression | |
| """, | ||
| examples = """ | ||
| Examples: | ||
| > SELECT '%SystemDrive%\Users\John' _FUNC_ '\%SystemDrive\%\\Users%' | ||
| > SELECT '%SystemDrive%\Users\John' _FUNC_ '\%SystemDrive\%\Users%'; | ||
| true | ||
| """, | ||
| note = """ | ||
|
|
@@ -153,6 +153,7 @@ case class Like(left: Expression, right: Expression) extends StringRegexExpressi | |
| } | ||
| } | ||
|
|
||
| // scalastyle:off line.contains.tab | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to check tab separators in examples when testing them (I mean we cannot ignore tabs in tests)? I feel a little annoying to add this line...
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you want to modify output of examples and replace tabs by something else? Just in case, we have to do the same while writing new examples, right. So, you cannot just copy-paste output from a terminal as is. If someone doesn't know this, he/she will lose time on troubleshooting test failures. |
||
| @ExpressionDescription( | ||
| usage = "str _FUNC_ regexp - Returns true if `str` matches `regexp`, or false otherwise.", | ||
| arguments = """ | ||
|
|
@@ -170,18 +171,20 @@ case class Like(left: Expression, right: Expression) extends StringRegexExpressi | |
| """, | ||
| examples = """ | ||
| Examples: | ||
| When spark.sql.parser.escapedStringLiterals is disabled (default). | ||
| > SELECT '%SystemDrive%\Users\John' _FUNC_ '%SystemDrive%\\Users.*' | ||
| > SET spark.sql.parser.escapedStringLiterals=true; | ||
| spark.sql.parser.escapedStringLiterals true | ||
| > SELECT '%SystemDrive%\Users\John' _FUNC_ '%SystemDrive%\\Users.*'; | ||
| true | ||
|
|
||
| When spark.sql.parser.escapedStringLiterals is enabled. | ||
| > SELECT '%SystemDrive%\Users\John' _FUNC_ '%SystemDrive%\Users.*' | ||
| > SET spark.sql.parser.escapedStringLiterals=false; | ||
| spark.sql.parser.escapedStringLiterals false | ||
| > SELECT '%SystemDrive%\Users\John' _FUNC_ '%SystemDrive%\Users.*'; | ||
| true | ||
| """, | ||
| note = """ | ||
| Use LIKE to match with simple string pattern. | ||
| """, | ||
| since = "1.0.0") | ||
| // scalastyle:on line.contains.tab | ||
| case class RLike(left: Expression, right: Expression) extends StringRegexExpression { | ||
|
|
||
| override def escape(v: String): String = v | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ur, I know the intention, but this is a revert of
[SPARK-29237][SQL] Prevent real function names in expression example template.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, using of the
_FUNC_template is impossible here because the expression has 2 function names%andmodbut one of the example always causes an error:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought
blacklistingis a better idea for this.And, the blacklisting was in this PR already before, isn't it?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, probably I don't understand you. Do you want to show not working example to users?
For
MOD, the examples (after replacing_FUNC_byMOD) are:Examples: > SELECT 2 MOD 1.8; 0.2 > SELECT MOD(2, 1.8); 0.2where the first one is incorrect.
For
%, both are correct:Examples: > SELECT 2 % 1.8; 0.2 > SELECT MOD(2, 1.8); 0.2Using
_FUNC_for the first example, or for the second one, or for both always produce an incorrect example. For the examples , we cannot use_FUNC_at all.