本文整理了Java中org.apache.hadoop.hive.ql.metadata.Hive.getDatabasesByPattern()
方法的一些代码示例,展示了Hive.getDatabasesByPattern()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Hive.getDatabasesByPattern()
方法的具体详情如下:
包路径:org.apache.hadoop.hive.ql.metadata.Hive
类名称:Hive
方法名:getDatabasesByPattern
[英]Get all existing databases that match the given pattern. The matching occurs as per Java regular expressions
[中]获取与给定模式匹配的所有现有数据库。匹配按照Java正则表达式进行
代码示例来源:origin: apache/hive
public static Iterable<String> matchesDb(Hive db, String dbPattern) throws HiveException {
if (dbPattern == null) {
return db.getAllDatabases();
} else {
return db.getDatabasesByPattern(dbPattern);
}
}
代码示例来源:origin: apache/drill
private Iterable<? extends String> matchesDb(String dbPattern) throws HiveException {
if (dbPattern == null) {
return db.getAllDatabases();
} else {
return db.getDatabasesByPattern(dbPattern);
}
}
}
代码示例来源:origin: apache/hive
/**
* Write a list of the available databases to a file.
*
* @param showDatabasesDesc
* These are the databases we're interested in.
* @return Returns 0 when execution succeeds and above 0 if it fails.
* @throws HiveException
* Throws this exception if an unexpected error occurs.
*/
private int showDatabases(Hive db, ShowDatabasesDesc showDatabasesDesc) throws HiveException {
// get the databases for the desired pattern - populate the output stream
List<String> databases = null;
if (showDatabasesDesc.getPattern() != null) {
LOG.debug("pattern: {}", showDatabasesDesc.getPattern());
databases = db.getDatabasesByPattern(showDatabasesDesc.getPattern());
} else {
databases = db.getAllDatabases();
}
LOG.info("Found {} database(s) matching the SHOW DATABASES statement.", databases.size());
// write the results in the file
DataOutputStream outStream = getOutputStream(showDatabasesDesc.getResFile());
try {
formatter.showDatabases(outStream, databases);
} catch (Exception e) {
throw new HiveException(e, ErrorMsg.GENERIC_ERROR, "show databases");
} finally {
IOUtils.closeStream(outStream);
}
return 0;
}
代码示例来源:origin: apache/drill
/**
* Write a list of the available databases to a file.
*
* @param showDatabasesDesc
* These are the databases we're interested in.
* @return Returns 0 when execution succeeds and above 0 if it fails.
* @throws HiveException
* Throws this exception if an unexpected error occurs.
*/
private int showDatabases(Hive db, ShowDatabasesDesc showDatabasesDesc) throws HiveException {
// get the databases for the desired pattern - populate the output stream
List<String> databases = null;
if (showDatabasesDesc.getPattern() != null) {
LOG.info("pattern: " + showDatabasesDesc.getPattern());
databases = db.getDatabasesByPattern(showDatabasesDesc.getPattern());
} else {
databases = db.getAllDatabases();
}
LOG.info("results : " + databases.size());
// write the results in the file
DataOutputStream outStream = getOutputStream(showDatabasesDesc.getResFile());
try {
formatter.showDatabases(outStream, databases);
} catch (Exception e) {
throw new HiveException(e, ErrorMsg.GENERIC_ERROR, "show databases");
} finally {
IOUtils.closeStream(outStream);
}
return 0;
}
代码示例来源:origin: apache/hive
@Override
public ASTNode preAnalyze(HiveSemanticAnalyzerHookContext context, ASTNode ast)
throws SemanticException {
Hive db;
try {
db = context.getHive();
} catch (HiveException e) {
throw new SemanticException("Couldn't get Hive DB instance in semantic analysis phase.", e);
}
// Analyze and create tbl properties object
int numCh = ast.getChildCount();
databaseName = BaseSemanticAnalyzer.getUnescapedName((ASTNode) ast.getChild(0));
for (int num = 1; num < numCh; num++) {
ASTNode child = (ASTNode) ast.getChild(num);
switch (child.getToken().getType()) {
case HiveParser.TOK_IFNOTEXISTS:
try {
List<String> dbs = db.getDatabasesByPattern(databaseName);
if (dbs != null && dbs.size() > 0) { // db exists
return ast;
}
} catch (HiveException e) {
throw new SemanticException(e);
}
break;
}
}
return ast;
}
代码示例来源:origin: org.apache.hadoop.hive/hive-exec
if (showDatabasesDesc.getPattern() != null) {
LOG.info("pattern: " + showDatabasesDesc.getPattern());
databases = db.getDatabasesByPattern(showDatabasesDesc.getPattern());
} else {
databases = db.getAllDatabases();
代码示例来源:origin: com.facebook.presto.hive/hive-apache
if (showDatabasesDesc.getPattern() != null) {
LOG.info("pattern: " + showDatabasesDesc.getPattern());
databases = db.getDatabasesByPattern(showDatabasesDesc.getPattern());
} else {
databases = db.getAllDatabases();
代码示例来源:origin: com.facebook.presto.hive/hive-apache
@Override
public ASTNode preAnalyze(HiveSemanticAnalyzerHookContext context, ASTNode ast)
throws SemanticException {
Hive db;
try {
db = context.getHive();
} catch (HiveException e) {
throw new SemanticException("Couldn't get Hive DB instance in semantic analysis phase.", e);
}
// Analyze and create tbl properties object
int numCh = ast.getChildCount();
databaseName = BaseSemanticAnalyzer.getUnescapedName((ASTNode) ast.getChild(0));
for (int num = 1; num < numCh; num++) {
ASTNode child = (ASTNode) ast.getChild(num);
switch (child.getToken().getType()) {
case HiveParser.TOK_IFNOTEXISTS:
try {
List<String> dbs = db.getDatabasesByPattern(databaseName);
if (dbs != null && dbs.size() > 0) { // db exists
return ast;
}
} catch (HiveException e) {
throw new SemanticException(e);
}
break;
}
}
return ast;
}
代码示例来源:origin: org.apache.hive.hcatalog/hive-hcatalog-core
@Override
public ASTNode preAnalyze(HiveSemanticAnalyzerHookContext context, ASTNode ast)
throws SemanticException {
Hive db;
try {
db = context.getHive();
} catch (HiveException e) {
throw new SemanticException("Couldn't get Hive DB instance in semantic analysis phase.", e);
}
// Analyze and create tbl properties object
int numCh = ast.getChildCount();
databaseName = BaseSemanticAnalyzer.getUnescapedName((ASTNode) ast.getChild(0));
for (int num = 1; num < numCh; num++) {
ASTNode child = (ASTNode) ast.getChild(num);
switch (child.getToken().getType()) {
case HiveParser.TOK_IFNOTEXISTS:
try {
List<String> dbs = db.getDatabasesByPattern(databaseName);
if (dbs != null && dbs.size() > 0) { // db exists
return ast;
}
} catch (HiveException e) {
throw new SemanticException(e);
}
break;
}
}
return ast;
}
代码示例来源:origin: com.github.hyukjinkwon.hcatalog/hive-hcatalog-core
@Override
public ASTNode preAnalyze(HiveSemanticAnalyzerHookContext context, ASTNode ast)
throws SemanticException {
Hive db;
try {
db = context.getHive();
} catch (HiveException e) {
throw new SemanticException("Couldn't get Hive DB instance in semantic analysis phase.", e);
}
// Analyze and create tbl properties object
int numCh = ast.getChildCount();
databaseName = BaseSemanticAnalyzer.getUnescapedName((ASTNode) ast.getChild(0));
for (int num = 1; num < numCh; num++) {
ASTNode child = (ASTNode) ast.getChild(num);
switch (child.getToken().getType()) {
case HiveParser.TOK_IFNOTEXISTS:
try {
List<String> dbs = db.getDatabasesByPattern(databaseName);
if (dbs != null && dbs.size() > 0) { // db exists
return ast;
}
} catch (HiveException e) {
throw new SemanticException(e);
}
break;
}
}
return ast;
}
代码示例来源:origin: org.spark-project.hive.hcatalog/hive-hcatalog-core
@Override
public ASTNode preAnalyze(HiveSemanticAnalyzerHookContext context, ASTNode ast)
throws SemanticException {
Hive db;
try {
db = context.getHive();
} catch (HiveException e) {
throw new SemanticException("Couldn't get Hive DB instance in semantic analysis phase.", e);
}
// Analyze and create tbl properties object
int numCh = ast.getChildCount();
databaseName = BaseSemanticAnalyzer.getUnescapedName((ASTNode) ast.getChild(0));
for (int num = 1; num < numCh; num++) {
ASTNode child = (ASTNode) ast.getChild(num);
switch (child.getToken().getType()) {
case HiveParser.TOK_IFNOTEXISTS:
try {
List<String> dbs = db.getDatabasesByPattern(databaseName);
if (dbs != null && dbs.size() > 0) { // db exists
return ast;
}
} catch (HiveException e) {
throw new SemanticException(e);
}
break;
}
}
return ast;
}
内容来源于网络,如有侵权,请联系作者删除!