0

I have data stored in Tuples like Tuple6 and I make SQL statements like select f1 from test. My problem is I want to set column names instead of f1, f2, f3. Can I still have Tuple and set column Names?

Some code Input format

public Tuple6<Long, Integer, String, String, String, Double> nextRecord(Tuple6<Long, Integer, String, String, String, Double> row) throws IOException {
    col1 = (IntValue) cfr.getRow()[0];
    col2 = (IntValue) cfr.getRow()[1];
    col3 = (StringValue) cfr.getRow()[2];
    col4 = (StringValue) cfr.getRow()[3];
    col5 = (StringValue) cfr.getRow()[4];
    col6 = (DoubleValue) cfr.getRow()[5];
    row.f0 = Long.valueOf(col1.getValue());
    row.f1 = col2.getValue();
    row.f2 = col3.getValue();
    row.f3 = col4.getValue();
    row.f4 = col5.getValue();
    row.f5 = col6.getValue();
    return row;
}  @Override
public TypeInformation<Tuple6<Long,Integer, String, String, String, Double>> getProducedType() {
    return type;
}

static TypeInformation[] columns = {
        TypeInformation.of(Long.class),
        TypeInformation.of(Integer.class),
        TypeInformation.of(String.class),
        TypeInformation.of(String.class),
        TypeInformation.of(String.class),
        TypeInformation.of(Double.class)
};

static TupleTypeInfo<Tuple6<Long, Integer, String, String, String, Double>> type = new TupleTypeInfo<>(columns);

And here some Code TableSource

     @Override
public TableSchema getTableSchema() {
    return new TableSchema(WorkloadColunarInputFormat.type.getFieldNames(),WorkloadColunarInputFormat.columns);
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
dfvt
  • 87
  • 2
  • 12
  • Could you support the issue with some code? Or describe in more detail? – Alex Mar 05 '18 at 17:57
  • @Beckham Added more code. I have implemented InputFormat and and tableSource and i can do things like this Table r = tenv.sqlQuery("select f1, sum(f0) from test group by f1 "); But I want to set Column Names – dfvt Mar 05 '18 at 18:30

0 Answers0