imay commented on a change in pull request #468: Support UDF in syntax
URL: https://github.com/apache/incubator-doris/pull/468#discussion_r244279602
##########
File path: fe/src/main/java/org/apache/doris/analysis/CreateFunctionStmt.java
##########
@@ -17,38 +17,129 @@
package org.apache.doris.analysis;
+import com.google.common.collect.ImmutableSortedMap;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.doris.catalog.Catalog;
+import org.apache.doris.catalog.Function;
+import org.apache.doris.catalog.ScalarFunction;
import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.ErrorCode;
+import org.apache.doris.common.ErrorReport;
import org.apache.doris.common.UserException;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+import org.apache.doris.qe.ConnectContext;
-import java.util.List;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.util.Map;
-/**
- * Created by zhaochun on 14-7-30.
- */
-public class CreateFunctionStmt extends StatementBase {
- private final FunctionName functionName;
- private final List<org.apache.doris.catalog.ColumnType> argumentType;
- private final org.apache.doris.catalog.ColumnType returnType;
- private final String soFilePath;
- private final Map<String, String> properties;
- private final boolean isAggregate;
-
- public CreateFunctionStmt(FunctionName functionName,
- List<org.apache.doris.catalog.ColumnType> argumentType,
- org.apache.doris.catalog.ColumnType returnType, String soFilePath,
- Map<String, String> properties, boolean isAggregate) {
+// create a user define function
+public class CreateFunctionStmt extends DdlStmt {
+
+ private final FunctionName functionName;
+ private final boolean isAggregate;
+ private final FunctionArgsDef argsDef;
+ private final TypeDef returnType;
+ private final Map<String, String> properties;
+
+ // needed item set after analyzed
+ private String objectFile;
+ private Function function;
+ private String checksum;
+
+ public CreateFunctionStmt(boolean isAggregate, FunctionName functionName,
FunctionArgsDef argsDef,
+ TypeDef returnType, Map<String, String>
properties) {
this.functionName = functionName;
- this.argumentType = argumentType;
- this.returnType = returnType;
- this.soFilePath = soFilePath;
- this.properties = properties;
this.isAggregate = isAggregate;
+ this.argsDef = argsDef;
+ this.returnType = returnType;
+ if (properties == null) {
+ this.properties = ImmutableSortedMap.of();
+ } else {
+ this.properties = ImmutableSortedMap.copyOf(properties,
String.CASE_INSENSITIVE_ORDER);
+ }
}
+ public FunctionName getFunctionName() { return functionName; }
+ public Function getFunction() { return function; }
+
@Override
- public void analyze(Analyzer analyzer) throws AnalysisException,
UserException {
+ public void analyze(Analyzer analyzer) throws UserException {
super.analyze(analyzer);
+
+ analyzeCommon(analyzer);
+ // check
+ if (isAggregate) {
+ analyzeUda();
+ } else {
+ analyzeUdf();
+ }
+ }
+
+ private void analyzeCommon(Analyzer analyzer) throws AnalysisException {
+ // check function name
+ functionName.analyze(analyzer);
+
+ // check operation privilege
+ if (!Catalog.getCurrentCatalog().getAuth().checkDbPriv(
+ ConnectContext.get(), functionName.getDb(),
PrivPredicate.ADMIN)) {
Review comment:
> Use checkGlobalPriv()
OK
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]