/** * @param expr * @param tables */ void getTablesForExpression(AbstractExpression expr, HashSet<Table> tables) { List<TupleValueExpression> tves = ExpressionUtil.getTupleValueExpressions(expr); for (TupleValueExpression tupleExpr : tves) { String tableName = tupleExpr.getTableName(); Table table = getTableFromDB(tableName); tables.add(table); } }
// Even though this function applies generally to expressions and tables and not just to TVEs as // such, // this function is somewhat TVE-related because TVEs DO represent the points where expression // trees // depend on tables. public static boolean isOperandDependentOnTable(AbstractExpression expr, Table table) { for (TupleValueExpression tve : ExpressionUtil.getTupleValueExpressions(expr)) { // TODO: This clumsy testing of table names regardless of table aliases is // EXACTLY why we can't have nice things like self-joins. if (table.getTypeName().equals(tve.getTableName())) { return true; } } return false; }
/** * Parse the scan_columns element out of the HSQL-generated XML. Fills scanColumns with a list of * the columns used in the plan, hashed by table name. * * @param columnsNode */ void parseScanColumns(VoltXMLElement columnsNode) { scanColumns = new HashMap<String, ArrayList<SchemaColumn>>(); for (VoltXMLElement child : columnsNode.children) { assert (child.name.equals("columnref")); AbstractExpression col_exp = parseExpressionTree(child); // TupleValueExpressions are always specifically typed, // so there is no need for expression type specialization, here. assert (col_exp != null); assert (col_exp instanceof TupleValueExpression); TupleValueExpression tve = (TupleValueExpression) col_exp; SchemaColumn col = new SchemaColumn(tve.getTableName(), tve.getColumnName(), tve.getColumnAlias(), col_exp); ArrayList<SchemaColumn> table_cols = null; if (!scanColumns.containsKey(col.getTableName())) { table_cols = new ArrayList<SchemaColumn>(); scanColumns.put(col.getTableName(), table_cols); } table_cols = scanColumns.get(col.getTableName()); table_cols.add(col); } }