1

I'm experimenting with calcite from scala, and trying to pass a simple scala class for creating a schema at runtime (using ReflectiveSchema), I'm having some headache.

For example, re-implementing the FoodMart JDBC Example (which works well in Java), I'm calling it as simple as new ReflectiveSchema(new Hr()), using a Hr class rewritten in scala as:

class HR {

  val emps: Array[Employee] = Array(new Employee(100, "Bill"))

}

I'm experiencing an error: ...SqlValidatorException: Object 'emps' not found within 'hr'. This problem seems to be related to the fact that val fields are actually created private in bytecode from java, and the implementation in calcite seems to be able to use (by means of java reflection) only fields accessible through the .getFields() method of a class. So I suppose this direction requires a lot more hacking than a simple my_field.setAccessible(true) or similar.

Are there any other way to construct a schema by API, avoiding reflection and the usage of JSON?

thanks in advance for any suggestion

Alfredo Serafini
  • 195
  • 3
  • 13
  • 1
    [Here](https://github.com/codefeedr/repl/blob/master/src/main/java/HrSchema.java) I found an hybrid approach, where the HRSchema has been actually written in Java, while the [ReflectiveSchema usage](https://github.com/codefeedr/repl/blob/212f7d4e08c7ca118682fff0c34199ced233c629/src/main/scala/commands/ConnectCommand.scala#L45) is in Scala instead. – P3trur0 Sep 03 '18 at 08:42
  • Hi thanks for the reply. This way works for me too, but my concern is about enabling the usage of scala classes itself (or even case classes), otherwise It would be less flexible to use from my code. Any ideas? – Alfredo Serafini Sep 03 '18 at 12:49

0 Answers0