@Override public void analyze(Analyzer analyzer) throws AnalysisException, AuthorizationException { // For now, if authorization is enabled, the user needs ALL on the server // to create functions. // TODO: this is not the right granularity but acceptable for now. analyzer.getCatalog().checkCreateDropFunctionAccess(analyzer.getUser()); // Validate function name is legal fn_.getFunctionName().analyze(analyzer); // Validate DB is legal String dbName = analyzer.getTargetDbName(fn_.getFunctionName()); fn_.getFunctionName().setDb(dbName); if (analyzer.getCatalog().getDb(dbName, analyzer.getUser(), Privilege.CREATE) == null) { throw new AnalysisException(Analyzer.DB_DOES_NOT_EXIST_ERROR_MSG + dbName); } Function existingFn = analyzer.getCatalog().getFunction(fn_, Function.CompareMode.IS_INDISTINGUISHABLE); if (existingFn != null && !ifNotExists_) { throw new AnalysisException( Analyzer.FN_ALREADY_EXISTS_ERROR_MSG + existingFn.signatureString()); } fn_.getLocation().analyze(analyzer, Privilege.CREATE); // Check the file type from the binary type to infer the type of the UDA fn_.setBinaryType(getBinaryType()); }
@Override public void analyze(Analyzer analyzer) throws AnalysisException, AuthorizationException { // For now, if authorization is enabled, the user needs ALL on the server // to drop functions. // TODO: this is not the right granularity but acceptable for now. analyzer.getCatalog().checkCreateDropFunctionAccess(analyzer.getUser()); desc_.getFunctionName().analyze(analyzer); String dbName = analyzer.getTargetDbName(desc_.getFunctionName()); desc_.getFunctionName().setDb(dbName); if (analyzer.getCatalog().getDb(dbName, analyzer.getUser(), Privilege.DROP) == null && !ifExists_) { throw new AnalysisException(Analyzer.DB_DOES_NOT_EXIST_ERROR_MSG + dbName); } if (analyzer.getCatalog().getFunction(desc_, Function.CompareMode.IS_IDENTICAL) == null && !ifExists_) { throw new AnalysisException(Analyzer.FN_DOES_NOT_EXIST_ERROR_MSG + desc_.signatureString()); } }