You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by br...@apache.org on 2019/01/03 19:21:15 UTC
[drill-site] branch asf-site updated: update timestampadd/diff
functions with support version and cast
This is an automated email from the ASF dual-hosted git repository.
bridgetb pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/drill-site.git
The following commit(s) were added to refs/heads/asf-site by this push:
new 4c51336 update timestampadd/diff functions with support version and cast
4c51336 is described below
commit 4c513365a08d488afdb48d84c8b1f22524f1a1ad
Author: Bridget Bevens <bb...@maprtech.com>
AuthorDate: Thu Jan 3 11:20:59 2019 -0800
update timestampadd/diff functions with support version and cast
---
docs/date-time-functions-and-arithmetic/index.html | 26 ++++++++++++++--------
feed.xml | 4 ++--
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/docs/date-time-functions-and-arithmetic/index.html b/docs/date-time-functions-and-arithmetic/index.html
index b6254d2..b5f2a01 100644
--- a/docs/date-time-functions-and-arithmetic/index.html
+++ b/docs/date-time-functions-and-arithmetic/index.html
@@ -1297,7 +1297,7 @@
</div>
- Dec 29, 2018
+ Jan 3, 2019
<link href="/css/docpage.css" rel="stylesheet" type="text/css">
@@ -1366,11 +1366,11 @@
<td>BIGINT</td>
</tr>
<tr>
-<td><a href="/docs/date-time-functions-and-arithmetic/#timestampadd">TIMESTAMPADD</a></td>
+<td><a href="/docs/date-time-functions-and-arithmetic/#timestampadd">TIMESTAMPADD</a>*</td>
<td>Inferred based on unit of time</td>
</tr>
<tr>
-<td><a href="/docs/date-time-functions-and-arithmetic/#timestampdiff">TIMESTAMPDIFF</a></td>
+<td><a href="/docs/date-time-functions-and-arithmetic/#timestampdiff">TIMESTAMPDIFF</a>*</td>
<td>Inferred based on unit of time</td>
</tr>
<tr>
@@ -1379,6 +1379,10 @@
</tr>
</tbody></table>
+<ul>
+<li>Supported in Drill 1.15 and later.</li>
+</ul>
+
<h2 id="age">AGE</h2>
<p>Returns the interval between two timestamps or subtracts a timestamp from midnight of the current date.</p>
@@ -1899,7 +1903,9 @@ SELECT UNIX_TIMESTAMP('2015-05-29 08:18:53.0', 'yyyy-MM-dd HH:mm:ss.
</code></pre></div>
<h2 id="timestampadd">TIMESTAMPADD</h2>
-<p>Adds an interval of time, in the given time units, to a datetime expression. </p>
+<p>Adds an interval of time, in the given time units, to a datetime expression. </p>
+
+<p><strong>Note:</strong> Drill 1.15 and later supports the TIMESTAMPADD function. </p>
<h3 id="timestampadd-syntax">TIMESTAMPADD Syntax</h3>
@@ -1933,14 +1939,14 @@ SELECT UNIX_TIMESTAMP('2015-05-29 08:18:53.0', 'yyyy-MM-dd HH:mm:ss.
+------------------------+
</code></pre></div>
<p>Add a quarter (3 months) to the date values in the first column of the dates.csv file:</p>
-<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT TIMESTAMPADD(QUARTER, 1, COLUMNS[0]) q1 FROM dfs.`/quarter/dates.csv`;
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT TIMESTAMPADD(QUARTER, 1, CAST(COLUMNS[0] as date)) q1 FROM dfs.`/quarter/dates.csv`;
+------------------------+
| q1 |
+------------------------+
| 2018-04-01 00:00:00.0 |
| 2017-05-02 00:00:00.0 |
| 2000-08-06 00:00:00.0 |
-+------------------------+
++------------------------+
</code></pre></div>
<p>Dates in column[0] before applying the TIMESTAMPADD function:</p>
<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT COLUMNS[0] FROM dfs.`/quarter/dates.csv`;
@@ -1954,7 +1960,9 @@ SELECT UNIX_TIMESTAMP('2015-05-29 08:18:53.0', 'yyyy-MM-dd HH:mm:ss.
</code></pre></div>
<h2 id="timestampdiff">TIMESTAMPDIFF</h2>
-<p>Calculates an interval of time, in the given time units, by subtracting <em>datetime_expression1</em> from <em>datetime_expression2</em> (<em>datetime_expression2</em> − <em>datetime_expression1</em>). </p>
+<p>Calculates an interval of time, in the given time units, by subtracting <em>datetime_expression1</em> from <em>datetime_expression2</em> (<em>datetime_expression2</em> − <em>datetime_expression1</em>). </p>
+
+<p><strong>Note:</strong> Drill 1.15 and later supports the TIMESTAMPDIFF function. </p>
<h3 id="timestampdiff-syntax">TIMESTAMPDIFF Syntax</h3>
@@ -1989,7 +1997,7 @@ SELECT UNIX_TIMESTAMP('2015-05-29 08:18:53.0', 'yyyy-MM-dd HH:mm:ss.
+---------+
</code></pre></div>
<p>Subtracts the date literal '1970-01-15' from the dates in the first column of the dates.csv file and returns the difference in seconds: </p>
-<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT TIMESTAMPDIFF(SECOND, DATE '1970-01-15', columns[0]) a from dfs.`/quarter/dates.csv`;
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT TIMESTAMPDIFF(SECOND, DATE '1970-01-15', CAST(COLUMNS[0] as date)) a FROM dfs.`/quarter/dates.csv`
+-------------+
| a |
+-------------+
@@ -1999,7 +2007,7 @@ SELECT UNIX_TIMESTAMP('2015-05-29 08:18:53.0', 'yyyy-MM-dd HH:mm:ss.
+-------------+
</code></pre></div>
<p>Subtracts the date in the third column from the date in the first column (columns[0]-columns[2]) of the dates.csv file and returns the difference in seconds: </p>
-<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT TIMESTAMPDIFF(SECOND, columns[2], columns[0]) a from dfs.`/quarter/dates.csv`;
+<div class="highlight"><pre><code class="language-text" data-lang="text">SELECT TIMESTAMPDIFF(SECOND, CAST(COLUMNS[2] as date), CAST(COLUMNS[0] as date)) a from dfs.`/home/bee/pets.csv`;
+------------+
| a |
+------------+
diff --git a/feed.xml b/feed.xml
index 986caf6..9f29eb5 100644
--- a/feed.xml
+++ b/feed.xml
@@ -6,8 +6,8 @@
</description>
<link>/</link>
<atom:link href="/feed.xml" rel="self" type="application/rss+xml"/>
- <pubDate>Sun, 30 Dec 2018 00:29:20 -0800</pubDate>
- <lastBuildDate>Sun, 30 Dec 2018 00:29:20 -0800</lastBuildDate>
+ <pubDate>Thu, 03 Jan 2019 11:18:45 -0800</pubDate>
+ <lastBuildDate>Thu, 03 Jan 2019 11:18:45 -0800</lastBuildDate>
<generator>Jekyll v2.5.2</generator>
<item>