umehrot2 commented on a change in pull request #1702:
URL: https://github.com/apache/hudi/pull/1702#discussion_r466317612
##########
File path: hudi-spark/src/main/scala/org/apache/hudi/DefaultSource.scala
##########
@@ -56,29 +58,56 @@ class DefaultSource extends RelationProvider
val parameters = Map(QUERY_TYPE_OPT_KEY -> DEFAULT_QUERY_TYPE_OPT_VAL) ++
translateViewTypesToQueryTypes(optParams)
val path = parameters.get("path")
- if (path.isEmpty) {
- throw new HoodieException("'path' must be specified.")
- }
if (parameters(QUERY_TYPE_OPT_KEY).equals(QUERY_TYPE_SNAPSHOT_OPT_VAL)) {
- // this is just effectively RO view only, where `path` can contain a mix
of
- // non-hoodie/hoodie path files. set the path filter up
- sqlContext.sparkContext.hadoopConfiguration.setClass(
- "mapreduce.input.pathFilter.class",
- classOf[HoodieROTablePathFilter],
- classOf[org.apache.hadoop.fs.PathFilter])
-
- log.info("Constructing hoodie (as parquet) data source with options :" +
parameters)
- log.warn("Snapshot view not supported yet via data source, for
MERGE_ON_READ tables. " +
- "Please query the Hive table registered using Spark SQL.")
- // simply return as a regular parquet relation
- DataSource.apply(
- sparkSession = sqlContext.sparkSession,
- userSpecifiedSchema = Option(schema),
- className = "parquet",
- options = parameters)
- .resolveRelation()
+ val readPathsStr =
parameters.get(DataSourceReadOptions.READ_PATHS_OPT_KEY)
+ if (path.isEmpty && readPathsStr.isEmpty) {
+ throw new HoodieException(s"'path' or '$READ_PATHS_OPT_KEY' or both
must be specified.")
+ }
+
+ val readPaths = readPathsStr.map(p =>
p.split(",").toSeq).getOrElse(Seq())
+ val allPaths = path.map(p => Seq(p)).getOrElse(Seq()) ++ readPaths
+
+ val fs = FSUtils.getFs(allPaths.head,
sqlContext.sparkContext.hadoopConfiguration)
+ val globPaths = HudiSparkUtils.checkAndGlobPathIfNecessary(allPaths, fs)
+
+ val tablePath = DataSourceUtils.getTablePath(fs, globPaths.toArray)
+ log.info("Obtained hudi table path: " + tablePath)
+
+ val metaClient = new HoodieTableMetaClient(fs.getConf, tablePath)
+ val bootstrapIndex = BootstrapIndex.getBootstrapIndex(metaClient)
+
+ val isBootstrappedTable = bootstrapIndex.useIndex()
Review comment:
Good point. I didn't realize that this is being stored in
`hoodie.properties` file.
Ideally we would want to have a kind of check here, which can tell us `if
any of the files is still bootstrapped or not`. If all the files written during
bootstrap have had some `upsert` to it, it means that a regular hudi file has
been written corresponding to each one of them. In such a case we would be able
to simply use `spark's parquet datasource`, for querying which would be faster.
Just wanted to bring to your notice. However, for now I can do what you are
suggesting.
----------------------------------------------------------------
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]