FAILED:SemanticException [错误10014]:第1:21行错误的参数' stock_price_high':

时间:2017-11-27 22:14:20

标签: java hadoop hive user-defined-functions hiveql

我是Hive的新手,我正在尝试在Hive命令行中创建和使用UDF。

我创建了一个Java代码,用于根据样本NYSE数据集计算股票的协方差。以下是Java中的代码:

<body>
  <form id="myForm">
    <div class="sub form-row align-items-center">
      <div class="col">
        <fieldset>
          <h3>
            <legend>Eligibility Test</legend>
          </h3>
        </fieldset>
      </div>
    </div>
    <div class="col">
      <fieldset>
        <div class="col">
          <legend>Have you had your record expunged before?</legend>
          <input type="radio" name="field1" value="0" onclick="getscores1(this)" />
          <label>
            Yes
          </label>
          <input type="radio" name="field1" value="1" onclick="getscores1(this)" />
          <label>
            No
          </label>
        </div>
      </fieldset>
    </div>
    <div class="col">
      <div class="row">
        <fieldset>
          <legend>Do you have any charges pending against you?</legend>
          <input type="radio" name="field2" value=" 0 " onclick="getscores2(this)" />
          <label>
            Yes
          </label>
          <input type="radio" name="field2 " value="1" onclick="getscores2(this)" />
          <label>
            No
          </label>
        </fieldset>
      </div>
    </div>
    <fieldset id="submitbutton">
      <input type="button" id="submit" value="submit" onclick='answer()' />
    </fieldset>
    <p id="totalScore">this is answer </p>

将jar文件添加到hive shell后,我创建了一个名为&#39; cv&#39;并传递参数。

package udf;

import org.apache.hadoop.hive.ql.exec.UDF;

public class CoVariance extends UDF {
    public Double covariance (Double stockpricex, Double stockpricey, Double avgstockpricex, Double avgstockpricey, int tuplecount) {

        if (stockpricex == null|| stockpricey == null || avgstockpricex == null || avgstockpricey == null || tuplecount == 0 ) {
        return null;
        } //check for invalid parameters

        Double covar = ((stockpricex-avgstockpricex)*(stockpricey-avgstockpricey)/(tuplecount - 1));

        return covar.doubleValue();     
    } // return the final co-variance of the stocks

} // end of class

我收到以下错误:

  

失败:SemanticException [错误10014]:第1:21行错误的参数   &#39; stock_price_high&#39;:没有类udf.CoVariance的匹配方法   (double,double,double,double,bigint)。可能的选择:

这里出了什么问题?非常感谢您的帮助。

0 个答案:

没有答案