private TableDescriptor getTableDescriptor(String tableName) throws UndefinedTableException { TableDescriptor tableDescriptor = null; if (tableName == null || tableName.isEmpty()) { throw new UndefinedTableException(tableName); } tableName = tableName.toUpperCase(); for (TableDescriptor testDescriptor : schemaInfoTableDescriptors) { if (testDescriptor.getTableNameString().equalsIgnoreCase(tableName)) { tableDescriptor = testDescriptor; break; } } if (tableDescriptor == null) { throw new UndefinedTableException(tableName); } return tableDescriptor; }
private TableDescriptor getTableDescriptor(String tableName) throws UndefinedTableException { TableDescriptor tableDescriptor = null; if (tableName == null || tableName.isEmpty()) { throw new UndefinedTableException(tableName); } tableName = tableName.toUpperCase(); for (int idx = 0; idx < schemaInfoTableDescriptors.size(); idx++) { TableDescriptor testDescriptor = schemaInfoTableDescriptors.get(idx); if (testDescriptor.getTableNameString().equalsIgnoreCase(tableName)) { tableDescriptor = testDescriptor; break; } } if (tableDescriptor == null) { throw new UndefinedTableException(tableName); } return tableDescriptor; }
private int getTableId(int databaseId, String databaseName, String tableName) throws UndefinedTableException { ResultSet res = null; String tidSql = "SELECT TID from TABLES WHERE db_id = ? AND " + COL_TABLES_NAME + "=?"; try (PreparedStatement pstmt = getConnection().prepareStatement(tidSql)) { pstmt.setInt(1, databaseId); pstmt.setString(2, tableName); res = pstmt.executeQuery(); if (!res.next()) { throw new UndefinedTableException(databaseName, tableName); } return res.getInt(1); } catch (SQLException se) { throw new TajoInternalError(se); } finally { CatalogUtil.closeQuietly(res); } }
public CatalogProtos.TableDescProto getTableDesc(String tableName) throws UndefinedTableException { TableDescriptor tableDescriptor; tableDescriptor = getTableDescriptor(tableName); if (tableDescriptor == null) { throw new UndefinedTableException(DATABASE_NAME, tableName); } return tableDescriptor.getTableDescription(); }
@Override public long getTableVolume(TableDesc table, Optional<EvalNode> filter) { String sql = "SELECT pg_table_size('" + IdentifierUtil.extractSimpleName(table.getName()) + "')"; try (Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sql)) { if (rs.next()) { return rs.getLong(1); } else { throw new TajoRuntimeException(new UndefinedTableException(table.getName())); } } catch (SQLException e) { throw new TajoInternalError(e); } } }
public CatalogProtos.TableDescProto getTableDesc(String tableName) throws UndefinedTableException { TableDescriptor tableDescriptor; tableDescriptor = getTableDescriptor(tableName); if (tableDescriptor == null) { throw new UndefinedTableException(DATABASE_NAME, tableName); } return tableDescriptor.getTableDescription(); }
private int getTableId(int databaseId, String databaseName, String tableName) throws UndefinedTableException { Connection conn = null; PreparedStatement pstmt = null; ResultSet res = null; try { String tidSql = "SELECT TID from TABLES WHERE db_id = ? AND " + COL_TABLES_NAME + "=?"; conn = getConnection(); pstmt = conn.prepareStatement(tidSql); pstmt.setInt(1, databaseId); pstmt.setString(2, tableName); res = pstmt.executeQuery(); if (!res.next()) { throw new UndefinedTableException(databaseName, tableName); } return res.getInt(1); } catch (SQLException se) { throw new TajoInternalError(se); } finally { CatalogUtil.closeQuietly(pstmt, res); } }
throw new UndefinedTableException(statsProto.getTableName());
private boolean assertRelationExistence(Context context, String tableName) { String qualifiedName; if (CatalogUtil.isFQTableName(tableName)) { qualifiedName = tableName; } else { qualifiedName = CatalogUtil.buildFQName(context.queryContext.get(SessionVars.CURRENT_DATABASE), tableName); } if (!catalog.existsTable(qualifiedName)) { context.state.addVerification(new UndefinedTableException(qualifiedName)); return false; } return true; }
private boolean assertRelationExistence(Context context, String tableName) { String qualifiedName; if (IdentifierUtil.isFQTableName(tableName)) { qualifiedName = tableName; } else { qualifiedName = IdentifierUtil.buildFQName(context.queryContext.get(SessionVars.CURRENT_DATABASE), tableName); } if (!catalog.existsTable(qualifiedName)) { context.state.addVerification(new UndefinedTableException(qualifiedName)); return false; } return true; }
protected org.apache.hadoop.hive.ql.metadata.Table getHiveTable(String databaseName, final String tableName) throws UndefinedTableException { HiveCatalogStoreClientPool.HiveCatalogStoreClient client = null; try { client = clientPool.getClient(); return HiveCatalogUtil.getTable(client.getHiveClient(), databaseName, tableName); } catch (NoSuchObjectException nsoe) { throw new UndefinedTableException(tableName); } catch (Exception e) { throw new TajoInternalError(e); } finally { if (client != null) client.release(); } }
@Override public boolean existPartitionMethod(String databaseName, String tableName) throws UndefinedTableException { boolean exist = false; org.apache.hadoop.hive.ql.metadata.Table table; HiveCatalogStoreClientPool.HiveCatalogStoreClient client = null; try { try { client = clientPool.getClient(); table = HiveCatalogUtil.getTable(client.getHiveClient(), databaseName, tableName); } catch (NoSuchObjectException nsoe) { throw new UndefinedTableException(tableName); } catch (Exception e) { throw new TajoInternalError(e); } // set partition keys List<FieldSchema> partitionKeys = table.getPartitionKeys(); if (partitionKeys != null && partitionKeys.size() > 0) { exist = true; } } finally { if(client != null) client.release(); } return exist; }
return; } else { // Otherwise, it causes an exception. throw new UndefinedTableException(qualifiedName);
return; } else { // Otherwise, it causes an exception. throw new UndefinedTableException(qualifiedName);
@Override public TableDesc getTableDesc(final String tableName) throws UndefinedTableException { final BlockingInterface stub = conn.getTMStub(); TableResponse res; try { res = stub.getTableDesc(null, conn.getSessionedString(tableName)); } catch (ServiceException e) { throw new RuntimeException(e); } if (isThisError(res.getState(), ResultCode.UNDEFINED_TABLE)) { throw new UndefinedTableException(res.getState()); } ensureOk(res.getState()); return new TableDesc(res.getTable()); }
@Override public TableDesc getTableDesc(final String tableName) throws UndefinedTableException { final BlockingInterface stub = conn.getTMStub(); TableResponse res; try { res = stub.getTableDesc(null, conn.getSessionedString(tableName)); } catch (ServiceException e) { throw new RuntimeException(e); } if (isThisError(res.getState(), ResultCode.UNDEFINED_TABLE)) { throw new UndefinedTableException(res.getState()); } ensureOk(res.getState()); return new TableDesc(res.getTable()); }
@Override public List<CatalogProtos.PartitionDescProto> getPartitionsOfTable(String databaseName, String tableName) throws UndefinedDatabaseException, UndefinedTableException, UndefinedPartitionMethodException { List<PartitionDescProto> list = null; try { if (!existDatabase(databaseName)) { throw new UndefinedDatabaseException(tableName); } if (!existTable(databaseName, tableName)) { throw new UndefinedTableException(tableName); } if (!existPartitionMethod(databaseName, tableName)) { throw new UndefinedPartitionMethodException(tableName); } list = getPartitionsFromHiveMetaStore(databaseName, tableName, ""); } catch (Exception se) { throw new TajoInternalError(se); } return list; }
@Override public List<PartitionDescProto> getPartitionsByAlgebra(PartitionsByAlgebraProto request) throws UndefinedDatabaseException, UndefinedTableException, UndefinedPartitionMethodException, UnsupportedException { List<PartitionDescProto> list = null; try { String databaseName = request.getDatabaseName(); String tableName = request.getTableName(); if (!existDatabase(databaseName)) { throw new UndefinedDatabaseException(tableName); } if (!existTable(databaseName, tableName)) { throw new UndefinedTableException(tableName); } if (!existPartitionMethod(databaseName, tableName)) { throw new UndefinedPartitionMethodException(tableName); } TableDescProto tableDesc = getTable(databaseName, tableName); String filter = getFilter(databaseName, tableName, tableDesc.getPartition().getExpressionSchema().getFieldsList() , request.getAlgebra()); list = getPartitionsFromHiveMetaStore(databaseName, tableName, filter); } catch (UnsupportedException ue) { throw ue; } catch (Exception se) { throw new TajoInternalError(se); } return list; }
public LogicalNode handleCreateTableLike(PlanContext context, CreateTable expr, CreateTableNode createTableNode) throws TajoException { String parentTableName = expr.getLikeParentTableName(); if (CatalogUtil.isFQTableName(parentTableName) == false) { parentTableName = CatalogUtil.buildFQName(context.queryContext.get(SessionVars.CURRENT_DATABASE), parentTableName); } TableDesc baseTable = catalog.getTableDesc(parentTableName); if(baseTable == null) { throw new UndefinedTableException(parentTableName); } PartitionMethodDesc partitionDesc = baseTable.getPartitionMethod(); createTableNode.setTableSchema(baseTable.getSchema()); createTableNode.setPartitionMethod(partitionDesc); createTableNode.setDataFormat(CatalogUtil.getBackwardCompitableDataFormat(baseTable.getMeta().getDataFormat())); createTableNode.setOptions(baseTable.getMeta().getOptions()); createTableNode.setExternal(baseTable.isExternal()); if(baseTable.isExternal()) { createTableNode.setUri(baseTable.getUri()); } return createTableNode; }
public LogicalNode handleCreateTableLike(PlanContext context, CreateTable expr, CreateTableNode createTableNode) throws TajoException { String parentTableName = expr.getLikeParentTableName(); if (IdentifierUtil.isFQTableName(parentTableName) == false) { parentTableName = IdentifierUtil.buildFQName(context.queryContext.get(SessionVars.CURRENT_DATABASE), parentTableName); } TableDesc baseTable = catalog.getTableDesc(parentTableName); if(baseTable == null) { throw new UndefinedTableException(parentTableName); } PartitionMethodDesc partitionDesc = baseTable.getPartitionMethod(); createTableNode.setTableSchema(baseTable.getSchema()); createTableNode.setPartitionMethod(partitionDesc); createTableNode.setDataFormat(CatalogUtil.getBackwardCompitableDataFormat(baseTable.getMeta().getDataFormat())); createTableNode.setOptions(baseTable.getMeta().getPropertySet()); createTableNode.setExternal(baseTable.isExternal()); if(baseTable.isExternal()) { createTableNode.setUri(baseTable.getUri()); } return createTableNode; }