pengzhiwei2018 commented on a change in pull request #2651:
URL: https://github.com/apache/hudi/pull/2651#discussion_r619828391
##########
File path:
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/hudi/DefaultSource.scala
##########
@@ -79,40 +87,64 @@ class DefaultSource extends RelationProvider
val allPaths = path.map(p => Seq(p)).getOrElse(Seq()) ++ readPaths
val fs = FSUtils.getFs(allPaths.head,
sqlContext.sparkContext.hadoopConfiguration)
- val globPaths = HoodieSparkUtils.checkAndGlobPathIfNecessary(allPaths, fs)
-
- val tablePath = DataSourceUtils.getTablePath(fs, globPaths.toArray)
+ // Get the table base path
+ val tablePathOpt = TablePathUtils.getTablePath(fs, new Path(allPaths.head))
+ val tablePath = if (tablePathOpt.isPresent) {
+ tablePathOpt.get().toString
+ } else {
+ throw new HoodieException(s"Failed to get the table path, " +
+ s"Maybe ${allPaths.head} is not a hoodie table path")
+ }
log.info("Obtained hudi table path: " + tablePath)
val metaClient =
HoodieTableMetaClient.builder().setConf(fs.getConf).setBasePath(tablePath).build()
val isBootstrappedTable =
metaClient.getTableConfig.getBootstrapBasePath.isPresent
- log.info("Is bootstrapped table => " + isBootstrappedTable)
-
- if (parameters(QUERY_TYPE_OPT_KEY).equals(QUERY_TYPE_SNAPSHOT_OPT_VAL)) {
- if (metaClient.getTableType.equals(HoodieTableType.MERGE_ON_READ)) {
- if (isBootstrappedTable) {
- // Snapshot query is not supported for Bootstrapped MOR tables
- log.warn("Snapshot query is not supported for Bootstrapped
Merge-on-Read tables." +
- " Falling back to Read Optimized query.")
- new HoodieBootstrapRelation(sqlContext, schema, globPaths,
metaClient, optParams)
- } else {
- new MergeOnReadSnapshotRelation(sqlContext, optParams, schema,
globPaths, metaClient)
- }
- } else {
- getBaseFileOnlyView(sqlContext, parameters, schema, readPaths,
isBootstrappedTable, globPaths, metaClient)
- }
- } else
if(parameters(QUERY_TYPE_OPT_KEY).equals(QUERY_TYPE_READ_OPTIMIZED_OPT_VAL)) {
- getBaseFileOnlyView(sqlContext, parameters, schema, readPaths,
isBootstrappedTable, globPaths, metaClient)
- } else if
(parameters(QUERY_TYPE_OPT_KEY).equals(QUERY_TYPE_INCREMENTAL_OPT_VAL)) {
- val metaClient =
HoodieTableMetaClient.builder().setConf(fs.getConf).setBasePath(tablePath).build()
- if (metaClient.getTableType.equals(HoodieTableType.MERGE_ON_READ)) {
- new MergeOnReadIncrementalRelation(sqlContext, optParams, schema,
metaClient)
+ val tableType = metaClient.getTableType
+ val queryType = parameters(QUERY_TYPE_OPT_KEY)
+ log.info(s"Is bootstrapped table => $isBootstrappedTable, tableType is:
$tableType")
+
+ (tableType, queryType, isBootstrappedTable) match {
+
+ case (COPY_ON_WRITE, QUERY_TYPE_SNAPSHOT_OPT_VAL, false) |
+ (COPY_ON_WRITE, QUERY_TYPE_READ_OPTIMIZED_OPT_VAL, false) |
+ (MERGE_ON_READ, QUERY_TYPE_READ_OPTIMIZED_OPT_VAL, false) =>
+ getBaseFileOnlyView(sqlContext, parameters, schema, tablePath,
metaClient)
+
+ case (COPY_ON_WRITE, QUERY_TYPE_INCREMENTAL_OPT_VAL, _) =>
Review comment:
Yes, it will looks more nice to have all incremental next to each other.
--
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:
[email protected]