5050public class TestClpPushDown
5151{
5252 private static final String TABLE_NAME = "test_pushdown" ;
53- private static final Long TEST_TS_SECONDS = 1746003005L ;
54- private static final Long TEST_TS_NANOSECONDS = 1746003005000000000L ;
53+ private static final Long TEST_TS_SECONDS_LOWER_BOUND = 1746003005L ;
54+ private static final Long TEST_TS_NANOSECONDS_LOWER_BOUND = 1746003005000000000L ;
55+ private static final Long TEST_TS_SECONDS_UPPER_BOUND = 1746003015L ;
56+ private static final Long TEST_TS_NANOSECONDS_UPPER_BOUND = 1746003015000000000L ;
5557
5658 private ClpMockMetadataDatabase mockMetadataDatabase ;
5759 private DistributedQueryRunner queryRunner ;
5860 private QueryManager queryManager ;
5961 private DispatchManager dispatchManager ;
6062
6163 @ BeforeMethod
62- public void setUp () throws Exception {
64+ public void setUp ()
65+ throws Exception
66+ {
6367 mockMetadataDatabase = ClpMockMetadataDatabase
6468 .builder ()
6569 .build ();
@@ -98,7 +102,9 @@ public void setUp() throws Exception {
98102 }
99103
100104 @ AfterMethod
101- public void tearDown () throws InterruptedException {
105+ public void tearDown ()
106+ throws InterruptedException
107+ {
102108 long maxCleanUpTime = 5 * 1000L ; // 5 seconds
103109 long currentCleanUpTime = 0L ;
104110 while (!queryManager .getQueries ().isEmpty () && currentCleanUpTime < maxCleanUpTime ) {
@@ -112,23 +118,31 @@ public void tearDown() throws InterruptedException {
112118
113119 public void testTimestampComparisons ()
114120 {
115- testPushDown (format ("ts > from_unixtime(%s)" , TEST_TS_SECONDS ), format ("ts > %s" , TEST_TS_NANOSECONDS ));
116- testPushDown (format ("ts >= from_unixtime(%s)" , TEST_TS_SECONDS ), format ("ts >= %s" , TEST_TS_NANOSECONDS ));
117- testPushDown (format ("ts < from_unixtime(%s)" , TEST_TS_SECONDS ), format ("ts < %s" , TEST_TS_NANOSECONDS ));
118- testPushDown (format ("ts <= from_unixtime(%s)" , TEST_TS_SECONDS ), format ("ts <= %s" , TEST_TS_NANOSECONDS ));
119- testPushDown (format ("ts = from_unixtime(%s)" , TEST_TS_SECONDS ), format ("ts: %s" , TEST_TS_NANOSECONDS ));
120- testPushDown (format ("ts != from_unixtime(%s)" , TEST_TS_SECONDS ), format ("NOT ts: %s" , TEST_TS_NANOSECONDS ));
121- testPushDown (format ("ts <> from_unixtime(%s)" , TEST_TS_SECONDS ), format ("NOT ts: %s" , TEST_TS_NANOSECONDS ));
122- testPushDown (format ("from_unixtime(%s) < ts" , TEST_TS_SECONDS ), format ("ts > %s" , TEST_TS_NANOSECONDS ));
123- testPushDown (format ("from_unixtime(%s) <= ts" , TEST_TS_SECONDS ), format ("ts >= %s" , TEST_TS_NANOSECONDS ));
124- testPushDown (format ("from_unixtime(%s) > ts" , TEST_TS_SECONDS ), format ("ts < %s" , TEST_TS_NANOSECONDS ));
125- testPushDown (format ("from_unixtime(%s) >= ts" , TEST_TS_SECONDS ), format ("ts <= %s" , TEST_TS_NANOSECONDS ));
126- testPushDown (format ("from_unixtime(%s) = ts" , TEST_TS_SECONDS ), format ("ts: %s" , TEST_TS_NANOSECONDS ));
127- testPushDown (format ("from_unixtime(%s) != ts" , TEST_TS_SECONDS ), format ("NOT ts: %s" , TEST_TS_NANOSECONDS ));
128- testPushDown (format ("from_unixtime(%s) <> ts" , TEST_TS_SECONDS ), format ("NOT ts: %s" , TEST_TS_NANOSECONDS ));
121+ // Test logical binary
122+ testPushDown (format ("ts > from_unixtime(%s)" , TEST_TS_SECONDS_LOWER_BOUND ), format ("ts > %s" , TEST_TS_NANOSECONDS_LOWER_BOUND ));
123+ testPushDown (format ("ts >= from_unixtime(%s)" , TEST_TS_SECONDS_LOWER_BOUND ), format ("ts >= %s" , TEST_TS_NANOSECONDS_LOWER_BOUND ));
124+ testPushDown (format ("ts < from_unixtime(%s)" , TEST_TS_SECONDS_LOWER_BOUND ), format ("ts < %s" , TEST_TS_NANOSECONDS_LOWER_BOUND ));
125+ testPushDown (format ("ts <= from_unixtime(%s)" , TEST_TS_SECONDS_LOWER_BOUND ), format ("ts <= %s" , TEST_TS_NANOSECONDS_LOWER_BOUND ));
126+ testPushDown (format ("ts = from_unixtime(%s)" , TEST_TS_SECONDS_LOWER_BOUND ), format ("ts: %s" , TEST_TS_NANOSECONDS_LOWER_BOUND ));
127+ testPushDown (format ("ts != from_unixtime(%s)" , TEST_TS_SECONDS_LOWER_BOUND ), format ("NOT ts: %s" , TEST_TS_NANOSECONDS_LOWER_BOUND ));
128+ testPushDown (format ("ts <> from_unixtime(%s)" , TEST_TS_SECONDS_LOWER_BOUND ), format ("NOT ts: %s" , TEST_TS_NANOSECONDS_LOWER_BOUND ));
129+ testPushDown (format ("from_unixtime(%s) < ts" , TEST_TS_SECONDS_LOWER_BOUND ), format ("ts > %s" , TEST_TS_NANOSECONDS_LOWER_BOUND ));
130+ testPushDown (format ("from_unixtime(%s) <= ts" , TEST_TS_SECONDS_LOWER_BOUND ), format ("ts >= %s" , TEST_TS_NANOSECONDS_LOWER_BOUND ));
131+ testPushDown (format ("from_unixtime(%s) > ts" , TEST_TS_SECONDS_LOWER_BOUND ), format ("ts < %s" , TEST_TS_NANOSECONDS_LOWER_BOUND ));
132+ testPushDown (format ("from_unixtime(%s) >= ts" , TEST_TS_SECONDS_LOWER_BOUND ), format ("ts <= %s" , TEST_TS_NANOSECONDS_LOWER_BOUND ));
133+ testPushDown (format ("from_unixtime(%s) = ts" , TEST_TS_SECONDS_LOWER_BOUND ), format ("ts: %s" , TEST_TS_NANOSECONDS_LOWER_BOUND ));
134+ testPushDown (format ("from_unixtime(%s) != ts" , TEST_TS_SECONDS_LOWER_BOUND ), format ("NOT ts: %s" , TEST_TS_NANOSECONDS_LOWER_BOUND ));
135+ testPushDown (format ("from_unixtime(%s) <> ts" , TEST_TS_SECONDS_LOWER_BOUND ), format ("NOT ts: %s" , TEST_TS_NANOSECONDS_LOWER_BOUND ));
136+
137+ // Test BETWEEN
138+ testPushDown (format ("ts >= from_unixtime(%s) AND ts <= from_unixtime(%s)" , TEST_TS_SECONDS_LOWER_BOUND , TEST_TS_SECONDS_UPPER_BOUND ),
139+ format ("ts >= %s AND ts <= %s" , TEST_TS_NANOSECONDS_LOWER_BOUND , TEST_TS_NANOSECONDS_UPPER_BOUND ));
140+ testPushDown (format ("ts BETWEEN from_unixtime(%s) AND from_unixtime(%s)" , TEST_TS_SECONDS_LOWER_BOUND , TEST_TS_SECONDS_UPPER_BOUND ),
141+ format ("ts >= %s AND ts <= %s" , TEST_TS_NANOSECONDS_LOWER_BOUND , TEST_TS_NANOSECONDS_UPPER_BOUND ));
129142 }
130143
131- private void testPushDown (String filter , String expectedPushDown ) {
144+ private void testPushDown (String filter , String expectedPushDown )
145+ {
132146 try {
133147 QueryId id = queryRunner .getCoordinator ().getDispatchManager ().createQueryId ();
134148 @ Language ("SQL" ) String sql = format ("SELECT * FROM clp.default.test_pushdown WHERE %s LIMIT 1" , filter );
@@ -159,7 +173,8 @@ private void testPushDown(String filter, String expectedPushDown) {
159173 }
160174 assertTrue (isPushDownGenerated );
161175 queryManager .cancelQuery (id );
162- } catch (Exception e ) {
176+ }
177+ catch (Exception e ) {
163178 fail (e .getMessage ());
164179 }
165180 }
0 commit comments