flink-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lothium <Flo_Schul...@web.de>
Subject Re: Problem with SQL-API and nested objects in case class
Date Thu, 23 Nov 2017 09:02:08 GMT
Hey Timo,
when I try to access the array in the case class via the SQL syntax, I get
back an error that the syntax is invalid. Here is an example of the case
class structure:

case class Envelope(name: String, entity: Product)
case class Product(name: String, items: List[Item])
case class Item(attr1: String, attr2: String, attr3: Option[String])

The input stream is of type "Envelope" and I try to do the following query:
"SELECT entity.items[1].attr1 FROM product". Querying the name of the
product is not a problem for example. Is this really an invalid syntax? I
had a look at the documentation and I thought it would work like this.

I also tried to create a UDF to unnest the array, the function looks like

class UnnestArray() extends TableFunction[Item] {
  def eval(product: Product): Unit = {
    product.items.foreach(f => collect(f))

When I use this with the "LATERAL TABLE" expression, I get the following
org.apache.flink.table.api.ValidationException: SQL validation failed. From
line 1, column 55 to line 1, column 75: No match found for function
signature unnest_array(<COMPOSITE&lt;my case class definition>

Do you have any idea about that?


Sent from: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/

View raw message