Skip to content

Commit

Permalink
it works
Browse files Browse the repository at this point in the history
  • Loading branch information
alrocar committed Oct 2, 2024
1 parent db85709 commit cf66be5
Show file tree
Hide file tree
Showing 2 changed files with 170 additions and 0 deletions.
143 changes: 143 additions & 0 deletions tests/expected/functions.out
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,149 @@ SELECT uniq_exact(a) FILTER(WHERE b>1) FROM t1;
1
(1 row)

EXPLAIN (VERBOSE, COSTS OFF) SELECT c as d1 FROM t1 WHERE c >= to_timestamp('2019-01-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US') GROUP BY d1 ORDER BY d1;
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan
Output: c
Relations: Aggregate on (t1)
Remote SQL: SELECT c FROM regression.t1 WHERE ((c >= parseDateTimeBestEffortOrNull('2019-01-01 00:00:00.000000'))) GROUP BY c ORDER BY c ASC
(4 rows)

SELECT c as d1 FROM t1 WHERE c >= to_timestamp('2019-01-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US') GROUP BY d1 ORDER BY d1;
d1
---------------------
2019-01-01 10:00:00
2019-01-02 10:00:00
(2 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('dAy', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan
Output: (date_trunc('dAy'::text, (c AT TIME ZONE 'UTC'::text)))
Relations: Aggregate on (t1)
Remote SQL: SELECT toStartOfDay(toTimeZone(c, 'UTC')) FROM regression.t1 GROUP BY (toStartOfDay(toTimeZone(c, 'UTC'))) ORDER BY toStartOfDay(toTimeZone(c, 'UTC')) ASC
(4 rows)

SELECT date_trunc('day', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
d1
------------------------
2019-01-01 00:00:00-08
2019-01-02 00:00:00-08
(2 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('day', c at time zone 'UTC') as d1 FROM t2 GROUP BY d1 ORDER BY d1;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan
Output: (date_trunc('day'::text, (c AT TIME ZONE 'UTC'::text)))
Relations: Aggregate on (t2)
Remote SQL: SELECT toStartOfDay(toTimeZone(c, 'UTC')) FROM regression.t1 GROUP BY (toStartOfDay(toTimeZone(c, 'UTC'))) ORDER BY toStartOfDay(toTimeZone(c, 'UTC')) ASC
(4 rows)

SELECT date_trunc('day', c at time zone 'UTC') as d1 FROM t2 GROUP BY d1 ORDER BY d1;
d1
---------------------
2019-01-01 00:00:00
2019-01-02 00:00:00
(2 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_part('day'::text, timezone('UTC'::text, c)) as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan
Output: (date_part('day'::text, timezone('UTC'::text, c)))
Relations: Aggregate on (t1)
Remote SQL: SELECT toDayOfMonth(toTimeZone(c, 'UTC')) FROM regression.t1 GROUP BY (toDayOfMonth(toTimeZone(c, 'UTC'))) ORDER BY toDayOfMonth(toTimeZone(c, 'UTC')) ASC
(4 rows)

SELECT date_part('day'::text, timezone('UTC'::text, c)) as d1 FROM t1 GROUP BY d1 ORDER BY d1;
d1
----
1
2
(2 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_part('day'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan
Output: (date_part('day'::text, timezone('UTC'::text, c)))
Relations: Aggregate on (t2)
Remote SQL: SELECT toDayOfMonth(toTimeZone(c, 'UTC')) FROM regression.t1 GROUP BY (toDayOfMonth(toTimeZone(c, 'UTC'))) ORDER BY toDayOfMonth(toTimeZone(c, 'UTC')) ASC
(4 rows)

SELECT date_part('day'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;
d1
----
1
2
(2 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_part('doy'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan
Output: (date_part('doy'::text, timezone('UTC'::text, c)))
Relations: Aggregate on (t2)
Remote SQL: SELECT toDayOfYear(toTimeZone(c, 'UTC')) FROM regression.t1 GROUP BY (toDayOfYear(toTimeZone(c, 'UTC'))) ORDER BY toDayOfYear(toTimeZone(c, 'UTC')) ASC
(4 rows)

SELECT date_part('doy'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;
d1
----
1
2
(2 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_part('dow'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan
Output: (date_part('dow'::text, timezone('UTC'::text, c)))
Relations: Aggregate on (t2)
Remote SQL: SELECT toDayOfWeek(toTimeZone(c, 'UTC')) FROM regression.t1 GROUP BY (toDayOfWeek(toTimeZone(c, 'UTC'))) ORDER BY toDayOfWeek(toTimeZone(c, 'UTC')) ASC
(4 rows)

SELECT date_part('dow'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;
d1
----
2
3
(2 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_part('minuTe'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan
Output: (date_part('minuTe'::text, timezone('UTC'::text, c)))
Relations: Aggregate on (t2)
Remote SQL: SELECT toMinute(toTimeZone(c, 'UTC')) FROM regression.t1 GROUP BY (toMinute(toTimeZone(c, 'UTC'))) ORDER BY toMinute(toTimeZone(c, 'UTC')) ASC
(4 rows)

SELECT date_part('minuTe'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;
d1
----
0
(1 row)

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('SeCond', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Foreign Scan
Output: (date_trunc('SeCond'::text, (c AT TIME ZONE 'UTC'::text)))
Relations: Aggregate on (t1)
Remote SQL: SELECT toStartOfSecond(toDateTime64(toTimeZone(c, 'UTC'), 1, 'UTC')) FROM regression.t1 GROUP BY (toStartOfSecond(toDateTime64(toTimeZone(c, 'UTC'), 1, 'UTC'))) ORDER BY toStartOfSecond(toDateTime64(toTimeZone(c, 'UTC'), 1, 'UTC')) ASC
(4 rows)

SELECT date_trunc('SeCond', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
d1
------------------------
2019-01-01 10:00:00-08
2019-01-02 10:00:00-08
(2 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_part('ePoch'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
27 changes: 27 additions & 0 deletions tests/sql/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,33 @@ SELECT uniq_exact(a) FROM t1;
EXPLAIN (VERBOSE, COSTS OFF) SELECT uniq_exact(a) FILTER(WHERE b>1) FROM t1;
SELECT uniq_exact(a) FILTER(WHERE b>1) FROM t1;

EXPLAIN (VERBOSE, COSTS OFF) SELECT c as d1 FROM t1 WHERE c >= to_timestamp('2019-01-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US') GROUP BY d1 ORDER BY d1;
SELECT c as d1 FROM t1 WHERE c >= to_timestamp('2019-01-01 00:00:00.000000', 'YYYY-MM-DD HH24:MI:SS.US') GROUP BY d1 ORDER BY d1;

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('dAy', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
SELECT date_trunc('day', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('day', c at time zone 'UTC') as d1 FROM t2 GROUP BY d1 ORDER BY d1;
SELECT date_trunc('day', c at time zone 'UTC') as d1 FROM t2 GROUP BY d1 ORDER BY d1;

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_part('day'::text, timezone('UTC'::text, c)) as d1 FROM t1 GROUP BY d1 ORDER BY d1;
SELECT date_part('day'::text, timezone('UTC'::text, c)) as d1 FROM t1 GROUP BY d1 ORDER BY d1;

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_part('day'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;
SELECT date_part('day'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_part('doy'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;
SELECT date_part('doy'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_part('dow'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;
SELECT date_part('dow'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_part('minuTe'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;
SELECT date_part('minuTe'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_trunc('SeCond', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;
SELECT date_trunc('SeCond', c at time zone 'UTC') as d1 FROM t1 GROUP BY d1 ORDER BY d1;

EXPLAIN (VERBOSE, COSTS OFF) SELECT date_part('ePoch'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;
SELECT date_part('ePoch'::text, timezone('UTC'::text, c)) as d1 FROM t2 GROUP BY d1 ORDER BY d1;

Expand Down

0 comments on commit cf66be5

Please sign in to comment.