You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2016/03/17 21:09:28 UTC
[5/6] calcite git commit: In [CALCITE-1124],
I had the sign of TIMESTAMPDIFF wrong
In [CALCITE-1124], I had the sign of TIMESTAMPDIFF wrong
Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/ccb48675
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/ccb48675
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/ccb48675
Branch: refs/heads/master
Commit: ccb4867518bb11cace50cca64bc20aa0a832ce44
Parents: d739a1a
Author: Julian Hyde <jh...@apache.org>
Authored: Thu Mar 10 17:41:25 2016 -0800
Committer: Julian Hyde <jh...@apache.org>
Committed: Thu Mar 17 11:31:47 2016 -0700
----------------------------------------------------------------------
.../apache/calcite/sql2rel/StandardConvertletTable.java | 10 +++++-----
.../org/apache/calcite/sql/test/SqlOperatorBaseTest.java | 4 ++--
site/_docs/reference.md | 4 ++--
3 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/calcite/blob/ccb48675/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java b/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
index 44d6fe5..7fbc5f7 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
@@ -289,9 +289,9 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
registerOp(SqlStdOperatorTable.FLOOR, floorCeilConvertlet);
registerOp(SqlStdOperatorTable.CEIL, floorCeilConvertlet);
- registerOp(SqlStdOperatorTable.TIMESTAMP_ADD,
- new TimestampAddConvertlet());
- registerOp(SqlStdOperatorTable.TIMESTAMP_DIFF, new TimestampDiffConvertlet());
+ registerOp(SqlStdOperatorTable.TIMESTAMP_ADD, new TimestampAddConvertlet());
+ registerOp(SqlStdOperatorTable.TIMESTAMP_DIFF,
+ new TimestampDiffConvertlet());
// Convert "element(<expr>)" to "$element_slice(<expr>)", if the
// expression is a multiset of scalars.
@@ -1364,7 +1364,7 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
private class TimestampDiffConvertlet implements SqlRexConvertlet {
public RexNode convertCall(SqlRexContext cx, SqlCall call) {
// TIMESTAMPDIFF(unit, t1, t2)
- // => (t1 - t2) UNIT
+ // => (t2 - t1) UNIT
final RexBuilder rexBuilder = cx.getRexBuilder();
final SqlLiteral unitLiteral = call.operand(0);
final TimeUnit unit = unitLiteral.symbolValue(TimeUnit.class);
@@ -1375,8 +1375,8 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
return divide(cx.getRexBuilder(),
rexBuilder.makeCast(intType,
rexBuilder.makeCall(SqlStdOperatorTable.MINUS_DATE,
- cx.convertExpression(call.operand(1)),
cx.convertExpression(call.operand(2)),
+ cx.convertExpression(call.operand(1)),
cx.getRexBuilder().makeIntervalLiteral(qualifier))),
unit.multiplier);
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/ccb48675/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
index 1c5ec79..16abb8c 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
@@ -4624,11 +4624,11 @@ public abstract class SqlOperatorBaseTest {
tester.checkScalar("timestampdiff(HOUR, "
+ "timestamp '2016-02-24 12:42:25', "
+ "timestamp '2016-02-24 15:42:25')",
- "-3", "INTEGER NOT NULL");
+ "3", "INTEGER NOT NULL");
tester.checkScalar("timestampdiff(MICROSECOND, "
+ "timestamp '2016-02-24 12:42:25', "
+ "timestamp '2016-02-24 12:42:20')",
- "5000000", "INTEGER NOT NULL");
+ "-5000000", "INTEGER NOT NULL");
if (!INTERVAL) {
return;
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/ccb48675/site/_docs/reference.md
----------------------------------------------------------------------
diff --git a/site/_docs/reference.md b/site/_docs/reference.md
index af05ad2..aabc42f 100644
--- a/site/_docs/reference.md
+++ b/site/_docs/reference.md
@@ -1042,8 +1042,8 @@ Not implemented:
| {fn CURTIME()} | Equivalent to `LOCALTIME`
| {fn NOW()} | Equivalent to `LOCALTIMESTAMP`
| {fn QUARTER(date)} | Equivalent to `EXTRACT(QUARTER FROM date)`. Returns an integer between 1 and 4.
-| {fn TIMESTAMPADD(interval, count, timestamp)} | Adds an interval to a timestamp
-| {fn TIMESTAMPDIFF(interval, timestamp, timestamp)} | Subtracts two timestamps
+| {fn TIMESTAMPADD(timeUnit, count, timestamp)} | Adds an interval of *count* *timeUnit*s to a timestamp
+| {fn TIMESTAMPDIFF(timeUnit, timestamp1, timestamp2)} | Subtracts *timestamp1* from *timestamp2* and returns the result in *timeUnit*s
Not implemented: