hudi icon indicating copy to clipboard operation
hudi copied to clipboard

INCREMETNAL QUERY-Null value Exception

Open prashanthpdesai opened this issue 6 years ago • 11 comments

Tips before filing an issue

  • Have you gone through our FAQs? Yes

  • Join the mailing list to engage in conversations and get faster support at [email protected].

  • If you have triaged this as a bug, then file an issue directly.

Describe the problem you faced

Facing null value exception while pulling the data from hudi basepath programmatically.

To Reproduce

Steps to reproduce the behavior:

1. 2. 3. 4.

Expected behavior

Get all the records which are being ingested from last begintime to current time incrementally.

Environment Description

  • Hudi version : 0.5.2

  • Spark version : 2.2.1

  • Hive version :

  • Hadoop version : 2.7

  • Storage (HDFS/S3/GCS..) : HDFS

  • Running on Docker? (yes/no) : no

Additional context

Please find the steps and error description. scala> val basepath= "/datalake/xxx/xxx/prd/xxx/hudi_cow_dedup_debug"

scala> spark.read.format("org.apache.hudi").load(basepath + "/*").createOrReplaceTempView("hudi_tab")

scala> val commits = spark.sql("select distinct(_hoodie_commit_time) as commitTime from hudi_tab order by commitTime").map(k => k.getString(0)).take(50) commits: Array[String] = Array(20200622140846, 20200622151300, 20200622161353, 20200622170749, 20200622180730, 20200622191126, 20200622201001, 20200622211525, 20200622220714, 20200622231112, 20200623001304, 20200623011203, 20200623020759, 20200623031251, 20200623041044)

scala> val beginTime = commits(commits.length - 2) beginTime: String = 20200623031251

scala> val incrementalDF = spark.read.format("org.apache.hudi").option(QUERY_TYPE_OPT_KEY, QUERY_TYPE_INCREMENTAL_OPT_VAL).option(BEGIN_INSTANTTIME_OPT_KEY, beginTime).load(basepath); java.lang.NoSuchFieldError: NULL_VALUE at org.apache.hudi.avro.HoodieAvroUtils.addMetadataFields(HoodieAvroUtils.java:143) at org.apache.hudi.avro.HoodieAvroUtils.createHoodieWriteSchema(HoodieAvroUtils.java:130) at org.apache.hudi.IncrementalRelation.(IncrementalRelation.scala:77) at org.apache.hudi.DefaultSource.createRelation(DefaultSource.scala:80) at org.apache.hudi.DefaultSource.createRelation(DefaultSource.scala:47) at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:307) at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:178) at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:156) ... 60 elided

scala> val incrementalDF = spark.read.format("org.apache.hudi").option("hoodie.datasource.query.type","incremental").option("hoodie.datasource.read.begin.instanttime",beginTime).load(basepath); java.lang.NoSuchFieldError: NULL_VALUE at org.apache.hudi.avro.HoodieAvroUtils.addMetadataFields(HoodieAvroUtils.java:143) at org.apache.hudi.avro.HoodieAvroUtils.createHoodieWriteSchema(HoodieAvroUtils.java:130) at org.apache.hudi.IncrementalRelation.(IncrementalRelation.scala:77) at org.apache.hudi.DefaultSource.createRelation(DefaultSource.scala:80) at org.apache.hudi.DefaultSource.createRelation(DefaultSource.scala:47) at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:307) at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:178) at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:156) ... 60 elided

Add any other context about the problem here.

Stacktrace

Add the stacktrace of the error.

prashanthpdesai avatar Jun 30 '20 16:06 prashanthpdesai

The code you are referring to seems to be from master - https://github.com/apache/hudi/blob/2be924fd3a04e2106f1ad3f9ce91890ea58c8a88/hudi-common/src/main/java/org/apache/hudi/avro/HoodieAvroUtils.java#L143 Where NULL_VALUE comes fromJsonProperties. Whereas 0.5.2 uses https://github.com/apache/hudi/blob/41202da7788193da77f1ae4b784127bb93eaae2c/hudi-common/src/main/java/org/apache/hudi/common/util/HoodieAvroUtils.java#L143 that's pointing to initRecordKeySchema() and references to NullNode.getInstance.

@prashanthpdesai are you using Hudi master or 0.5.2 ?

bhasudha avatar Jul 01 '20 04:07 bhasudha

@bhasudha : we are using master jar .

Just an added information vinoth @vinothchandar wanted to share information here ,have created external table manually on the same base path but we see null pointer exception for simple select query. hive> select * from default.part_prd_simple_mmprd limit 5; OK Failed with exception java.io.IOException:java.lang.NullPointerException

but by disabling fetch task conversion i was able to query the same table without any exception.

hive> set hive.fetch.task.conversion=none; hive> select * from default.part_prd_simple_mmprd limit 5; Launching Job 1 out of 1 Number of reduce tasks is set to 0 since there's no reduce operator

