Azure/spark-cdm-connector

Error in - Explicit write, creating an entity in a CDM folder based on a pre-defined model

Closed this issue · 11 comments

UPLOAD CDM FILES FIRST

To run this example, first create a /Models/Contacts folder to your demo container in ADLS gen2,

then upload the provided Contacts.manifest.cdm.json, Person.cdm.json, Entity.cdm.json files

When I was trying to execute following code segment, I get - Entity definition model file "/Contacts/Person.cdm.json" not found., All the directories and files are in place as per above comments.

My directory structure is - adbdemofilesystem / Models / Contacts
Files under Contacts are - Contacts.manifest.cdm.json, Person.cdm.json, Entity.cdm.json files

Create the dataframe that matches the CDM definition of the entity, Person

df2 = spark.createDataFrame(spark.sparkContext.parallelize(data2, 1), schema2)
(df2.write.format("com.microsoft.cdm")
.option("storage", storageAccountName)
.option("manifestPath", container + "/Data/Contacts/root.manifest.cdm.json")
.option("entity", "Person")
.option("entityDefinitionModelRoot", container + "/Models")
.option("entityDefinitionPath", "/Contacts/Person.cdm.json/Person")
.mode("overwrite")
.save())


Py4JJavaError Traceback (most recent call last)
/databricks/spark/python/pyspark/sql/utils.py in deco(*a, **kw)
62 try:
---> 63 return f(*a, **kw)
64 except py4j.protocol.Py4JJavaError as e:

/databricks/spark/python/lib/py4j-0.10.7-src.zip/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)
327 "An error occurred while calling {0}{1}{2}.\n".
--> 328 format(target_id, ".", name), value)
329 else:

Py4JJavaError: An error occurred while calling o1112.save.
: java.lang.IllegalArgumentException: Entity definition model file "/Contacts/Person.cdm.json" not found
at com.microsoft.cdm.utils.CDMModelCommon.(CDMModelCommon.scala:85)
at com.microsoft.cdm.utils.CDMModelWriter.(CDMModelWriter.scala:38)
at com.microsoft.cdm.write.CDMDataSourceWriter.(CDMDataSourceWriter.scala:69)
at com.microsoft.cdm.DefaultSource.createWriter(DefaultSource.scala:295)
at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:277)
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:380)
at py4j.Gateway.invoke(Gateway.java:295)
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
at py4j.commands.CallCommand.execute(CallCommand.java:79)
at py4j.GatewayConnection.run(GatewayConnection.java:251)
at java.lang.Thread.run(Thread.java:748)

During handling of the above exception, another exception occurred:

IllegalArgumentException Traceback (most recent call last)
in
34 .option("entityDefinitionModelRoot", container + "/Models")
35 .option("entityDefinitionPath", "/Contacts/Person.cdm.json/Person")
---> 36 .mode("overwrite")
37 .save())

Were you able to run the previous two cells (implicit and explicit write from pre-defined model) from the example?

I just re-ran the sample and it should still work:
image

Can you share a similar snapshot?

That looks similar to what I have.

Can you also take a snapshot of the contents at the container level? Is there a directory called ImplicitTest at the same level Models?

Thank you for the quick response. Yes. I do have directory called ImplicitTest at the same level Models.

image

I'm not sure what the error is then. Can you reach out to asksparkcdm@microsoft.com and we can schedule some time to debug it.

thank you for your help. I am closing this issue.