Hi Leonard,

The tuple fields can also be referenced as their POJO names (f0, f1), they
can be reordered similar to pojo fields, however you cannot alias them. (If
you look at the link I have sent that shows how it is supposed to work but
it throws an exception when I try it)
Also what I am trying to do at the end is to flatten a nested tuple:

Tuple2<String, Tuple2<Integer, Integer>> -> into 3 columns, lets say name,
age, height

Normally I would write this: tableEnv.fromDataStream(input, “f0 as name,
f1.f0 as age, f1.f1 as height");
However this doesnt work and there seem to be no way to assign names to the
nested tuple columns anyways.

For Pojo aliasing works  but still I cannot find a way to unnest a nested
object:

public static class Person {
  public String name;
  public public Tuple2<Integer, Integer> details;
}

tableEnv.fromDataStream(persons, "name, details.f0 as age, details.f1 as
height")

this leads to an error:
Field reference expression or alias on field expression expected.

Aliasing fields also doesn't work when converting from Row stream even if
the column names are provided in the type info.

Cheers,
Gyula

On Mon, Apr 27, 2020 at 3:33 PM Leonard Xu <xbjt...@gmail.com> wrote:

> Hi,  gyula.fora
>
> If you’re trying convert Table from a Tuple DataStream, Alias the filed by
> `as` expression is no supported yet,
> because all fields are referenced by position in this point. You can
> simply alias like following syntax:
> ```
> tableEnv.fromDataStream(env.fromElements(Tuple2.of("a", 1)), “name, age");
> ```
> This should satisfy  your purpose. And back to the 1.10 docs, If you are
> converting Table from a
> POJO(assuming the POJO person has two fields name and age) DataStream,
> Alias the filed by `as` is supported
> because this point all fields are referenced by name, like:
> ```
> tableEnv.fromDataStream(env.fromElements(new Person(“foo", 12)), “age as
> age_alias, name as user_name,");
> ```
>
>
> Best,
> Leonard, Xu

Reply via email to