prashanthpdesai avatar Jul 01 '20 05:07 prashanthpdesai

@prashanthpdesai thanks for the update. Just wanted to point you to a NOTE on Fetch task in Hive here - https://hudi.apache.org/docs/querying_data.html#hive

So IIUC, there are two issues here?

  1. Simple Incremental query is throwing NULL_VALUE exception ? Could you paste the spark-shell command that you used ? Along with the write configs. Meanwhile, I can try to run Quickstart on latest master to see if I can reproduce this.
  2. The second issue is with registering the table as external and querying via Hive ( simple select * query). That fails with exception "java.io.IOException:java.lang.NullPointerException". But goes away with disabling fetch.task.conversion? Could you paste the full stack trace for the exception here?

bhasudha avatar Jul 01 '20 18:07 bhasudha

Sure @bhasudha

  1. please find the spark spark-shell --master yarn --queue queue_q1 --jars /home/pdesai/HUDI/incubator-hudi/packaging/hudi-spark-bundle/target/hudi-spark-bundle_2.11-0.6.0-SNAPSHOT.jar --conf 'spark.serializer=org.apache.spark.serializer.KryoSerializer' --conf spark.sql.hive.convertMetastoreParquet=false --num-executors 16 --executor-cores 4 —executor-memory 32G

imported these configs ..: import org.apache.hudi.QuickstartUtils._ import scala.collection.JavaConversions._ import org.apache.spark.sql.SaveMode._ import org.apache.hudi.DataSourceReadOptions._ import org.apache.hudi.DataSourceWriteOptions._ import org.apache.hudi.config.HoodieWriteConfig._ import org.apache.hudi.config.HoodieStorageConfig._ import org.apache.hudi.config.HoodieCompactionConfig._

we did also try with 0.5.2 jar as well , faced the same issue .

  1. For Hive query issue , i don't see full stack trace as its not submitting to cluster , i just get the null pointer exception which i have pasted earlier .

prashanthpdesai avatar Jul 01 '20 19:07 prashanthpdesai

@prashanthpdesai I was not able to reproduce this with Quickstart instructions. I tried against the jar from latest master. I noticed one thing though in your spark shell command, that you are not passing in the --packages org.apache.spark:spark-avro_2.11:2.4.4. By default spark-shell does not include spark-avro.

I am suspecting this is the issue. Could you try once including spark-avro in your spark-shell command?

bhasudha avatar Jul 04 '20 07:07 bhasudha

@bhasudha : Hi , tried with same packages which you have mentioned above , we see diff kind of error .

Please find the trace below .

spark-shell --queue queue_q1 --packages org.apache.hudi:hudi-spark-bundle_2.11:0.5.3,org.apache.spark:spark-avro_2.11:2.4.4 --conf 'spark.serializer=org.apache.spark.serializer.KryoSerializer' Warning: Master yarn-client is deprecated since 2.0. Please use master "yarn" with specified deploy mode instead. The jars for the packages stored in: /home/edzmmprd/.ivy2/jars :: loading settings :: url = jar:file:/opt/mapr/spark/spark-2.2.1/jars/ivy-2.4.0.jar!/org/apache/ivy/core/settings/ivysettings.xml org.apache.hudi#hudi-spark-bundle_2.11 added as a dependency org.apache.spark#spark-avro_2.11 added as a dependency :: resolving dependencies :: org.apache.spark#spark-submit-parent;1.0 confs: [default] found org.apache.hudi#hudi-spark-bundle_2.11;0.5.3 in central found org.apache.spark#spark-avro_2.11;2.4.4 in central found org.apache.spark#spark-tags_2.11;2.4.4 in central found org.spark-project.spark#unused;1.0.0 in central downloading https://repo1.maven.org/maven2/org/apache/hudi/hudi-spark-bundle_2.11/0.5.3/hudi-spark-bundle_2.11-0.5.3.jar ... [SUCCESSFUL ] org.apache.hudi#hudi-spark-bundle_2.11;0.5.3!hudi-spark-bundle_2.11.jar (787ms) downloading https://repo1.maven.org/maven2/org/apache/spark/spark-avro_2.11/2.4.4/spark-avro_2.11-2.4.4.jar ... [SUCCESSFUL ] org.apache.spark#spark-avro_2.11;2.4.4!spark-avro_2.11.jar (13ms) downloading https://repo1.maven.org/maven2/org/apache/spark/spark-tags_2.11/2.4.4/spark-tags_2.11-2.4.4.jar ... [SUCCESSFUL ] org.apache.spark#spark-tags_2.11;2.4.4!spark-tags_2.11.jar (6ms) downloading https://repo1.maven.org/maven2/org/spark-project/spark/unused/1.0.0/unused-1.0.0.jar ... [SUCCESSFUL ] org.spark-project.spark#unused;1.0.0!unused.jar (5ms) :: resolution report :: resolve 2006ms :: artifacts dl 817ms :: modules in use: org.apache.hudi#hudi-spark-bundle_2.11;0.5.3 from central in [default] org.apache.spark#spark-avro_2.11;2.4.4 from central in [default] org.apache.spark#spark-tags_2.11;2.4.4 from central in [default] org.spark-project.spark#unused;1.0.0 from central in [default] --------------------------------------------------------------------- | | modules || artifacts | | conf | number| search|dwnlded|evicted|| number|dwnlded| --------------------------------------------------------------------- | default | 4 | 4 | 4 | 0 || 4 | 4 | --------------------------------------------------------------------- :: retrieving :: org.apache.spark#spark-submit-parent confs: [default] 4 artifacts copied, 0 already retrieved (20789kB/44ms)

