fix(executor-task): 修复sql语句查询到null字段导致数组越界错误
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.lanyuanxiaoyao.service.executor.task;
|
package com.lanyuanxiaoyao.service.executor.task;
|
||||||
|
|
||||||
import cn.hutool.core.collection.IterUtil;
|
import cn.hutool.core.collection.IterUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import de.vandermeer.asciitable.AsciiTable;
|
import de.vandermeer.asciitable.AsciiTable;
|
||||||
import de.vandermeer.asciitable.CWC_LongestLine;
|
import de.vandermeer.asciitable.CWC_LongestLine;
|
||||||
@@ -18,7 +19,6 @@ import org.apache.flink.util.CloseableIterator;
|
|||||||
import org.apache.hudi.common.table.HoodieTableConfig;
|
import org.apache.hudi.common.table.HoodieTableConfig;
|
||||||
import org.apache.hudi.common.table.HoodieTableMetaClient;
|
import org.apache.hudi.common.table.HoodieTableMetaClient;
|
||||||
import org.apache.hudi.common.table.TableSchemaResolver;
|
import org.apache.hudi.common.table.TableSchemaResolver;
|
||||||
import org.apache.hudi.configuration.FlinkOptions;
|
|
||||||
import org.apache.hudi.org.apache.avro.Schema;
|
import org.apache.hudi.org.apache.avro.Schema;
|
||||||
import org.apache.hudi.util.AvroSchemaConverter;
|
import org.apache.hudi.util.AvroSchemaConverter;
|
||||||
import org.apache.hudi.util.HoodiePipeline;
|
import org.apache.hudi.util.HoodiePipeline;
|
||||||
@@ -89,7 +89,12 @@ public class SQLExecutor {
|
|||||||
table.addRule();
|
table.addRule();
|
||||||
table.addRow(fields.toArray());
|
table.addRow(fields.toArray());
|
||||||
table.addRule();
|
table.addRule();
|
||||||
iterator.forEachRemaining(row -> table.addRow(fields.collect(row::getField).toArray()));
|
iterator.forEachRemaining(row -> {
|
||||||
|
table.addRow(fields.collect(name -> {
|
||||||
|
Object field = row.getField(name);
|
||||||
|
return ObjectUtil.isNull(field) ? "null" : field;
|
||||||
|
}).toArray());
|
||||||
|
});
|
||||||
table.addRule();
|
table.addRule();
|
||||||
table.getRenderer().setCWC(new CWC_LongestLine());
|
table.getRenderer().setCWC(new CWC_LongestLine());
|
||||||
table.getContext().setGridTheme(TA_GridThemes.NONE);
|
table.getContext().setGridTheme(TA_GridThemes.NONE);
|
||||||
|
|||||||
Reference in New Issue
Block a user