1

我正在尝试学习如何进行简单的分析,例如使用 Kinesis Analytics 实时计算价格波动的百分位等级,

我计算每个代码在 1 分钟滑动窗口内的价格波动率,然后尝试对所有代码符号进行百分比排名,并将前 25% 作为选定代码,但是我在 percent_rank 步骤中遇到错误,不确定是因为我没有作为 SQL 专业人士或它只是与运动相关的错误,请分享您的解决方案。提前致谢


CREATE OR REPLACE STREAM "TEMP_STREAM" (
                            ticker_symbol VARCHAR(10), 
                            Change double,
                            Price double);

CREATE OR REPLACE STREAM "RAW_STREAM" (
                            ticker_symbol VARCHAR(10), 
                            price_avg double,
                            price_volatility double);
                            
                            
CREATE OR REPLACE STREAM "DESTINATION_SQL_STREAM" (
                            ticker_symbol VARCHAR(10), 
                            price_avg double,
                            price_volatility double,
                            pr_rank double);
                          
CREATE OR REPLACE PUMP "STREAM_PUMP" AS 
   INSERT INTO "TEMP_STREAM"
      SELECT STREAM ticker_symbol,Change,Price  
      FROM "SOURCE_SQL_STREAM_001"  ;
      
      

CREATE OR REPLACE PUMP "STREAM_PUMP" AS 
   INSERT INTO "RAW_STREAM"
      SELECT STREAM ticker_symbol,
                    AVG(Price) over W1 as price_avg,
                    STDDEV_SAMP(Price) over W1 as price_volatility
      FROM "TEMP_STREAM" 
       WINDOW W1 AS (
              PARTITION BY ticker_symbol 
              RANGE INTERVAL '1' MINUTE PRECEDING) ORDER BY ROWTIME,price_volatility ASC;
              
CREATE OR REPLACE PUMP "OUTPUT_PUMP" AS 
   INSERT INTO "DESTINATION_SQL_STREAM"
      SELECT STREAM ticker_symbol,
                    price_avg, price_volatility,
                     PERCENT_RANK() OVER(ORDER BY ROWTIME,price_volatility ASC) AS pr_rank
                  FROM "RAW_STREAM";

  
There was an issue updating your application. Error message:  Failed SQL command: CREATE OR REPLACE PUMP "OUTPUT_PUMP" AS INSERT INTO "DESTINATION_SQL_STREAM" SELECT STREAM ticker_symbol, price_avg, price_volatility, PERCENT_RANK() OVER(ORDER BY ROWTIME,price_volatility ASC) AS pr_rank FROM "RAW_STREAM". SQL error message: From line 5, column 51 to line 5, column 57: ROWTIME pseudo-column must be in SELECT or ORDER BY clause
4

0 回答 0