calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject calcite git commit: [CALCITE-1179] Extend list of time units and time unit ranges (Venki Korukanti)
Date Fri, 22 Apr 2016 21:02:02 GMT
Repository: calcite
Updated Branches:
  refs/heads/master 62f9abae4 -> 26a645890


[CALCITE-1179] Extend list of time units and time unit ranges (Venki Korukanti)

The purpose of this commit is to allow more time units in Calcite's
EXTRACT function. This commit covers only Avatica changes.
[CALCITE-1177] will make the corresponding Calcite changes after the next
Avatica release.


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/26a64589
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/26a64589
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/26a64589

Branch: refs/heads/master
Commit: 26a6458903cd13d2a541b59042d178e8177705a9
Parents: 62f9aba
Author: vkorukanti <venki@dremio.com>
Authored: Tue Mar 29 17:41:18 2016 -0700
Committer: Julian Hyde <jhyde@apache.org>
Committed: Fri Apr 22 14:00:21 2016 -0700

----------------------------------------------------------------------
 .../org/apache/calcite/avatica/util/TimeUnit.java  | 17 ++++++++++++-----
 .../apache/calcite/avatica/util/TimeUnitRange.java |  8 +++++++-
 2 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/26a64589/avatica/core/src/main/java/org/apache/calcite/avatica/util/TimeUnit.java
----------------------------------------------------------------------
diff --git a/avatica/core/src/main/java/org/apache/calcite/avatica/util/TimeUnit.java b/avatica/core/src/main/java/org/apache/calcite/avatica/util/TimeUnit.java
index 574aa45..251c4cf 100644
--- a/avatica/core/src/main/java/org/apache/calcite/avatica/util/TimeUnit.java
+++ b/avatica/core/src/main/java/org/apache/calcite/avatica/util/TimeUnit.java
@@ -25,10 +25,11 @@ import java.math.BigDecimal;
  * {@link #HOUR}, {@link #MINUTE}, {@link #SECOND} can be the unit of a SQL
  * interval.
  *
- * <p>The others ({@link #QUARTER}, {@link #WEEK}, {@link #MILLISECOND} and
- * {@link #MICROSECOND}) are convenient to use it internally, when converting to
- * and from UNIX timestamps. And also may be arguments to the
- * {@code TIMESTAMPADD} and {@code TIMESTAMPDIFF} functions.
+ * <p>The others ({@link #QUARTER}, {@link #WEEK}, {@link #MILLISECOND},
+ * {@link #DOW}, {@link #DOY}, {@link #EPOCH}, {@link #DECADE}, {@link #CENTURY},
+ * {@link #MILLENNIUM} and {@link #MICROSECOND}) are convenient to use internally,
+ * when converting to and from UNIX timestamps. And also may be arguments to the
+ * {@code EXTRACT}, {@code TIMESTAMPADD} and {@code TIMESTAMPDIFF} functions.
  */
 public enum TimeUnit {
   YEAR(true, ' ', BigDecimal.valueOf(12) /* months */, null),
@@ -46,7 +47,13 @@ public enum TimeUnit {
       BigDecimal.valueOf(53)),
   MILLISECOND(false, '.', BigDecimal.ONE, BigDecimal.valueOf(1000)),
   MICROSECOND(false, '.', BigDecimal.ONE.scaleByPowerOfTen(-3),
-      BigDecimal.valueOf(1000000));
+      BigDecimal.valueOf(1000000)),
+  DOW(false, '-', null, null),
+  DOY(false, '-', null, null),
+  EPOCH(false, '*', null, null),
+  DECADE(true, '*', BigDecimal.valueOf(120) /* months */, null),
+  CENTURY(true, '*', BigDecimal.valueOf(1200) /* months */, null),
+  MILLENNIUM(true, '*', BigDecimal.valueOf(12000) /* months */, null);
 
   public final boolean yearMonth;
   public final char separator;

http://git-wip-us.apache.org/repos/asf/calcite/blob/26a64589/avatica/core/src/main/java/org/apache/calcite/avatica/util/TimeUnitRange.java
----------------------------------------------------------------------
diff --git a/avatica/core/src/main/java/org/apache/calcite/avatica/util/TimeUnitRange.java
b/avatica/core/src/main/java/org/apache/calcite/avatica/util/TimeUnitRange.java
index ddfe9f7..42d44dc 100644
--- a/avatica/core/src/main/java/org/apache/calcite/avatica/util/TimeUnitRange.java
+++ b/avatica/core/src/main/java/org/apache/calcite/avatica/util/TimeUnitRange.java
@@ -42,7 +42,13 @@ public enum TimeUnitRange {
   QUARTER(TimeUnit.QUARTER, null),
   WEEK(TimeUnit.WEEK, null),
   MILLISECOND(TimeUnit.MILLISECOND, null),
-  MICROSECOND(TimeUnit.MICROSECOND, null);
+  MICROSECOND(TimeUnit.MICROSECOND, null),
+  DOW(TimeUnit.DOW, null),
+  DOY(TimeUnit.DOY, null),
+  EPOCH(TimeUnit.EPOCH, null),
+  DECADE(TimeUnit.DECADE, null),
+  CENTURY(TimeUnit.CENTURY, null),
+  MILLENNIUM(TimeUnit.MILLENNIUM, null);
 
   public final TimeUnit startUnit;
   public final TimeUnit endUnit;


Mime
View raw message