Returns the Table for the given TableName from the 'stmtTableCache' in the global analysis state. Throws an AnalysisException if the database or table does not exist. Throws a TableLoadingException if the registered table failed to load. Does not register authorization requests or access events.
(TableName tblName, boolean mustExist)
| 3799 | * Does not register authorization requests or access events. |
| 3800 | */ |
| 3801 | public FeTable getTable(TableName tblName, boolean mustExist) |
| 3802 | throws AnalysisException, TableLoadingException { |
| 3803 | if (IcebergMetadataTable.isIcebergMetadataTable(tblName.toPath(), this)) { |
| 3804 | return getMetadataVirtualTable(tblName.toPath()); |
| 3805 | } |
| 3806 | FeTable table = globalState_.stmtTableCache.tables.get(tblName); |
| 3807 | if (table == null) { |
| 3808 | if (!mustExist) { |
| 3809 | return null; |
| 3810 | } |
| 3811 | if (!globalState_.stmtTableCache.dbs.contains(tblName.getDb())) { |
| 3812 | throw new AnalysisException(DB_DOES_NOT_EXIST_ERROR_MSG + tblName.getDb()); |
| 3813 | } else { |
| 3814 | throw new AnalysisException(TBL_DOES_NOT_EXIST_ERROR_MSG + tblName.toString()); |
| 3815 | } |
| 3816 | } |
| 3817 | Preconditions.checkState(table.isLoaded(), "table: %s should be loaded", tblName); |
| 3818 | if (table instanceof FeIncompleteTable) { |
| 3819 | // If there were problems loading this table's metadata, throw an exception |
| 3820 | // when it is accessed. |
| 3821 | ImpalaException cause = ((FeIncompleteTable) table).getCause(); |
| 3822 | if (cause instanceof TableLoadingException) throw (TableLoadingException) cause; |
| 3823 | throw new TableLoadingException("Missing metadata for table: " + tblName, cause); |
| 3824 | } |
| 3825 | return table; |
| 3826 | } |
| 3827 | |
| 3828 | /** |
| 3829 | * Wrapper around {@link #getTable(TableName tblName, boolean mustExist)}. |
no test coverage detected