alamb commented on code in PR #26332:
URL: https://github.com/apache/datafusion/pull/26332#discussion_r4283337142
##########
datafusion/sqllogictest/test_files/datetime/timestamps.slt:
##########
@@ -1679,122 +1679,121 @@ ORDER BY date_trunc('hour', ts);
562129260 562125600
562129259 562129200
-# Typed bounds from a child function must retain named timezone metadata
-query II
-SELECT
- c,
- arrow_cast(
- date_trunc('hour', from_unixtime(c, 'America/Goose_Bay')),
- 'Int64'
- ) AS truncated
-FROM (
- SELECT column1 AS c
- FROM (
- VALUES
- (562129260::bigint),
- (562129259::bigint)
- )
- ORDER BY c
- LIMIT 2
-)
-ORDER BY date_trunc('hour', from_unixtime(c, 'America/Goose_Bay'));
-----
-562129260 562125600
-562129259 562129200
+# The ordering propagation tests below read from tables declared sorted with
+# `WITH ORDER`, so a plan has no sort at all when the ordering propagates, and
+# exactly the final sort when it must not. Each file is written in its
Review Comment:
❤️
##########
datafusion/sqllogictest/test_files/datetime/timestamps.slt:
##########
@@ -1679,122 +1679,121 @@ ORDER BY date_trunc('hour', ts);
562129260 562125600
562129259 562129200
-# Typed bounds from a child function must retain named timezone metadata
-query II
-SELECT
- c,
- arrow_cast(
- date_trunc('hour', from_unixtime(c, 'America/Goose_Bay')),
- 'Int64'
- ) AS truncated
-FROM (
- SELECT column1 AS c
- FROM (
- VALUES
- (562129260::bigint),
- (562129259::bigint)
- )
- ORDER BY c
- LIMIT 2
-)
-ORDER BY date_trunc('hour', from_unixtime(c, 'America/Goose_Bay'));
-----
-562129260 562125600
-562129259 562129200
+# The ordering propagation tests below read from tables declared sorted with
+# `WITH ORDER`, so a plan has no sort at all when the ordering propagates, and
+# exactly the final sort when it must not. Each file is written in its
+# declared order.
# Typed bounds allow date_trunc to propagate ordering through timezone-free
from_unixtime
+query I
+COPY (VALUES (3600::bigint), (7200::bigint))
+TO 'test_files/scratch/timestamps/ordered_epochs.csv'
+OPTIONS ('format.has_header' 'true');
+----
+2
+
+statement ok
+CREATE EXTERNAL TABLE ordered_epochs (c BIGINT)
+STORED AS CSV
+WITH ORDER (c ASC)
+LOCATION 'test_files/scratch/timestamps/ordered_epochs.csv'
+OPTIONS ('format.has_header' 'true');
+
query TT
EXPLAIN SELECT date_trunc('hour', from_unixtime(c)) AS truncated
-FROM (
- SELECT column1 AS c
- FROM (
- VALUES
- (7200::bigint),
- (3600::bigint)
- )
- ORDER BY c
- LIMIT 2
-)
+FROM ordered_epochs
ORDER BY date_trunc('hour', from_unixtime(c));
----
logical_plan
01)Sort: truncated ASC NULLS LAST
-02)--Projection: date_trunc(Utf8("hour"), from_unixtime(c)) AS truncated
-03)----Sort: c ASC NULLS LAST, fetch=2
-04)------Projection: column1 AS c
-05)--------Values: (Int64(7200)), (Int64(3600))
+02)--Projection: date_trunc(Utf8("hour"), from_unixtime(ordered_epochs.c)) AS
truncated
+03)----TableScan: ordered_epochs projection=[c]
physical_plan
-01)ProjectionExec: expr=[date_trunc(hour, from_unixtime(column1@0)) as
truncated]
-02)--SortExec: TopK(fetch=2), expr=[column1@0 ASC NULLS LAST],
preserve_partitioning=[false]
-03)----DataSourceExec: partitions=1, partition_sizes=[1]
+01)SortPreservingMergeExec: [truncated@0 ASC NULLS LAST]
Review Comment:
👍
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]