vvysotskyi commented on a change in pull request #1638: DRILL-7022: Partition 
pruning is not happening the first time after the metadata auto-refresh
URL: https://github.com/apache/drill/pull/1638#discussion_r256941880
 
 

 ##########
 File path: 
exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetMetadataCache.java
 ##########
 @@ -902,6 +902,27 @@ public void testEmptyDirectoryWithMetadataDirFile() 
throws Exception {
             .run();
   }
 
+  @Test
+  public void testAutoRefreshPartitionPruning() throws Exception {
+    test("create table dfs.tmp.`orders` partition by (o_orderstatus) as\n" +
+        "select * from cp.`tpch/orders.parquet`");
+
+    test("refresh table metadata dfs.tmp.`orders`");
+
+    File ordersTable = new File(dirTestWatcher.getDfsTestTmpDir(), "orders");
+
+    // sets last-modified time of directory greater than the time of cache 
file to force metadata cache file auto-refresh
+    assertTrue("Unable to change the last-modified time of table directory",
+        ordersTable.setLastModified(new File(ordersTable, 
Metadata.METADATA_FILENAME).lastModified() + 100500));
+
+    String query = "select * from dfs.tmp.`orders`\n" +
+        "where o_orderstatus = 'O' and o_orderdate < '1995-03-10'";
+    PlanTestBase.testPlanOneExpectedPattern(query, "numRowGroups=1");
+
+    int actualRowCount = testSql(query);
+    assertEquals("Row count does not match the expected value", 1, 
actualRowCount);
 
 Review comment:
   It's a good idea, but tests may run so fast, that modification time won't 
change (there is a bug in `lastModified` method where milliseconds are lost: 
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8177809), so this check 
wouldn't work. Adding `Thread.sleep(1000)` will help, but it will make the test 
much slower. So I leave it as it is.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to