Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BigQueryType#toAvro generated code doesn't compile on multi-nested classes #5665

@clairemcginty

Description

@clairemcginty

for example, BigQueryType[NestedWrapper] for this code:

object Schema {

  @BigQueryType.toTable
  case class Base(
    events: List[Nested] = Nil
  )

  case class Nested(
    sibling: NestedWrapper
  )

  case class NestedWrapper(
    sibling: Sibling // this is where it breaks
  )

  case class Sibling()
}

generates a code block that redefines val result:

blackbox typecheck (against pt = com.spotify.concertdistribution.Schema.Base => org.apache.avro.generic.GenericRecord): (((r: com.spotify.concertdistribution.Schema.Base) => {
  import _root_.scala.jdk.javaapi.CollectionConverters._;
  {
    val result = {
      import _root_.scala.jdk.CollectionConverters._;
      val recordSchema = _root_.com.spotify.scio.bigquery.types.BigQueryType.avroSchemaOf[com.spotify.concertdistribution.Schema.Base];
      new _root_.org.apache.avro.generic.GenericRecordBuilder(_root_.org.apache.avro.Schema.createRecord("Base", recordSchema.getDoc, recordSchema.getNamespace, recordSchema.isError, recordSchema.getFields.asScala.map(((f) => new _root_.org.apache.avro.Schema.Field(f.name(), f.schema(), f.doc(), f.defaultVal()))).asJava))
    };
    result.set("repeat", {
      val rrepeat = r.repeat;
      {
        val result = {
          import _root_.scala.jdk.CollectionConverters._;
          val recordSchema = _root_.com.spotify.scio.bigquery.types.BigQueryType.avroSchemaOf[com.spotify.concertdistribution.Schema.Level1 @com.spotify.scio.bigquery.types.BigQueryTag];
          new _root_.org.apache.avro.generic.GenericRecordBuilder(_root_.org.apache.avro.Schema.createRecord("repeat", recordSchema.getDoc, recordSchema.getNamespace, recordSchema.isError, recordSchema.getFields.asScala.map(((f) => new _root_.org.apache.avro.Schema.Field(f.name(), f.schema(), f.doc(), f.defaultVal()))).asJava))
        };
...

and results in the compilation error recursive value rsibling needs type

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions