n3nash commented on a change in pull request #2417:
URL: https://github.com/apache/hudi/pull/2417#discussion_r554525498



##########
File path: 
hudi-common/src/test/java/org/apache/hudi/metadata/TestFileSystemBackedTableMetadata.java
##########
@@ -0,0 +1,181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hudi.metadata;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hudi.common.config.SerializableConfiguration;
+import org.apache.hudi.common.engine.HoodieLocalEngineContext;
+import org.apache.hudi.common.fs.FSUtils;
+import org.apache.hudi.common.model.HoodiePartitionMetadata;
+import org.apache.hudi.common.testutils.FileCreateUtils;
+import org.apache.hudi.common.testutils.HoodieCommonTestHarness;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+public class TestFileSystemBackedTableMetadata extends HoodieCommonTestHarness 
{
+
+  private static final int NUM_FILE_IDS_PER_PARTITION = 10;
+
+  private static String TEST_WRITE_TOKEN = "1-0-1";
+
+  private final List<String> DATE_PARTITIONS = Arrays.asList("2019/01/01", 
"2020/01/02", "2021/03/01");
+  private final List<String> ONE_LEVEL_PARTITIONS = Arrays.asList("2019", 
"2020", "2021");
+  private final List<String> MULTI_LEVEL_PARTITIONS = Arrays.asList("2019/01", 
"2020/01", "2021/01");
+  private final List<String> fileIdsPerPartition =
+      IntStream.range(0, NUM_FILE_IDS_PER_PARTITION).mapToObj(x -> 
UUID.randomUUID().toString()).collect(Collectors.toList());
+
+  @BeforeEach
+  public void setUp() throws IOException {
+    initMetaClient();
+  }
+
+  @AfterEach
+  public void tearDown() throws IOException {
+    metaClient.getFs().delete(new Path(metaClient.getBasePath()), true);
+  }
+
+  /**
+   * Test non partition hoodie table
+   * @throws IOException
+   */
+  @Test
+  public void testNonPartitionedTable() throws IOException {
+    // Generate 10 files under basepath
+    String instant = "100";
+    createDataFiles(basePath, instant);
+    FileCreateUtils.createCommit(basePath, instant);
+    HoodieLocalEngineContext localEngineContext = new 
HoodieLocalEngineContext(metaClient.getHadoopConf());
+    FileSystemBackedTableMetadata fileSystemBackedTableMetadata =
+        new FileSystemBackedTableMetadata(localEngineContext, new 
SerializableConfiguration(metaClient.getHadoopConf()), basePath, false);
+    
Assertions.assertTrue(fileSystemBackedTableMetadata.getAllPartitionPaths().size()
 == 0);
+    
Assertions.assertTrue(fileSystemBackedTableMetadata.getAllFilesInPartition(new 
Path(basePath)).length == 10);
+  }
+
+  /**
+   * Test listing of partitions result for date based partitions
+   * @throws IOException
+   */
+  @Test
+  public void testDatePartitionedTable() throws IOException {
+    String instant = "100";
+    // Generate 10 files under each partition
+    DATE_PARTITIONS.stream().map(p -> createPartition(p, false))

Review comment:
       @vinothchandar Does assumeDatePartitoning=true assume that all 
partitions are hoodie partitions (skips check for .hoodie_partition_metadata) ?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to