makubi / avrohugger-maven-plugin

Maven plugin for generating Scala case classes and ADTs from Apache Avro schemas, datafiles, and protocols
Apache License 2.0
9 stars 9 forks source link

ERROR: Not an Avro data file. #86

Open devinbost opened 1 year ago

devinbost commented 1 year ago

When I run mvn avrohugger:generate-scala-sources, I get the error:

Not an Avro data file. -> [Help 1]

Here is the context in the output:

[INFO] Generating Scala files for schemas in /Users/devin.bost/proj/repos/pulsar_workshop/scenarios/native-pulsar/np-common/src/main/avro to /Users/devin.bost/proj/repos/pulsar_workshop/scenarios/spark-scala/target/generated-sources [INFO] Generating Scala files for /Users/devin.bost/proj/repos/pulsar_workshop/scenarios/native-pulsar/np-common/src/main/avro/DeviceTSNew.avro [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.429 s [INFO] Finished at: 2023-06-27T18:47:58-05:00 [INFO] ------------------------------------------------------------------------ [ERROR] Not an Avro data file. -> [Help 1]

This can be reproduced from this repo branch:

To reproduce: git clone https://github.com/devinbost/pulsar_workshop.git git checkout spark-scala cd pulsar_workshop cd scenarios cd spark-scala mvn avrohugger:generate-scala-sources

For reference, here is the Avro file:

{
  "namespace": "com.example.pulsarworkshop",
  "type": "record",
  "name": "DeviceTSNew",
  "fields": [
    {
      "name": "tag_id",
      "type": "string"
    },
    {
      "name": "data_quality",
      "type": "int"
    },
    {
      "name": "event_time",
      "type": "string",
      "logicalType": "timestamp-millis",
      "doc": "The date and time is stored as string in ISO 8601 format"
    },
    {
      "name": "event_value",
      "type": "double"
    },
    {
       "name": "yyyymm",
       "type": "int"
    }
  ]
}

Here is the POM file:

pom.xml.txt

julianpeeters commented 1 year ago

Hi @devinbost , I notice that this line is reporting a .avro file:

[INFO] Generating Scala files for /Users/devin.bost/proj/repos/pulsar_workshop/scenarios/native-pulsar/np-common/src/main/avro/DeviceTSNew.avro

However, if the copy-pasted text is the entire file (and not just the schema portion), then that would appear to be a .avsc file. That would be consistent with the reported error.

Please try renaming the file from DeviceTSNew.avro to DeviceTSNew.avsc. Took me a bit to realize the issue, and maybe you already beat me to the solution.