[GitHub] [hudi] pengzhiwei2018 commented on a change in pull request #3193: [HUDI-2107] Support Read Log Only MOR Table For Spark

2021-07-09 Thread GitBox


pengzhiwei2018 commented on a change in pull request #3193:
URL: https://github.com/apache/hudi/pull/3193#discussion_r666725674



##
File path: 
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestMergeIntoTable2.scala
##
@@ -0,0 +1,91 @@
+/*
+ * 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.spark.sql.hudi
+
+import org.apache.hudi.testutils.DataSourceTestUtils
+
+class TestMergeIntoTable2 extends TestHoodieSqlBase {

Review comment:
   Yes, I will rename it.




-- 
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: commits-unsubscr...@hudi.apache.org

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




[GitHub] [hudi] pengzhiwei2018 commented on a change in pull request #3193: [HUDI-2107] Support Read Log Only MOR Table For Spark

2021-07-09 Thread GitBox


pengzhiwei2018 commented on a change in pull request #3193:
URL: https://github.com/apache/hudi/pull/3193#discussion_r666725447



##
File path: 
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/hudi/MergeOnReadSnapshotRelation.scala
##
@@ -137,11 +136,14 @@ class MergeOnReadSnapshotRelation(val sqlContext: 
SQLContext,
   }
 
   def buildFileIndex(filters: Array[Filter]): List[HoodieMergeOnReadFileSplit] 
= {
-
-val fileStatuses = if (globPaths.isDefined) {
+// Get all partition paths
+val partitionPaths = if (globPaths.isDefined) {
   // Load files from the global paths if it has defined to be compatible 
with the original mode
   val inMemoryFileIndex = 
HoodieSparkUtils.createInMemoryFileIndex(sqlContext.sparkSession, globPaths.get)
-  inMemoryFileIndex.allFiles()
+  val fsView = new HoodieTableFileSystemView(metaClient,
+metaClient.getActiveTimeline.getCommitsTimeline
+  .filterCompletedInstants, inMemoryFileIndex.allFiles().toArray)
+  
fsView.getLatestBaseFiles.iterator().asScala.toList.map(_.getFileStatus.getPath.getParent)

Review comment:
   Currently we have already support the `non-globalPaths ` query way by 
https://github.com/apache/hudi/pull/2651, I will add some doc to introduce it 
in 0.9 release.




-- 
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: commits-unsubscr...@hudi.apache.org

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




[GitHub] [hudi] pengzhiwei2018 commented on a change in pull request #3193: [HUDI-2107] Support Read Log Only MOR Table For Spark

2021-07-09 Thread GitBox


pengzhiwei2018 commented on a change in pull request #3193:
URL: https://github.com/apache/hudi/pull/3193#discussion_r666723325



##
File path: 
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HoodieRealtimeInputFormatUtils.java
##
@@ -161,28 +162,18 @@
 .map(instant -> 
fsView.getLatestMergedFileSlicesBeforeOrOn(relPartitionPath, 
instant.getTimestamp()))
 .orElse(Stream.empty());
 
-// subgroup splits again by file id & match with log files.
-Map> groupedInputSplits = 
partitionsToParquetSplits.get(partitionPath).stream()
-.collect(Collectors.groupingBy(file -> 
FSUtils.getFileId(file.getFileStatus().getPath().getName(;
 latestFileSlices.forEach(fileSlice -> {
-  List dataFileSplits = 
groupedInputSplits.get(fileSlice.getFileId());
-  dataFileSplits.forEach(split -> {
-try {
-  List logFilePaths = 
fileSlice.getLogFiles().sorted(HoodieLogFile.getLogFileComparator())
+  List logFilePaths = 
fileSlice.getLogFiles().sorted(HoodieLogFile.getLogFileComparator())
   .map(logFile -> 
logFile.getPath().toString()).collect(Collectors.toList());
-  resultMap.put(split, logFilePaths);
-} catch (Exception e) {
-  throw new HoodieException("Error creating hoodie real time split 
", e);
-}
-  });
+  baseAndLogsList.add(Pair.of(fileSlice.getBaseFile(), logFilePaths));

Review comment:
   No, for log only file slice, the fileSlice.getBaseFile() is an empty 
Option.




-- 
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: commits-unsubscr...@hudi.apache.org

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




[GitHub] [hudi] pengzhiwei2018 commented on a change in pull request #3193: [HUDI-2107] Support Read Log Only MOR Table For Spark

2021-07-06 Thread GitBox


pengzhiwei2018 commented on a change in pull request #3193:
URL: https://github.com/apache/hudi/pull/3193#discussion_r664402382



##
File path: 
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HoodieRealtimeInputFormatUtils.java
##
@@ -161,29 +162,21 @@
 .map(instant -> 
fsView.getLatestMergedFileSlicesBeforeOrOn(relPartitionPath, 
instant.getTimestamp()))
 .orElse(Stream.empty());
 
-// subgroup splits again by file id & match with log files.
-Map> groupedInputSplits = 
partitionsToParquetSplits.get(partitionPath).stream()
-.collect(Collectors.groupingBy(file -> 
FSUtils.getFileId(file.getFileStatus().getPath().getName(;
 latestFileSlices.forEach(fileSlice -> {
-  List dataFileSplits = 
groupedInputSplits.get(fileSlice.getFileId());
-  dataFileSplits.forEach(split -> {
-try {
-  List logFilePaths = 
fileSlice.getLogFiles().sorted(HoodieLogFile.getLogFileComparator())
+  List logFilePaths = 
fileSlice.getLogFiles().sorted(HoodieLogFile.getLogFileComparator())
   .map(logFile -> 
logFile.getPath().toString()).collect(Collectors.toList());
-  resultMap.put(split, logFilePaths);
-} catch (Exception e) {
-  throw new HoodieException("Error creating hoodie real time split 
", e);
-}
-  });
+  baseAndLogsList.add(Pair.of(fileSlice.getBaseFile(), logFilePaths));
 });
   } catch (Exception e) {
 throw new HoodieException("Error obtaining data file/log file 
grouping: " + partitionPath, e);
   }
 });
-return resultMap;
+return baseAndLogsList;
   }
 
 
+
+

Review comment:
   done

##
File path: 
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/hudi/MergeOnReadSnapshotRelation.scala
##
@@ -137,11 +136,14 @@ class MergeOnReadSnapshotRelation(val sqlContext: 
SQLContext,
   }
 
   def buildFileIndex(filters: Array[Filter]): List[HoodieMergeOnReadFileSplit] 
= {
-
-val fileStatuses = if (globPaths.isDefined) {
+// Get all partition paths
+val partitionPaths = if (globPaths.isDefined) {
   // Load files from the global paths if it has defined to be compatible 
with the original mode
   val inMemoryFileIndex = 
HoodieSparkUtils.createInMemoryFileIndex(sqlContext.sparkSession, globPaths.get)
-  inMemoryFileIndex.allFiles()
+  val fsView = new HoodieTableFileSystemView(metaClient,
+metaClient.getActiveTimeline.getCommitsTimeline
+  .filterCompletedInstants, inMemoryFileIndex.allFiles().toArray)
+  
fsView.getLatestBaseFiles.iterator().asScala.toList.map(_.getFileStatus.getPath.getParent)

Review comment:
   Yes, currently I have not support reading-log only table  for the 
`globPaths` query which users must specify some `*` in the query path and the 
partition prune is also not work.
In the long way,  we should recommend the non-globalPath query which use 
the `HoodieFileIndex` to list files and partitions. User do not need to specify 
the `*`  in the query path and can also have better performance from the 
partition prune and meta table list.

##
File path: 
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestMergeIntoTable2.scala
##
@@ -0,0 +1,91 @@
+/*
+ * 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.spark.sql.hudi
+
+import org.apache.hudi.testutils.DataSourceTestUtils
+
+class TestMergeIntoTable2 extends TestHoodieSqlBase {

Review comment:
   As the origin `TestMergeIntoTable` is too long, I add another test class 
for merge-into. All subsequent cases about merge-into will be placed on 
TestMergeIntoTable2.




-- 
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: commits-unsubscr...@hudi.apache.org

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




[GitHub] [hudi] pengzhiwei2018 commented on a change in pull request #3193: [HUDI-2107] Support Read Log Only MOR Table For Spark

2021-07-06 Thread GitBox


pengzhiwei2018 commented on a change in pull request #3193:
URL: https://github.com/apache/hudi/pull/3193#discussion_r664403979



##
File path: 
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/TestMergeIntoTable2.scala
##
@@ -0,0 +1,91 @@
+/*
+ * 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.spark.sql.hudi
+
+import org.apache.hudi.testutils.DataSourceTestUtils
+
+class TestMergeIntoTable2 extends TestHoodieSqlBase {

Review comment:
   As the origin `TestMergeIntoTable` is too long, I add another test class 
for merge-into. All subsequent cases about merge-into will be placed on 
TestMergeIntoTable2.




-- 
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: commits-unsubscr...@hudi.apache.org

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




[GitHub] [hudi] pengzhiwei2018 commented on a change in pull request #3193: [HUDI-2107] Support Read Log Only MOR Table For Spark

2021-07-06 Thread GitBox


pengzhiwei2018 commented on a change in pull request #3193:
URL: https://github.com/apache/hudi/pull/3193#discussion_r664402382



##
File path: 
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HoodieRealtimeInputFormatUtils.java
##
@@ -161,29 +162,21 @@
 .map(instant -> 
fsView.getLatestMergedFileSlicesBeforeOrOn(relPartitionPath, 
instant.getTimestamp()))
 .orElse(Stream.empty());
 
-// subgroup splits again by file id & match with log files.
-Map> groupedInputSplits = 
partitionsToParquetSplits.get(partitionPath).stream()
-.collect(Collectors.groupingBy(file -> 
FSUtils.getFileId(file.getFileStatus().getPath().getName(;
 latestFileSlices.forEach(fileSlice -> {
-  List dataFileSplits = 
groupedInputSplits.get(fileSlice.getFileId());
-  dataFileSplits.forEach(split -> {
-try {
-  List logFilePaths = 
fileSlice.getLogFiles().sorted(HoodieLogFile.getLogFileComparator())
+  List logFilePaths = 
fileSlice.getLogFiles().sorted(HoodieLogFile.getLogFileComparator())
   .map(logFile -> 
logFile.getPath().toString()).collect(Collectors.toList());
-  resultMap.put(split, logFilePaths);
-} catch (Exception e) {
-  throw new HoodieException("Error creating hoodie real time split 
", e);
-}
-  });
+  baseAndLogsList.add(Pair.of(fileSlice.getBaseFile(), logFilePaths));
 });
   } catch (Exception e) {
 throw new HoodieException("Error obtaining data file/log file 
grouping: " + partitionPath, e);
   }
 });
-return resultMap;
+return baseAndLogsList;
   }
 
 
+
+

Review comment:
   done

##
File path: 
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/hudi/MergeOnReadSnapshotRelation.scala
##
@@ -137,11 +136,14 @@ class MergeOnReadSnapshotRelation(val sqlContext: 
SQLContext,
   }
 
   def buildFileIndex(filters: Array[Filter]): List[HoodieMergeOnReadFileSplit] 
= {
-
-val fileStatuses = if (globPaths.isDefined) {
+// Get all partition paths
+val partitionPaths = if (globPaths.isDefined) {
   // Load files from the global paths if it has defined to be compatible 
with the original mode
   val inMemoryFileIndex = 
HoodieSparkUtils.createInMemoryFileIndex(sqlContext.sparkSession, globPaths.get)
-  inMemoryFileIndex.allFiles()
+  val fsView = new HoodieTableFileSystemView(metaClient,
+metaClient.getActiveTimeline.getCommitsTimeline
+  .filterCompletedInstants, inMemoryFileIndex.allFiles().toArray)
+  
fsView.getLatestBaseFiles.iterator().asScala.toList.map(_.getFileStatus.getPath.getParent)

Review comment:
   Yes, currently I have not support reading-log only table  for the 
`globPaths` query which users must specify some `*` in the query path and the 
partition prune is also not work.
In the long way,  we should recommend the non-globalPath query which use 
the `HoodieFileIndex` to list files and partitions. User do not need to specify 
the `*`  in the query path and can also have better performance from the 
partition prune and meta table list.




-- 
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: commits-unsubscr...@hudi.apache.org

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