org.apache.hadoop.hive.metastore.api.Function.getDbName()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(11.3k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中org.apache.hadoop.hive.metastore.api.Function.getDbName()方法的一些代码示例,展示了Function.getDbName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Function.getDbName()方法的具体详情如下:
包路径:org.apache.hadoop.hive.metastore.api.Function
类名称:Function
方法名:getDbName

Function.getDbName介绍

暂无

代码示例

代码示例来源:origin: apache/hive

public JSONCreateFunctionMessage(String server, String servicePrincipal, Function fn, Long timestamp) {
 this.server = server;
 this.servicePrincipal = servicePrincipal;
 this.db = fn.getDbName();
 this.timestamp = timestamp;
 try {
  this.functionObjJson = MessageBuilder.createFunctionObjJson(fn);
 } catch (TException ex) {
  throw new IllegalArgumentException("Could not serialize Function object", ex);
 }
 checkValid();
}

代码示例来源:origin: apache/hive

public JSONCreateFunctionMessage(String server, String servicePrincipal, Function fn, Long timestamp) {
 this.server = server;
 this.servicePrincipal = servicePrincipal;
 this.db = fn.getDbName();
 this.timestamp = timestamp;
 try {
  this.functionObjJson = MessageBuilder.createFunctionObjJson(fn);
 } catch (TException ex) {
  throw new IllegalArgumentException("Could not serialize Function object", ex);
 }
 checkValid();
}

代码示例来源:origin: apache/hive

public JSONDropFunctionMessage(String server, String servicePrincipal, Function fn, Long timestamp) {
 this.server = server;
 this.servicePrincipal = servicePrincipal;
 this.db = fn.getDbName();
 this.timestamp = timestamp;
 try {
  this.functionObjJson = MessageBuilder.createFunctionObjJson(fn);
 } catch (TException ex) {
  throw new IllegalArgumentException("Could not serialize Function object", ex);
 }
 checkValid();
}

代码示例来源:origin: apache/hive

private FunctionDescBuilder(Context context) throws SemanticException {
 this.context = context;
 try {
  FileSystem fs = FileSystem.get(new Path(context.location).toUri(), context.hiveConf);
  metadata = EximUtil.readMetaData(fs, new Path(context.location, EximUtil.METADATA_NAME));
 } catch (IOException e) {
  throw new SemanticException(ErrorMsg.INVALID_PATH.getMsg(), e);
 }
 destinationDbName = context.isDbNameEmpty() ? metadata.function.getDbName() : context.dbName;
}

代码示例来源:origin: apache/hive

public JSONDropFunctionMessage(String server, String servicePrincipal, Function fn, Long timestamp) {
 this.server = server;
 this.servicePrincipal = servicePrincipal;
 this.db = fn.getDbName();
 this.functionName = fn.getFunctionName();
 this.timestamp = timestamp;
 checkValid();
}

代码示例来源:origin: apache/hive

private boolean isFunctionAlreadyLoaded(Path funcDumpRoot) throws HiveException, IOException {
 Path metadataPath = new Path(funcDumpRoot, EximUtil.METADATA_NAME);
 FileSystem fs = FileSystem.get(metadataPath.toUri(), context.hiveConf);
 MetaData metadata = EximUtil.readMetaData(fs, metadataPath);
 Function function;
 try {
  String dbName = StringUtils.isBlank(dbNameToLoadIn) ? metadata.function.getDbName() : dbNameToLoadIn;
  function = context.hiveDb.getFunction(dbName, metadata.function.getFunctionName());
 } catch (HiveException e) {
  if (e.getCause() instanceof NoSuchObjectException) {
   return false;
  }
  throw e;
 }
 return (function != null);
}

代码示例来源:origin: apache/hive

@Test(expected = NoSuchObjectException.class)
public void testGetFunctionNoSuchFunction() throws Exception {
 // Choosing the 2nd function, since the 1st one is duplicated in the dummy database
 Function function = testFunctions[1];
 client.getFunction(function.getDbName(), "no_such_function");
}

代码示例来源:origin: apache/hive

public void reloadFunctions() throws HiveException {
 HashSet<String> registryFunctions = new HashSet<String>(
   FunctionRegistry.getFunctionNames(".+\\..+"));
 for (Function function : getAllFunctions()) {
  String functionName = function.getFunctionName();
  try {
   LOG.info("Registering function " + functionName + " " + function.getClassName());
   String qualFunc = FunctionUtils.qualifyFunctionName(functionName, function.getDbName());
   FunctionRegistry.registerPermanentFunction(qualFunc, function.getClassName(), false,
         FunctionTask.toFunctionResource(function.getResourceUris()));
   registryFunctions.remove(qualFunc);
  } catch (Exception e) {
   LOG.warn("Failed to register persistent function " +
       functionName + ":" + function.getClassName() + ". Ignore and continue.");
  }
 }
 // unregister functions from local system registry that are not in getAllFunctions()
 for (String functionName : registryFunctions) {
  try {
   FunctionRegistry.unregisterPermanentFunction(functionName);
  } catch (Exception e) {
   LOG.warn("Failed to unregister persistent function " +
     functionName + "on reload. Ignore and continue.");
  }
 }
}

代码示例来源:origin: apache/hive

public void startLocalizeAllFunctions() throws HiveException {
 Hive hive = Hive.get(false);
 // Do not allow embedded metastore in LLAP unless we are in test.
 try {
  hive.getMSC(HiveConf.getBoolVar(conf, ConfVars.HIVE_IN_TEST), true);
 } catch (MetaException e) {
  throw new HiveException(e);
 }
 List<Function> fns = hive.getAllFunctions();
 for (Function fn : fns) {
  String fqfn = fn.getDbName() + "." + fn.getFunctionName();
  List<ResourceUri> resources = fn.getResourceUris();
  if (resources == null || resources.isEmpty()) continue; // Nothing to localize.
  FnResources result = new FnResources();
  resourcesByFn.put(fqfn, result);
  workQueue.add(new LocalizeFn(fqfn, resources, result, fn.getClassName(), false));
 }
 workQueue.add(new RefreshClassloader());
}

代码示例来源:origin: apache/hive

@Test(expected = MetaException.class)
public void testAlterFunctionAlreadyExists() throws Exception {
 Function originalFunction = testFunctions[0];
 Function newFunction = testFunctions[1];
 client.alterFunction(originalFunction.getDbName(), originalFunction.getFunctionName(),
   newFunction);
}

代码示例来源:origin: apache/hive

@Test(expected = MetaException.class)
public void testAlterFunctionNoSuchFunction() throws Exception {
 // Choosing the 2nd function, since the 1st one is duplicated in the dummy database
 Function originalFunction = testFunctions[1];
 Function newFunction = getNewFunction();
 client.alterFunction(originalFunction.getDbName(), "no_such_function", newFunction);
}

代码示例来源:origin: apache/hive

@Override
public void createFunction(Function func) throws InvalidObjectException, MetaException {
 if (callerVerifier != null) {
  CallerArguments args = new CallerArguments(func.getDbName());
  args.funcName = func.getFunctionName();
  Boolean success = callerVerifier.apply(args);
  if ((success != null) && !success) {
   throw new MetaException("InjectableBehaviourObjectStore: Invalid Create Function operation on DB: "
       + args.dbName + " function: " + args.funcName);
  }
 }
 super.createFunction(func);
}

代码示例来源:origin: apache/hive

@Test
public void testGetFunctionCaseInsensitive() throws Exception {
 Function function = testFunctions[0];
 // Test in upper case
 Function resultUpper = client.getFunction(function.getDbName().toUpperCase(),
   function.getFunctionName().toUpperCase());
 Assert.assertEquals("Comparing functions", function, resultUpper);
 // Test in mixed case
 Function resultMix = client.getFunction("DeFaUlt", "tEsT_FuncTION_tO_FinD_1");
 Assert.assertEquals("Comparing functions", function, resultMix);
}

代码示例来源:origin: apache/hive

public Object getFieldValue(_Fields field) {
 switch (field) {
 case FUNCTION_NAME:
  return getFunctionName();
 case DB_NAME:
  return getDbName();
 case CLASS_NAME:
  return getClassName();
 case OWNER_NAME:
  return getOwnerName();
 case OWNER_TYPE:
  return getOwnerType();
 case CREATE_TIME:
  return getCreateTime();
 case FUNCTION_TYPE:
  return getFunctionType();
 case RESOURCE_URIS:
  return getResourceUris();
 case CAT_NAME:
  return getCatName();
 }
 throw new IllegalStateException();
}

代码示例来源:origin: apache/hive

private MFunction convertToMFunction(Function func) throws InvalidObjectException {
 if (func == null) {
  return null;
 }
 MDatabase mdb = null;
 String catName = func.isSetCatName() ? func.getCatName() : getDefaultCatalog(conf);
 try {
  mdb = getMDatabase(catName, func.getDbName());
 } catch (NoSuchObjectException e) {
  LOG.error("Database does not exist", e);
  throw new InvalidObjectException("Database " + func.getDbName() + " doesn't exist.");
 }
 MFunction mfunc = new MFunction(func.getFunctionName(),
   mdb,
   func.getClassName(),
   func.getOwnerName(),
   func.getOwnerType().name(),
   func.getCreateTime(),
   func.getFunctionType().getValue(),
   convertToMResourceUriList(func.getResourceUris()));
 return mfunc;
}

代码示例来源:origin: apache/hive

@Test
public void testDropFunctionCaseInsensitive() throws Exception {
 Function function = testFunctions[0];
 // Test in upper case
 client.dropFunction(function.getDbName().toUpperCase(),
   function.getFunctionName().toUpperCase());
 // Check if the function is really removed
 try {
  client.getFunction(function.getDbName(), function.getFunctionName());
  Assert.fail("Expected a NoSuchObjectException to be thrown");
 } catch (NoSuchObjectException exception) {
  // Expected exception
 }
 // Test in mixed case
 client.createFunction(function);
 client.dropFunction("DeFaUlt", "tEsT_FuncTION_tO_FinD_1");
 // Check if the function is really removed
 try {
  client.getFunction(function.getDbName(), function.getFunctionName());
  Assert.fail("Expected a NoSuchObjectException to be thrown");
 } catch (NoSuchObjectException exception) {
  // Expected exception
 }
}

代码示例来源:origin: apache/hive

/**
 * @param fnEvent function event
 * @throws MetaException
 */
@Override
public void onDropFunction(DropFunctionEvent fnEvent) throws MetaException {
 Function fn = fnEvent.getFunction();
 DropFunctionMessage msg = MessageBuilder.getInstance().buildDropFunctionMessage(fn);
 NotificationEvent event =
   new NotificationEvent(0, now(), EventType.DROP_FUNCTION.toString(),
     msgEncoder.getSerializer().serialize(msg));
 event.setCatName(fn.isSetCatName() ? fn.getCatName() : DEFAULT_CATALOG_NAME);
 event.setDbName(fn.getDbName());
 process(event, fnEvent);
}

代码示例来源:origin: apache/hive

/**
 * @param fnEvent function event
 * @throws MetaException
 */
@Override
public void onCreateFunction(CreateFunctionEvent fnEvent) throws MetaException {
 Function fn = fnEvent.getFunction();
 CreateFunctionMessage msg = MessageBuilder.getInstance()
   .buildCreateFunctionMessage(fn);
 NotificationEvent event =
   new NotificationEvent(0, now(), EventType.CREATE_FUNCTION.toString(),
     msgEncoder.getSerializer().serialize(msg));
 event.setCatName(fn.isSetCatName() ? fn.getCatName() : DEFAULT_CATALOG_NAME);
 event.setDbName(fn.getDbName());
 process(event, fnEvent);
}

代码示例来源:origin: apache/hive

private void validateFunctionInfo(Function func) throws InvalidObjectException, MetaException {
 if (func == null) {
  throw new MetaException("Function cannot be null.");
 }
 if (func.getFunctionName() == null) {
  throw new MetaException("Function name cannot be null.");
 }
 if (func.getDbName() == null) {
  throw new MetaException("Database name in Function cannot be null.");
 }
 if (!MetaStoreUtils.validateName(func.getFunctionName(), null)) {
  throw new InvalidObjectException(func.getFunctionName() + " is not a valid object name");
 }
 String className = func.getClassName();
 if (className == null) {
  throw new InvalidObjectException("Function class name cannot be null");
 }
 if (func.getOwnerType() == null) {
  throw new MetaException("Function owner type cannot be null.");
 }
 if (func.getFunctionType() == null) {
  throw new MetaException("Function type cannot be null.");
 }
}

代码示例来源:origin: apache/hive

@Test
public void testCreateFunctionDefaultValues() throws Exception {
 Function function = new Function();
 function.setDbName(OTHER_DATABASE);
 function.setFunctionName("test_function");
 function.setClassName(TEST_FUNCTION_CLASS);
 function.setOwnerType(PrincipalType.USER);
 function.setFunctionType(FunctionType.JAVA);
 client.createFunction(function);
 Function createdFunction = client.getFunction(function.getDbName(),
   function.getFunctionName());
 Assert.assertNull("Comparing OwnerName", createdFunction.getOwnerName());
 Assert.assertEquals("Comparing ResourceUris", 0, createdFunction.getResourceUris().size());
 // The create time is set
 Assert.assertNotEquals("Comparing CreateTime", 0, createdFunction.getCreateTime());
}

相关文章