Skip to content

Commit

Permalink
[FLINK-6846] [table] Deprecate quarter() in Table API
Browse files Browse the repository at this point in the history
  • Loading branch information
twalthr committed Aug 2, 2018
1 parent 6aaf5ed commit 94ca19e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 32 deletions.
26 changes: 2 additions & 24 deletions docs/dev/table/tableApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -2783,7 +2783,7 @@ TEMPORAL.extract(TIMEINTERVALUNIT)
{% endhighlight %}
</td>
<td>
<p>Extracts parts of a time point or time interval. Returns the part as a long value. E.g. <code>'2006-06-05'.toDate.extract(DAY)</code> leads to 5.</p>
<p>Extracts parts of a time point or time interval. Returns the part as a long value. E.g. <code>'2006-06-05'.toDate.extract(DAY)</code> leads to 5 or <code>'2006-06-05'.toDate.extract(QUARTER)</code> leads to 2.</p>
</td>
</tr>

Expand All @@ -2809,17 +2809,6 @@ TIMEPOINT.ceil(TIMEINTERVALUNIT)
</td>
</tr>

<tr>
<td>
{% highlight java %}
DATE.quarter()
{% endhighlight %}
</td>
<td>
<p>Returns the quarter of a year from a SQL date. E.g. <code>'1994-09-27'.toDate.quarter()</code> leads to 3.</p>
</td>
</tr>

<tr>
<td>
{% highlight java %}
Expand Down Expand Up @@ -4311,7 +4300,7 @@ TEMPORAL.extract(TimeIntervalUnit)
{% endhighlight %}
</td>
<td>
<p>Extracts parts of a time point or time interval. Returns the part as a long value. E.g. <code>"2006-06-05".toDate.extract(TimeIntervalUnit.DAY)</code> leads to 5.</p>
<p>Extracts parts of a time point or time interval. Returns the part as a long value. E.g. <code>"2006-06-05".toDate.extract(TimeIntervalUnit.DAY)</code> leads to 5 or <code>'2006-06-05'.toDate.extract(QUARTER)</code> leads to 2.</p>
</td>
</tr>

Expand All @@ -4337,17 +4326,6 @@ TIMEPOINT.ceil(TimeIntervalUnit)
</td>
</tr>

<tr>
<td>
{% highlight scala %}
DATE.quarter()
{% endhighlight %}
</td>
<td>
<p>Returns the quarter of a year from a SQL date. E.g. <code>"1994-09-27".toDate.quarter()</code> leads to 3.</p>
</td>
</tr>

<tr>
<td>
{% highlight scala %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,11 @@ trait ImplicitExpressionOperations {
* Returns the quarter of a year from a SQL date.
*
* e.g. "1994-09-27".toDate.quarter() leads to 3
*
* @deprecated This method will be used for describing an interval of months in future versions.
* Use `extract(TimeIntervalUnit.QUARTER)` instead.
*/
@deprecated
def quarter() = Quarter(expr)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ object TimeIntervalUnit extends TableSymbols {
val YEAR = Value(TimeUnitRange.YEAR)
val YEAR_TO_MONTH = Value(TimeUnitRange.YEAR_TO_MONTH)
val MONTH = Value(TimeUnitRange.MONTH)
val QUARTER = Value(TimeUnitRange.QUARTER)
val DAY = Value(TimeUnitRange.DAY)
val DAY_TO_HOUR = Value(TimeUnitRange.DAY_TO_HOUR)
val DAY_TO_MINUTE = Value(TimeUnitRange.DAY_TO_MINUTE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ case class Extract(timeIntervalUnit: Expression, temporal: Expression) extends E
timeIntervalUnit match {
case SymbolExpression(TimeIntervalUnit.YEAR)
| SymbolExpression(TimeIntervalUnit.MONTH)
| SymbolExpression(TimeIntervalUnit.QUARTER)
| SymbolExpression(TimeIntervalUnit.DAY)
if temporal.resultType == SqlTimeTypeInfo.DATE
|| temporal.resultType == SqlTimeTypeInfo.TIMESTAMP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,18 @@ class ScalarFunctionsTest extends ScalarTypesTestBase {
"EXTRACT(YEAR FROM f20)",
"2")

testAllApis(
'f18.extract(TimeIntervalUnit.QUARTER),
"f18.extract(QUARTER)",
"EXTRACT(QUARTER FROM f18)",
"4")

testAllApis(
'f16.extract(TimeIntervalUnit.QUARTER),
"f16.extract(QUARTER)",
"EXTRACT(QUARTER FROM f16)",
"4")

// test SQL only time units
testSqlApi(
"EXTRACT(MILLENNIUM FROM f18)",
Expand Down Expand Up @@ -1577,14 +1589,6 @@ class ScalarFunctionsTest extends ScalarTypesTestBase {
"EXTRACT(DOW FROM f16)",
"1")

testSqlApi(
"EXTRACT(QUARTER FROM f18)",
"4")

testSqlApi(
"EXTRACT(QUARTER FROM f16)",
"4")

testSqlApi(
"EXTRACT(WEEK FROM f18)",
"45")
Expand Down

0 comments on commit 94ca19e

Please sign in to comment.