Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler crashes when deriving TypeInformation for case class with @DataTypeHint #41

Open
megri opened this issue Aug 24, 2022 · 3 comments

Comments

@megri
Copy link

megri commented Aug 24, 2022

Scala version: 3.1.3

The compiler crashes with Error: Unexpected error when compiling project_ea109e5296_ea109e5296-b3409dd64e: 'class Class' when trying to derive an instance of TypeInformation[?] for a case class that uses org.apache.flink.table.annotation.DataTypeHint

I minimized the issue to the following, runnable with scala-cli

//> using scala "3.1.3"
//> using lib "org.apache.flink:flink-table-runtime:1.15.2"
//> using lib "io.findify::flink-adt:0.6.1"

package com.stuff

import io.findify.flinkadt.api.*
import org.apache.flink.table.annotation.DataTypeHint
import org.apache.flink.api.common.typeinfo.TypeInformation


case class Test(@DataTypeHint("BIGINT") timestamp: Long)

@main def run() =
  summon[TypeInformation[Test]]
@megri
Copy link
Author

megri commented Aug 24, 2022

It's possible this is a Dotty compiler issue but I'm not sure 🤔

@NickBurkard
Copy link
Contributor

I tried replicating this locally, it only fails on Scala 3, 2.12 & 2.13 work. I think this may be a Scala 3 compiler bug. 😅

package io.findify.flinkadt

import io.findify.flinkadt.api._
import org.apache.flink.table.annotation.DataTypeHint
import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

class DataTypeHintTest extends AnyFlatSpec with Matchers {
  it should "support deriving type information with data type hints" in {
    drop(deriveTypeInformation[UsesDataTypeHint])
  }
}

case class UsesDataTypeHint(@DataTypeHint("BIGINT") foo: Long)

Scala 3 error:

Error while emitting DataTypeHintTest.scala
...
[error] java.util.NoSuchElementException: class Class
[error] scala.collection.mutable.AnyRefMap$ExceptionDefault.apply(AnyRefMap.scala:508)
[error] scala.collection.mutable.AnyRefMap$ExceptionDefault.apply(AnyRefMap.scala:507)

@megri
Copy link
Author

megri commented Sep 2, 2022

I tried replicating this locally, it only fails on Scala 3, 2.12 & 2.13 work. I think this may be a Scala 3 compiler bug. 😅

Thanks for confirming. I tried replicating the issue by reimplementing the DataTypeHint interface but couldn't get it to trigger when I did so. I'll re-report the issue in the dotty-repo and see if they can help me out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants