Error running hudi on aws glue
Hi, I am trying to get the hudi script run using aws glue2.0. I have uploaded the jars (spark-avro_2.11-2.4.3.jar, hudi-spark-bundle_2.12-0.5.3.jar) to s3 and referenced them using --extra-jars parameter and also configured --packages org.apache.hudi:hudi-spark-bundle_2.11:0.5.3,org.apache.spark:spark-avro_2.11:2.4.3 parameter. Now when I run the glue job with hudi script I get the following error
df.write.format("hudi").options(**hudi_options).mode("append").save(basePath) File "/opt/amazon/spark/python/lib/pyspark.zip/pyspark/sql/readwriter.py", line 734, in save self._jwrite.save(path) File "/opt/amazon/spark/python/lib/py4j-0.10.7-src.zip/py4j/java_gateway.py", line 1257, in call answer, self.gateway_client, self.target_id, self.name) File "/opt/amazon/spark/python/lib/pyspark.zip/pyspark/sql/utils.py", line 63, in deco return f(*a, **kw) File "/opt/amazon/spark/python/lib/py4j-0.10.7-src.zip/py4j/protocol.py", line 328, in get_return_value format(target_id, ".", name), value) py4j.protocol.Py4JJavaError: An error occurred while calling o155.save. : java.lang.NoSuchMethodError: scala.Some.value()Ljava/lang/Object; at org.apache.hudi.HoodieSparkSqlWriter$.write(HoodieSparkSqlWriter.scala:59) at org.apache.hudi.DefaultSource.createRelation(DefaultSource.scala:108) at org.apache.spark.sql.execution.datasources.SaveIntoDataSourceCommand.run(SaveIntoDataSourceCommand.scala:45) at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:70) at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:68) at org.apache.spark.sql.execution.command.ExecutedCommandExec.doExecute(commands.scala:86) at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:131) at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:127) at org.apache.spark.sql.execution.SparkPlan$$anonfun$executeQuery$1.apply(SparkPlan.scala:155) at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151) at org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:152) at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:127) at org.apache.spark.sql.execution.QueryExecution.toRdd$lzycompute(QueryExecution.scala:80) at org.apache.spark.sql.execution.QueryExecution.toRdd(QueryExecution.scala:80) at org.apache.spark.sql.DataFrameWriter$$anonfun$runCommand$1.apply(DataFrameWriter.scala:676) at org.apache.spark.sql.DataFrameWriter$$anonfun$runCommand$1.apply(DataFrameWriter.scala:676) at org.apache.spark.sql.execution.SQLExecution$$anonfun$withNewExecutionId$1.apply(SQLExecution.scala:78) at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:125) at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:73) at org.apache.spark.sql.DataFrameWriter.runCommand(DataFrameWriter.scala:676) at org.apache.spark.sql.DataFrameWriter.saveToV1Source(DataFrameWriter.scala:285) at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:271) at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:229) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244) at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357) at py4j.Gateway.invoke(Gateway.java:282) at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132) at py4j.commands.CallCommand.execute(CallCommand.java:79) at py4j.GatewayConnection.run(GatewayConnection.java:238) at java.lang.Thread.run(Thread.java:748)
Am I missing something ? Any help would be appreciated and thanks in advance.
Environment: Aws Glue 2.0 pyspark Spark Version:2.4.3 Hadoop version: 2.8.5-amzn-1
cc @umehrot2 are you able to help?
@KarthickAN AWS Glue does not have official support for Hudi. So you may possibly hit runtime issues which you would have to workaround by yourself.
As for this particular issue, seems like it might be due to scala version mismatch. In your description you have mentioned that you are uploading hudi-spark-bundle 2.12 on s3 and referencing using --extra-jars and at the same time configuring --packages with hudi-spark-bundle 2.11 which is confusing. You should only try passing 2.11 jar, and by only one method. You should try either --extra-jars or --packages, not both.
@vinothchandar @umehrot2 Thank you for responding. I was able to run it after I uploaded a custom built jar by adding the shadedPattern in the pom for org.apache.hudi.org.eclipse.jetty. like mentioned in the following issue thread https://github.com/apache/hudi/issues/1789.
I was able to run the read optimized queries as well on athena. As of now I am evaluating hudi with our existing data lake architecture. It seems to integrate well. But I do have few queries though
- Athena and Redshift spectrum supports querying CoW hudi table now. Will it add support for MoR as well in the near future ?
- Will AWS Glue natively support hudi in the future ?
- Will you be adding support for cloudwatch metrics ?
- Is it possible to enable hive sync feature for AWS Glue Catalog ?
- I also tried running the 0.6.0-rc1 build on AWS Glue. The job kept on running even after it has written the data successfully. Then I had to kill it manually. It happened once in 0.5.3 as well. Is there a async feature that runs by default which we should disable ?
@umehrot2 : Assigned this support ticket to you as this is AWS specific.
- Please reach out to AWS support. I am not aware of it, and its best to hear from AWS teams themselves (if they are willing to reveal this information).
- Please reach out to AWS support. I am not aware of it, and its best to ask AWS Glue. But afaik this is not going to happen.
- We have no plans as of now. If you want, you can reach out to AWS support and open a feature request with EMR team detailing your use-case. If there is sufficient ask for it, its possible we might invest in it.
- You can hive-sync to glue catalog from EMR cluster. (If that was your question)
- I am not aware of any such feature. If you cannot reproduce similar behavior on EMR, then it might have something to do with AWS Glue.
We primarily use AWS Glue not EMR. So I wanted to know what would be the way to
- sync to glue catalog using hudi ( If hudi can't do it then we might have to manage it using boto3 )
- push metrics to cloudwatch ( I see one way to extend UserDefinedMetricsReporter )
from glue. It would be helpful if you could provide your inputs regarding the same. Thanks.
@KarthickAN
-
AWS Glue does not officially support Hudi. Does the sync to glue catalog not work out of the box ? I assume the problem with glue would be that it does not have hive-server running which is required for sync to work through Hudi. Yeah using boto3 or sdk to directly call glue APIs instead of Hive would be the way to approach it.
-
For pushing metrics to cloudwatch, you are right. Having an implementation of the metrics reported would be good.
@KarthickAN closing this issue. Please re-open if you need help with any other question here.
By any chance, does anyone have a working example I can follow to get Hudi to work with AWS glue? I have added the jars to a S3 path and am adding as extra jars parameter to the glue job. However, I am still getting ClassNotFoundException when running a simple job to write a hudi dataset.
Py4JJavaError: An error occurred while calling o298.save. : java.lang.ClassNotFoundException: Failed to find data source: hoodie. Please find packages at http://spark.apache.org/third-party-projects.html at org.apache.spark.sql.execution.datasources.DataSource$.lookupDataSource(DataSource.scala:657) at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:245) at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:229) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244) at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357) at py4j.Gateway.invoke(Gateway.java:282) at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132) at py4j.commands.CallCommand.execute(CallCommand.java:79) at py4j.GatewayConnection.run(GatewayConnection.java:238) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.ClassNotFoundException: hoodie.DefaultSource at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$20$$anonfun$apply$12.apply(DataSource.scala:634) at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$20$$anonfun$apply$12.apply(DataSource.scala:634) at scala.util.Try$.apply(Try.scala:192) at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$20.apply(DataSource.scala:634) at org.apache.spark.sql.execution.datasources.DataSource$$anonfun$20.apply(DataSource.scala:634) at scala.util.Try.orElse(Try.scala:84) at org.apache.spark.sql.execution.datasources.DataSource$.lookupDataSource(DataSource.scala:634) ... 13 more
Can you try "hudi" or "org.apache.hudi" as data-source name ?
I have tried both and both give me the same classnotfound error. I'm trying to write out a data frame and am not passing any extra options
df.write
.format("hudi")
.mode("overwrite")
.save(s3_path)
cc @umehrot2 : Any ideas ?
To give some more info, in my glue job, i add the following parameters:
--extra-jars": s3://my_s3_bucket/hudi_jars/ --conf: "spark.serializer=org.apache.spark.serializer.KryoSerializer --conf spark.sql.hive.convertMetastoreParquet=false"
I have also tested with --user-jars-first: true but that did not help
below is how i build my test data.
test_json = [ { "key": "test1" }, { "key": "test2" } ]
rdd = sc.parallelize(test_json) df = spark.read.json(rdd)
Below are the jars in my s3 location spark-avro_2.11-2.4.4.jar hudi-spark-bundle_2.11-0.6.1-SNAPSHOT.jar httpclient-4.5.13.jar
Can you try the following:
--jars s3://my_s3_bucket/hudi_jars/hudi-spark-bundle_2.11-0.6.1-SNAPSHOT.jar,s3://my_s3_bucket/hudi_jars/spark-avro_2.11-2.4.4.jar,s3://my_s3_bucket/hudi_jars/httpclient-4.5.13.jar
Hello umehrot2, I added your suggestion to the glue job parameters and still get an error:
Traceback (most recent call last): File "/tmp/test_hudi.py", line 86, in
@kimberlyamandalu I have a version of this working, but with GlueDevEndpoints, which has pretty similar behavior. Here are the settings I have.
- Extra jars should have the full path of the jar file
--extra-jars "s3://mybucket/jars//hudi-spark-bundle_2.11-0.5.2-incubating.jar, s3://mybucket/jars/spark-avro_2.11-2.4.4.jar"
Job configuration should include the following config paramters
--conf "spark.serializer=org.apache.spark.serializer.KryoSerializer" --conf "spark.sql.hive.convertMetastoreParquet=false"
Here's the sample pyspark command that I ran and the format I used is just "hudi"
(inputDF1.write
.format("hudi")
.options(**hudi_options)
.mode("overwrite")
.save(args['target_s3_path']))
@rchamarthi thank you. I will try using individual paths to the jar files tomorrow and let this group lnow if it works
@rchamarthi specifying the individual jar files in the --extra-jars parameter did the trick!! i have successfully read and wrote hudi data sets!
Thank you very much to everyone for your very prompt responses! @rchamarthi @umehrot2 @bvaradar @KarthickAN
Really appreciate your guys' help!!!!
@kimberlyamandalu, @bvaradar, @umehrot2 @rchamarthi I am facing issue, while working hudi with glue, I have added the jar files in Glue Dependent jars path with full S3 path of jar. Could you please help it is very urgent
@ashok-workouts I have the following job parameters to ensure Hudi works with glue for my stuff:
--conf: "spark.serializer=org.apache.spark.serializer.KryoSerializer --conf spark.sql.hive.convertMetastoreParquet=false" --extra-jars: "s3://jar-bucket/spark-avro.jar,s3://jar-bucket/httpclient.jar,s3://jar-bucket/spark-bundle.jar"
I am using Python 3 and Glue version 2.0
Hope this helps. What error are you getting?