public static Iterable<String> matchesDb(Hive db, String dbPattern) throws HiveException { if (dbPattern == null) { return db.getAllDatabases(); } else { return db.getDatabasesByPattern(dbPattern); } }
private Iterable<? extends String> matchesDb(String dbPattern) throws HiveException { if (dbPattern == null) { return db.getAllDatabases(); } else { return db.getDatabasesByPattern(dbPattern); } } }
/** * 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; }
/** * 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; }
@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; }
if (showDatabasesDesc.getPattern() != null) { LOG.info("pattern: " + showDatabasesDesc.getPattern()); databases = db.getDatabasesByPattern(showDatabasesDesc.getPattern()); } else { databases = db.getAllDatabases();
if (showDatabasesDesc.getPattern() != null) { LOG.info("pattern: " + showDatabasesDesc.getPattern()); databases = db.getDatabasesByPattern(showDatabasesDesc.getPattern()); } else { databases = db.getAllDatabases();
@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; }
@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; }
@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; }
@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; }