@Override public Object evaluate(DeferredObject[] arguments) throws HiveException { return SessionState.get().getCurrentDatabase(); }
@Override public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException { return PrimitiveObjectInspectorFactory.getPrimitiveWritableConstantObjectInspector( TypeInfoFactory.stringTypeInfo, new Text(SessionState.get().getCurrentDatabase())); }
/** * Get all table names for the current database. * @return List of table names * @throws HiveException */ public List<String> getAllTables() throws HiveException { return getTablesByType(SessionState.get().getCurrentDatabase(), null, null); }
public StatsWork(Table table, HiveConf hconf) { super(); this.table = table; this.currentDatabase = SessionState.get().getCurrentDatabase(); statsReliable = hconf.getBoolVar(ConfVars.HIVE_STATS_RELIABLE); }
/** * Extract db and table name from dbtable string, where db and table are separated by "." * If there is no db name part, set the current sessions default db * @param dbtable * @return String array with two elements, first is db name, second is table name * @throws HiveException */ public static String[] getDbTableName(String dbtable) throws SemanticException { return getDbTableName(SessionState.get().getCurrentDatabase(), dbtable); }
/** * Get the Database object for current database * @return a Database object if this database exists, null otherwise. * @throws HiveException */ public Database getDatabaseCurrent() throws HiveException { String currentDb = SessionState.get().getCurrentDatabase(); return getDatabase(currentDb); }
public static String getCurrentDB() { String currentDB = null; if (SessionState.get() != null) { currentDB = SessionState.get().getCurrentDatabase(); } return currentDB == null ? "default" : currentDB; }
/** * Returns all existing tables from default database which match the given * pattern. The matching occurs as per Java regular expressions * * @param tablePattern * java re pattern * @return list of table names * @throws HiveException */ public List<String> getTablesByPattern(String tablePattern) throws HiveException { return getTablesByType(SessionState.get().getCurrentDatabase(), tablePattern, null); }
public static String getNormalizedFunctionName(String fn) throws SemanticException { // Does the same thing as getFunctionInfo, except for getting the function info. fn = fn.toLowerCase(); return (FunctionUtils.isQualifiedFunctionName(fn) || getFunctionInfo(fn) != null) ? fn : FunctionUtils.qualifyFunctionName( fn, SessionState.get().getCurrentDatabase().toLowerCase()); }
public static String getNormalizedFunctionName(String fn) throws SemanticException { // Does the same thing as getFunctionInfo, except for getting the function info. fn = fn.toLowerCase(); return (FunctionUtils.isQualifiedFunctionName(fn) || getFunctionInfo(fn) != null) ? fn : FunctionUtils.qualifyFunctionName( fn, SessionState.get().getCurrentDatabase().toLowerCase()); }
public static String[] getQualifiedFunctionNameParts(String name) throws HiveException { if (isQualifiedFunctionName(name)) { return splitQualifiedFunctionName(name); } String dbName = SessionState.get().getCurrentDatabase(); return new String[] { dbName, name }; }
public StatsWork(Table table, BasicStatsWork basicStatsWork, HiveConf hconf) { super(); this.table = table; this.basicStatsWork = basicStatsWork; this.currentDatabase = SessionState.get().getCurrentDatabase(); statsReliable = hconf.getBoolVar(ConfVars.HIVE_STATS_RELIABLE); basicStatsWork.setStatsReliable(statsReliable); }
public WindowFunctionInfo getWindowFunctionInfo(String functionName) throws SemanticException { // First try without qualifiers - would resolve builtin/temp functions FunctionInfo info = getFunctionInfo(WINDOW_FUNC_PREFIX + functionName); // Try qualifying with current db name for permanent functions if (info == null) { String qualifiedName = FunctionUtils.qualifyFunctionName( functionName, SessionState.get().getCurrentDatabase().toLowerCase()); info = getFunctionInfo(WINDOW_FUNC_PREFIX + qualifiedName); } if (info instanceof WindowFunctionInfo) { return (WindowFunctionInfo) info; } return null; }
public static Table getTable(ASTNode tree, BaseSemanticAnalyzer sa) throws SemanticException { String tableName = ColumnStatsSemanticAnalyzer.getUnescapedName((ASTNode) tree.getChild(0).getChild(0)); String currentDb = SessionState.get().getCurrentDatabase(); String [] names = Utilities.getDbTableName(currentDb, tableName); return sa.getTable(names[0], names[1], true); }
private void verifyStatsUpToDate(String tbl, String part, ArrayList<String> cols, IMetaStoreClient msClient, boolean isUpToDate) throws Exception { Partition partition = msClient.getPartition(ss.getCurrentDatabase(), tbl, part); verifyStatsUpToDate(partition.getParameters(), cols, isUpToDate); }
private void verifyStatsUpToDate(String tbl, List<String> cols, IMetaStoreClient msClient, boolean isUpToDate) throws Exception { Table table = msClient.getTable(ss.getCurrentDatabase(), tbl); verifyStatsUpToDate(table.getParameters(), cols, isUpToDate); }
private void setTableSkipProperty( IMetaStoreClient msClient, String tbl, String val) throws Exception { Table table = msClient.getTable(ss.getCurrentDatabase(), tbl); table.getParameters().put(StatsUpdaterThread.SKIP_STATS_AUTOUPDATE_PROPERTY, val); msClient.alter_table(table.getDbName(), table.getTableName(), table); }
private void setPartitionSkipProperty( IMetaStoreClient msClient, String tblName, String partName, String val) throws Exception { Partition part = msClient.getPartition(ss.getCurrentDatabase(), tblName, partName); part.getParameters().put(StatsUpdaterThread.SKIP_STATS_AUTOUPDATE_PROPERTY, val); msClient.alter_partition(part.getCatName(), part.getDbName(), tblName, part); }
private void verifyStatsUpToDate(String tbl, List<String> cols, IMetaStoreClient msClient, String validWriteIds, boolean isUpToDate) throws Exception { Table table = msClient.getTable(ss.getCurrentCatalog(), ss.getCurrentDatabase(), tbl, validWriteIds); verifyStatsUpToDate(table.getParameters(), cols, isUpToDate); }
private void verifyAndUnsetColStats(String tblName, String partName, List<String> cols, IMetaStoreClient msClient) throws Exception { Partition part = msClient.getPartition(ss.getCurrentDatabase(), tblName, partName); verifyAndUnsetColStatsVal(part.getParameters(), cols); EnvironmentContext ec = new EnvironmentContext(); // Make sure metastore doesn't mess with our bogus stats updates. ec.putToProperties(StatsSetupConst.DO_NOT_UPDATE_STATS, StatsSetupConst.TRUE); msClient.alter_partition(part.getCatName(), part.getDbName(), tblName, part, ec); // Double-check. part = msClient.getPartition(ss.getCurrentDatabase(), tblName, partName); for (String col : cols) { assertFalse(StatsSetupConst.areColumnStatsUptoDate(part.getParameters(), col)); } }