beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ming...@apache.org
Subject [1/2] beam git commit: [BEAM-2804] support TIMESTAMP in sort
Date Tue, 12 Sep 2017 17:21:32 GMT
Repository: beam
Updated Branches:
  refs/heads/master 001285a88 -> 8e85b6b37


[BEAM-2804] support TIMESTAMP in sort

reuse prepared input for testOrderBy_timestamp() test case


Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/2fa9dd0e
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/2fa9dd0e
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/2fa9dd0e

Branch: refs/heads/master
Commit: 2fa9dd0e7c4ac6e1512d5af89df5c882fe023039
Parents: 001285a
Author: Zang <szang@lm-sea-11001278.corp.ebay.com>
Authored: Mon Sep 11 14:59:52 2017 -0700
Committer: mingmxu <mingmxu@ebay.com>
Committed: Tue Sep 12 10:08:46 2017 -0700

----------------------------------------------------------------------
 .../extensions/sql/impl/rel/BeamSortRel.java    |  1 +
 .../sql/impl/rel/BeamSortRelTest.java           | 41 +++++++++++++++-----
 2 files changed, 32 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/beam/blob/2fa9dd0e/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSortRel.java
----------------------------------------------------------------------
diff --git a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSortRel.java
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSortRel.java
index 6a260bb..99626aa 100644
--- a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSortRel.java
+++ b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSortRel.java
@@ -213,6 +213,7 @@ public class BeamSortRel extends Sort implements BeamRelNode {
             case DOUBLE:
             case VARCHAR:
             case DATE:
+            case TIMESTAMP:
               Comparable v1 = (Comparable) row1.getFieldValue(fieldIndex);
               Comparable v2 = (Comparable) row2.getFieldValue(fieldIndex);
               fieldRet = v1.compareTo(v2);

http://git-wip-us.apache.org/repos/asf/beam/blob/2fa9dd0e/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSortRelTest.java
----------------------------------------------------------------------
diff --git a/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSortRelTest.java
b/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSortRelTest.java
index 19ba0d0..bab5296 100644
--- a/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSortRelTest.java
+++ b/sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamSortRelTest.java
@@ -49,16 +49,16 @@ public class BeamSortRelTest extends BaseRelTest {
             Types.DOUBLE, "price",
             Types.TIMESTAMP, "order_time"
         ).addRows(
-            1L, 2, 1.0, new Date(),
-            1L, 1, 2.0, new Date(),
-            2L, 4, 3.0, new Date(),
-            2L, 1, 4.0, new Date(),
-            5L, 5, 5.0, new Date(),
-            6L, 6, 6.0, new Date(),
-            7L, 7, 7.0, new Date(),
-            8L, 8888, 8.0, new Date(),
-            8L, 999, 9.0, new Date(),
-            10L, 100, 10.0, new Date()
+            1L, 2, 1.0, new Date(0),
+            1L, 1, 2.0, new Date(1),
+            2L, 4, 3.0, new Date(2),
+            2L, 1, 4.0, new Date(3),
+            5L, 5, 5.0, new Date(4),
+            6L, 6, 6.0, new Date(5),
+            7L, 7, 7.0, new Date(6),
+            8L, 8888, 8.0, new Date(7),
+            8L, 999, 9.0, new Date(8),
+            10L, 100, 10.0, new Date(9)
         )
     );
     sqlEnv.registerTable("SUB_ORDER_RAM",
@@ -92,6 +92,27 @@ public class BeamSortRelTest extends BaseRelTest {
   }
 
   @Test
+  public void testOrderBy_timestamp() throws Exception {
+    String sql = "SELECT order_id, site_id, price, order_time "
+        + "FROM ORDER_DETAILS "
+        + "ORDER BY order_time desc limit 4";
+
+    PCollection<BeamRecord> rows = compilePipeline(sql, pipeline, sqlEnv);
+    PAssert.that(rows).containsInAnyOrder(TestUtils.RowsBuilder.of(
+        Types.BIGINT, "order_id",
+        Types.INTEGER, "site_id",
+        Types.DOUBLE, "price",
+        Types.TIMESTAMP, "order_time"
+    ).addRows(
+        7L, 7, 7.0, new Date(6),
+        8L, 8888, 8.0, new Date(7),
+        8L, 999, 9.0, new Date(8),
+        10L, 100, 10.0, new Date(9)
+    ).getRows());
+    pipeline.run().waitUntilFinish();
+  }
+
+  @Test
   public void testOrderBy_nullsFirst() throws Exception {
     sqlEnv.registerTable("ORDER_DETAILS",
         MockedBoundedTable.of(


Mime
View raw message