AWS Kinesis SQL的问题-随机砍伐森林算法

问题描述

我在AWS Kinesis应用程序中有以下代码

CREATE OR REPLACE STREAM "OUT_FILE" (
        "fechaTS"              timestamp,"celda"                varchar(25),"Field1"               DOUBLE,"Field2"               DOUBLE,"ANOMALY_score"        DOUBLE,"ANOMALY_EXPLANATION"  varchar(1024)
        );

CREATE OR REPLACE PUMP "PMP_OUT" AS
   INSERT INTO "OUT_FILE"
      SELECT STREAM 
        "fechaTS","celda","Field1","Field2","ANOMALY_score","ANOMALY_EXPLANATION"
      FROM TABLE(RANDOM_CUT_FOREST_WITH_EXPLANATION(
                 CURSOR(SELECT STREAM * FROM "SOURCE_sql_STREAM_001"),300,512,8064,4,true))
  WHERE "celda" = 'CELLNUMBER' 
         ;

我只是希望每个输入记录的异常分数计算的常规输出

相反,我收到此错误消息:

Number of numeric attributes should be less than or equal to 30 (Please check the documentation to kNow the supported numeric sql types)

我输入到模型中的数字属性数量仅为2。另一方面,根据文档,受支持sql数字类型为:DOUBLE,INTEGER,FLOAT,tinyint,SMALLINT,REAL和BIGINT。 (我也尝试过FLOAT)。

我在做什么错了?

解决方法

解决方案是在输入架构级别将变量定义为DOUBLE(或其他可接受的类型):在SQL中将它们定义为DOUBLE是不够的。

我尝试过这样的JSON并起作用:

{"ApplicationName": "<myAppName>","Inputs": [{
   "InputSchema": {
            "RecordColumns": [{"Mapping": "fechaTS","Name": "fechaTS","SqlType": "timestamp"},{"Mapping": "celda","Name": "celda","SqlType": "varchar(25)"},{"Mapping": "Field1","Name": "Field1","SqlType": "DOUBLE"},{"Mapping": "Field2","Name": "Field2",{"Mapping": "Field3","Name": "Field3","SqlType": "DOUBLE"}],"RecordFormat": {"MappingParameters": {"JSONMappingParameters": {"RecordRowPath": "$"}},"RecordFormatType": "JSON"}
            },"KinesisStreamsInput": {"ResourceARN": "<myInputARN>","RoleARN": "<myRoleARN>"},"NamePrefix": "<myNamePrefix>"
    }]
  }

其他信息:如果将此JSON保存在myJson.json中,则发出以下命令:

aws kinesisanalytics create-application --cli-input-json file://myJson.json

AWS命令行界面(CLI)必须事先安装和配置。