Flink SQL validation failed. From line 1, column 89 to line 1, column 111: List of column aliases

SQL validation failed. From line 1, column 89 to line 1, column 111: List of column aliases must have same degree as table; table has 1 columns ('f0'), whereas alias list has 3 columns
at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:125)

解决方法:

//正确
    public static class SplitTF4 extends TableFunction<Row> {
        public void eval(String s) {
            Row row = Row.of(s.split("_")[0], s.split("_")[1], s.split("_")[1].length());
            collect(row);
        }
 
        //这个方法很重要,不写的话会报错!!!!
        //SQL validation failed. From line 1, column 89 to line 1, column 111: List of column aliases must have same degree as table; table has 1 columns ('f0'), whereas alias list has 3 columns
        //at org.apache.flink.table.planner.calcite.FlinkPlannerImpl.validate(FlinkPlannerImpl.scala:125)
        @Override
        public TypeInformation<Row> getResultType() {
            return Types.ROW(Types.STRING, Types.STRING, Types.INT);
        }
    }

详见我的:

https://programskills.blog.csdn.net/article/details/115659556

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页