harbby / presto-connectors

facebook presto connectors
Apache License 2.0
49 stars 22 forks source link

安装插件失败,public io.airlift.slice.Slice com.facebook.presto.elasticsearch6.functions.MatchQueryFunction.matchQuery(io.airlift.slice.Slice)] is an instance method. It must be in a class annotated with @ScalarFunction, and the class is required to have a public constructor. #5

Closed BobEnya closed 5 years ago

BobEnya commented 5 years ago

2018-11-08T11:42:12.819+0800 ERROR main com.facebook.presto.server.PrestoServer Method [public io.airlift.slice.Slice com.facebook.presto.elasticsearch6.functions.MatchQueryFunction.matchQuery(io.airlift.slice.Slice)] is an instance method. It must be in a class annotated with @ScalarFunction, and the class is required to have a public constructor. java.lang.IllegalArgumentException: Method [public io.airlift.slice.Slice com.facebook.presto.elasticsearch6.functions.MatchQueryFunction.matchQuery(io.airlift.slice.Slice)] is an instance method. It must be in a class annotated with @ScalarFunction, and the class is required to have a public constructor. at com.google.common.base.Preconditions.checkArgument(Preconditions.java:210) at com.facebook.presto.operator.scalar.annotations.ParametricScalarImplementation$Parser.getConstructor(ParametricScalarImplementation.java:646) at com.facebook.presto.operator.scalar.annotations.ParametricScalarImplementation$Parser.(ParametricScalarImplementation.java:513) at com.facebook.presto.operator.scalar.annotations.ParametricScalarImplementation$Parser.parseImplementation(ParametricScalarImplementation.java:710) at com.facebook.presto.operator.scalar.annotations.ScalarFromAnnotationsParser.parseParametricScalar(ScalarFromAnnotationsParser.java:106) at com.facebook.presto.operator.scalar.annotations.ScalarFromAnnotationsParser.parseFunctionDefinitions(ScalarFromAnnotationsParser.java:60) at com.facebook.presto.metadata.FunctionExtractor.extractFunctions(FunctionExtractor.java:57) at com.facebook.presto.server.PluginManager.installPlugin(PluginManager.java:200) at com.facebook.presto.server.PluginManager.loadPlugin(PluginManager.java:172) at com.facebook.presto.server.PluginManager.loadPlugin(PluginManager.java:156) at com.facebook.presto.server.PluginManager.loadPlugins(PluginManager.java:137) at com.facebook.presto.server.PrestoServer.run(PrestoServer.java:117) at com.facebook.presto.server.PrestoServer.main(PrestoServer.java:67)

icelemonna commented 5 years ago

遇到过这个问题,参考了其他plugin里面函数的声明方式,把matchQuery和matchPhrase声明为public static,再给类加一个private的构造函数,内容为空即可。

image

BobEnya commented 5 years ago

改了,但是又有其他问题 2018-11-08T18:19:07.738+0800 ERROR main com.facebook.presto.server.PrestoServer No factory for connector presto-elasticsearch6-0.210 java.lang.IllegalArgumentException: No factory for connector presto-elasticsearch6-0.210

遇到过这个问题,参考了其他plugin里面函数的声明方式,把matchQuery和matchPhrase声明为public static,再给类加一个private的构造函数,内容为空即可。

image

ciscoring commented 5 years ago

I had same issues. I changed the codes below. convert all methods of MatchQueryFunction to static. ` public class MatchQueryFunction { public static final String MATCH_COLUMN_SEP = "_%s@#$%^&*()+~";

@ScalarFunction("match_query")
@Description("es match_query")
@SqlType(StandardTypes.VARCHAR)
@SqlNullable
public static Slice matchQuery(
        @SqlType(StandardTypes.VARCHAR) Slice filter)
{
    if (filter == null) {
        return null;
    }
    String filterStr = filter.toStringUtf8();

    QueryBuilder builder = QueryBuilders.matchQuery(MATCH_COLUMN_SEP, filterStr);
    return Slices.utf8Slice(builder.toString());
}

@ScalarFunction("match_phrase")
@Description("es match_phrase")
@SqlType(StandardTypes.VARCHAR)
@SqlNullable
public static Slice matchPhrase(
        @SqlType(StandardTypes.VARCHAR) Slice filter)
{
    if (filter == null) {
        return null;
    }
    String filterStr = filter.toStringUtf8();

    QueryBuilder builder = QueryBuilders.matchPhraseQuery(MATCH_COLUMN_SEP, filterStr);
    return Slices.utf8Slice(builder.toString());
}

} `

harbby commented 5 years ago

这个应该是0.210版本 检查的更加严格所致,我会尽快进行测试和更正

ciscoring notifications@github.com 于2018年11月9日周五 下午3:49写道:

I had same issues. I changed the codes below. convert all methods of MatchQueryFunction to static. `/**

-

输入bitmap 输出该bitmap的值

/ public class MatchQueryFunction { public static final String MATCH_COLUMN_SEP = "__%s@#$%^&()_+~";

@ScalarFunction("match_query") @description https://github.com/description("es match_query") @SqlType(StandardTypes.VARCHAR) @SqlNullable public static Slice matchQuery( @SqlType(StandardTypes.VARCHAR) Slice filter) { if (filter == null) { return null; } String filterStr = filter.toStringUtf8();

QueryBuilder builder = QueryBuilders.matchQuery(MATCH_COLUMN_SEP, filterStr);
return Slices.utf8Slice(builder.toString());

}

@ScalarFunction("match_phrase") @description https://github.com/description("es match_phrase") @SqlType(StandardTypes.VARCHAR) @SqlNullable public static Slice matchPhrase( @SqlType(StandardTypes.VARCHAR) Slice filter) { if (filter == null) { return null; } String filterStr = filter.toStringUtf8();

QueryBuilder builder = QueryBuilders.matchPhraseQuery(MATCH_COLUMN_SEP, filterStr);
return Slices.utf8Slice(builder.toString());

} }`

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/harbby/presto-connectors/issues/5#issuecomment-437277945, or mute the thread https://github.com/notifications/unsubscribe-auth/AS5dS-VBQYuVNVfNn3FpRFEjILkbzIixks5utTObgaJpZM4YT9TF .

harbby commented 5 years ago

@ciscoring Thank you for the test, I will change it as soon as possible.

harbby commented 5 years ago

@icelemonna 非常感谢

harbby commented 5 years ago

Corrected, commit f1207d8a095ab3deefddfa51d9878f8eda9c0ac3