本文为您介绍作业开发有关的常见问题。
- 使用Entrypoint Main Args配置参数时,传入参数包含空格,作业无法运行起来,应该如何处理?
- 为什么相同JAR包经多次修改后上传失败?
- 报错:Could not parse type at position 50: expected but was . Input type string: ROW
使用Entrypoint Main Args配置参数时,传入参数包含空格,作业无法运行起来,应该如何处理?
- 问题详细
- 问题原因
在VVR为4.x版本时,如果Entrypoint Main Args的参数中间有空格,且整体参数外部没有加双引号,那么中间的空格就会被解析成分号,且作业可能无法运行起来。
- 解决方案
将Entrypoint Main Args参数写为
"--name \"where a = b\""
,即在外部添加一个双引号。修改后能够正常解析内部空格,并且作业能够正常运行。
为什么相同JAR包经多次修改后上传失败?
- 问题原因
因为UDF里面限制了JAR包之间的类名不能重复。
- 解决方案
在附加依赖文件里面上传JAR包,并在代码里面使用临时函数的方式,示例如下。
CREATE TEMPORARY FUNCTION `cp_record_reduce` AS 'com.taobao.test.udf.blink.CPRecordReduceUDF';
报错:Could not parse type at position 50: expected but was . Input type string: ROW
- 报错详情
用户在SQL编辑器中编写SQL时,使用UDTF出现语法检查错误(红色波浪线)。
Caused by: org.apache.flink.table.api.ValidationException: Could not parse type at position 50: <IDENTIFIER> expected but was <KEYWORD>. Input type string: ROW<resultId String,pointRange String,from String,to String,type String,pointScope String,userId String,point String,triggerSource String,time String,uuid String>
代码如下:@FunctionHint( //input = @DataTypeHint("BYTES"), output = @DataTypeHint("ROW<resultId String,pointRange String,from String,to String,type String,pointScope String,userId String,point String,triggerSource String,time String,uuid String>")) public class PointChangeMetaQPaser1 extends TableFunction<Row> { Logger logger = LoggerFactory.getLogger(this.getClass().getName()); public void eval(byte[] bytes) { try { String messageBody = new String(bytes, "UTF-8"); Map<String, String> resultDO = JSON.parseObject(messageBody, Map.class); logger.info("PointChangeMetaQPaser1 logger:" + JSON.toJSONString(resultDO)); collect(Row.of( getString(resultDO.get("resultId")), getString(resultDO.get("pointRange")), getString(resultDO.get("from")), getString(resultDO.get("to")), getString(resultDO.get("type")), getString(resultDO.get("pointScope")), getString(resultDO.get("userId")), getString(resultDO.get("point")), getString(resultDO.getOrDefault("triggerSource", "NULL")), getString(resultDO.getOrDefault("time", String.valueOf(System.currentTimeMillis()))), getString(resultDO.getOrDefault("uuid", String.valueOf(UUID.randomUUID()))) )); } catch (Exception e) { logger.error("PointChangeMetaQPaser1 error", e); } } private String getString(Object o) { if (o == null) { return null; } return String.valueOf(o); } }
- 报错原因
当使用DataTypeHint定义函数的数据类型时,将系统保留的关键字直接作为了字段名称。
- 解决方案
- 将变量名换成非关键字的名称,例如to换成fto,from换成ffrom等。
- 将已经用关键字取名的变量名加上反撇号(``)。