You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Mikhail (JIRA)" <ji...@apache.org> on 2018/08/23 10:38:00 UTC

[jira] [Commented] (FLINK-9391) Support UNNEST in Table API

    [ https://issues.apache.org/jira/browse/FLINK-9391?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16590055#comment-16590055 ] 

Mikhail commented on FLINK-9391:
--------------------------------

Hello [~twalthr],

As I know, [~ipatina] is on another project. So I'd like to continue Alina's work.

I already found out that if we want to select with unnest from table:
{code:java}
@Test
def testUnnest(): Unit = {
val env: ExecutionEnvironment = ExecutionEnvironment.getExecutionEnvironment
val tEnv = TableEnvironment.getTableEnvironment(env, config)

val data = new mutable.MutableList[(Int, Long, Array[String])]
data.+=((1, 1L, Array("Hi", "w")))
data.+=((2, 2L, Array("Hello", "k")))
data.+=((3, 2L, Array("Hello world", "x")))
val input = env.fromCollection(Random.shuffle(data)).toTable(tEnv).as('a, 'b, 'c)

val unnested = input.select('a, 'b, 'c.unnest())

val actual = unnested.toDataSet[Row].collect()

val expected = List("1,Hi", "1,w", "2,Hello", "2,k", "3,Hello world", "3,x").mkString("\n")
TestBaseUtils.compareResultAsText(actual.asJava, expected)
}
{code}
Then there will be generated code for a function in DataSetCalc#translateToPlan for processing input data. That code will be compiled and executed.

That code will be generated using CommonCalc#generateFunction which will process each element in a Row separately.

So final output for a Row in a table will contain single Row.

But for our case with UNNEST we need to have another flow.

[~twalthr], could you please suggest where to look at?

> Support UNNEST in Table API
> ---------------------------
>
>                 Key: FLINK-9391
>                 URL: https://issues.apache.org/jira/browse/FLINK-9391
>             Project: Flink
>          Issue Type: New Feature
>          Components: Table API &amp; SQL
>            Reporter: Timo Walther
>            Assignee: Alina Ipatina
>            Priority: Major
>
> FLINK-6033 introduced the UNNEST function for SQL. We should also add this function to the Table API to keep the APIs in sync. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)