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

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

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

Function.getFunctionName介绍

暂无

代码示例

代码示例来源: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 testDropFunctionNoSuchFunctionInThisDatabase() throws Exception {
 // Choosing the 2nd function, since the 1st one is duplicated in the dummy database
 Function function = testFunctions[1];
 client.dropFunction(OTHER_DATABASE, function.getFunctionName());
}

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

@Test(expected = MetaException.class)
public void testAlterFunctionNullFunction() throws Exception {
 Function originalFunction = testFunctions[1];
 client.alterFunction(DEFAULT_DATABASE, originalFunction.getFunctionName(), null);
}

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

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

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

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

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

@Test(expected = NoSuchObjectException.class)
public void dropNoSuchCatalog() throws TException {
 client.dropFunction("nosuch", DEFAULT_DATABASE_NAME, testFunctions[0].getFunctionName());
}

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

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

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

@Test(expected = NoSuchObjectException.class)
public void getNoSuchCatalog() throws TException {
 client.getFunction("nosuch", DEFAULT_DATABASE_NAME, testFunctions[0].getFunctionName());
}

代码示例来源: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

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

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 testAlterFunctionNoSuchDatabase() 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("no_such_database", originalFunction.getFunctionName(), newFunction);
}

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

@Test(expected = MetaException.class)
public void testAlterFunctionNoSuchFunctionInThisDatabase() 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(OTHER_DATABASE, originalFunction.getFunctionName(), 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 createDestinationPath() throws IOException, SemanticException, URISyntaxException {
  mockStatic(FileSystem.class);
  when(FileSystem.get(any(Configuration.class))).thenReturn(mockFs);
  when(FileSystem.get(any(URI.class), any(Configuration.class))).thenReturn(mockFs);
  when(mockFs.getScheme()).thenReturn("hdfs");
  when(mockFs.getUri()).thenReturn(new URI("hdfs", "somehost:9000", null, null, null));
  mockStatic(System.class);
  when(System.nanoTime()).thenReturn(Long.MAX_VALUE);
  when(functionObj.getFunctionName()).thenReturn("someFunctionName");
  mockStatic(ReplCopyTask.class);
  Task mock = mock(Task.class);
  when(ReplCopyTask.getLoadCopyTask(any(ReplicationSpec.class), any(Path.class), any(Path.class),
    any(HiveConf.class))).thenReturn(mock);

  ResourceUri resourceUri = function.destinationResourceUri(new ResourceUri(ResourceType.JAR,
    "hdfs://localhost:9000/user/someplace/ab.jar#e094828883"));

  assertThat(resourceUri.getUri(),
    is(equalTo(
      "hdfs://somehost:9000/someBasePath/withADir/replicadbname/somefunctionname/" + String
        .valueOf(Long.MAX_VALUE) + "/ab.jar")));
 }
}

代码示例来源: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

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 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());
}

相关文章