hudi icon indicating copy to clipboard operation
hudi copied to clipboard

Read RO View Exception: unable to infer schema for Parquet. It must be specified manually

Open jackwang2 opened this issue 7 years ago • 3 comments

    df1.dropDuplicates("event_id")
      .write
      .format("com.uber.hoodie")
      .mode(SaveMode.Append)
      .option(DataSourceWriteOptions.RECORDKEY_FIELD_OPT_KEY, "event_id")
      .option(DataSourceWriteOptions.PARTITIONPATH_FIELD_OPT_KEY, "st")
      .option(DataSourceWriteOptions.OPERATION_OPT_KEY, DataSourceWriteOptions.UPSERT_OPERATION_OPT_VAL)
      .option(HoodieWriteConfig.TABLE_NAME, "mytb")
      .option(DataSourceWriteOptions.PRECOMBINE_FIELD_OPT_KEY, "timestamp")
      .option("hoodie.insert.shuffle.parallelism",100)
      .save("s3a://my-bucket/temp/jack-test/result1")

I can use above code to upsert json data and write parquet files successfully, but when try to read data by RO view, it always throws exception:

val df2 = spark.read.format("com.uber.hoodie").load("s3a://my-bucket/temp/jack-test/result1")
df2.show(false)

org.apache.spark.sql.AnalysisException: Unable to infer schema for Parquet. It must be specified manually.; at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$9.apply(DataSource.scala:208) at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$9.apply(DataSource.scala:208) at scala.Option.getOrElse(Option.scala:121) at org.apache.spark.sql.execution.datasources.DataSource.getOrInferFileFormatSchema(DataSource.scala:207) at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:393) at com.uber.hoodie.DefaultSource.createRelation(DefaultSource.scala:81) at com.uber.hoodie.DefaultSource.createRelation(DefaultSource.scala:46) at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:341) at org.apache.spark.sql.DataFrameReader.loadV1Source(DataFrameReader.scala:239) at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:227) at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:174) ... 58 elided

jackwang2 avatar Apr 06 '19 07:04 jackwang2

@jackwang2 That is just spark exception when it does not find parquet files under the directory you specify.. may be you need to pass in a glob of the actual folders while reading?

val df2 = spark.read.format("com.uber.hoodie").load("s3a://my-bucket/temp/jack-test/result1/*/*/*")

Also please post on your dev ML for faster responses. hudi.apache.org/community.html

vinothchandar avatar Apr 08 '19 02:04 vinothchandar

@vinothchandar Thanks for the feedback, it helps us a lot.

jackwang2 avatar Apr 08 '19 06:04 jackwang2

After experimenting with changes on the Quickstart I got "pyspark.sql.utils.AnalysisException: Unable to infer schema for Parquet. It must be specified manually." when running:

tripsSnapshotDF = spark. \
  read. \
  format("hudi"). \
  load(basePath + "/*/*/*/*")

The solution was to change to below (check the depth of folders by running this linux command: find <basePath> ):

tripsSnapshotDF = spark. \
  read. \
  format("hudi"). \
  load(basePath + "/*/*")

tooptoop4 avatar Feb 11 '21 23:02 tooptoop4