scala> import org.apache.hudi.QuickstartUtils._ import org.apache.hudi.QuickstartUtils._

scala> import scala.collection.JavaConversions._ import scala.collection.JavaConversions._

scala> import org.apache.spark.sql.SaveMode._ import org.apache.spark.sql.SaveMode._

scala> import org.apache.hudi.DataSourceReadOptions._ import org.apache.hudi.DataSourceReadOptions._

scala> import org.apache.hudi.DataSourceWriteOptions._ import org.apache.hudi.DataSourceWriteOptions._

scala> import org.apache.hudi.config.HoodieWriteConfig._ import org.apache.hudi.config.HoodieWriteConfig._

scala> val basepath= "/datalake/uhclake/edz/prd/mcm/mcm_hudi_cow_dedup_fix" basepath: String = /datalake/uhclake/edz/prd/mcm/mcm_hudi_cow_dedup_fix

scala> spark.read.format("org.apache.hudi").load(basepath + "/*").createOrReplaceTempView("hudi_tab")

scala> val commits = spark.sql("select distinct(_hoodie_commit_time) as commitTime from hudi_tab order by commitTime").map(k => k.getString(0)).take(50) commits: Array[String] = Array(20200703000922, 20200703002654, 20200703010757, 20200703020715, 20200703030709, 20200703041422, 20200703051419, 20200703060728, 20200703070921, 20200703080801, 20200703090728, 20200703101459, 20200703110839, 20200703120708, 20200703131249, 20200703140738, 20200703151235, 20200703160723, 20200703170659, 20200703181223, 20200703211557, 20200703220646, 20200703231410, 20200704001432, 20200704010736, 20200704020754, 20200704030729, 20200704040836, 20200704050652, 20200704060650, 20200704070749, 20200704080711, 20200704090720, 20200704100722, 20200704110857, 20200704120736, 20200704130712, 20200704140741, 20200704150641, 20200704160732, 20200704170709, 20200704180745, 20200704190843, 20200704200658, 20200704210717, 20200704220739, 20200704230704, 20200705001445... scala> val beginTime = commits(commits.length - 2) beginTime: String = 20200705010728

scala> val incrementalDF = spark.read.format("org.apache.hudi").option(QUERY_TYPE_OPT_KEY, QUERY_TYPE_INCREMENTAL_OPT_VAL).option(BEGIN_INSTANTTIME_OPT_KEY, beginTime).load(basepath); java.lang.NoSuchMethodError: org.apache.avro.Schema$Field.(Ljava/lang/String;Lorg/apache/avro/Schema;Ljava/lang/String;Ljava/lang/Object;)V at org.apache.hudi.common.util.HoodieAvroUtils.addMetadataFields(HoodieAvroUtils.java:110) at org.apache.hudi.common.util.HoodieAvroUtils.createHoodieWriteSchema(HoodieAvroUtils.java:101) at org.apache.hudi.IncrementalRelation.(IncrementalRelation.scala:76) at org.apache.hudi.DefaultSource.createRelation(DefaultSource.scala:80) at org.apache.hudi.DefaultSource.createRelation(DefaultSource.scala:47) at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:307) at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:178) at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:156) ... 60 elided

prashanthpdesai avatar Jul 07 '20 02:07 prashanthpdesai

@prashanthpdesai This definitely looks like Avro incompatibility. The spark-avro and spark version must match - https://hudi.apache.org/docs/quick-start-guide.html#setup has a note on these. Hudi is migrated to spark 2.4.4 as we moved from Databricks-avro to spark-avro. Can you check the same on spark 2.4.4 shell ? I think that would resolve the issue.

bhasudha avatar Jul 08 '20 07:07 bhasudha

@bhasudha : if i understood correctly its not back ward compatible , we will try to check in 2.4.4 if its available in any of our environment.

prashanthpdesai avatar Jul 08 '20 22:07 prashanthpdesai

@bhasudha : it is working for Spark 2.4 version Thank you ..

prashanthpdesai avatar Jul 10 '20 22:07 prashanthpdesai

Great. Please close the issue if its now resolved

vinothchandar avatar Jul 11 '20 05:07 vinothchandar

Closing this for now. @prashanthpdesai : Please reopen if this is still an issue.

bvaradar avatar Jul 15 '20 14:07 bvaradar