@Test(dataProvider = "testCases") public void testGetAllFilters(String expr, List<String> expected) throws Exception { List<String> allFilters = newArrayList(); CubeQueryContext.getAllFilters(HQLParser.parseExpr(expr), "testcube", allFilters, jc, Maps.newHashMap()); assertEquals(allFilters, expected); }
protected static void getAllFilters(ASTNode node, String cubeAlias, List<String> allFilters, JoinClause joinClause, Map<Dimension, CandidateDim> dimToQuery) throws LensException { if (node.getToken().getType() == HiveParser.KW_AND || node.getToken().getType() == HiveParser.TOK_WHERE) { for (int i = 0; i < node.getChildCount(); i++) { ASTNode child = (ASTNode) node.getChild(i); getAllFilters(child, cubeAlias, allFilters, joinClause, dimToQuery); } } else { String table = getTableFromFilterAST(node); allFilters.add(getFilter(table, cubeAlias, node, joinClause, dimToQuery)); } }
CubeQueryContext extends TracksQueriedColumns implements QueryAST, TrackDenormContext { protected static void getAllFilters(ASTNode node, String cubeAlias, List<String> allFilters, JoinClause joinClause, Map<Dimension, CandidateDim> dimToQuery) throws LensException { if (node.getToken().getType() == HiveParser.KW_AND || node.getToken().getType() == HiveParser.TOK_WHERE) { for (int i = 0; i < node.getChildCount(); i++) { ASTNode child = (ASTNode) node.getChild(i); getAllFilters(child, cubeAlias, allFilters, joinClause, dimToQuery); } } else { String table = getTableFromFilterAST(node); allFilters.add(getFilter(table, cubeAlias, node, joinClause, dimToQuery)); } } }
CubeQueryContext extends TracksQueriedColumns implements QueryAST, TrackDenormContext { protected static void getAllFilters(ASTNode node, String cubeAlias, List<String> allFilters, JoinClause joinClause, Map<Dimension, CandidateDim> dimToQuery) throws LensException { if (node.getToken().getType() == HiveParser.KW_AND || node.getToken().getType() == HiveParser.TOK_WHERE) { for (int i = 0; i < node.getChildCount(); i++) { ASTNode child = (ASTNode) node.getChild(i); getAllFilters(child, cubeAlias, allFilters, joinClause, dimToQuery); } } else { String table = getTableFromFilterAST(node); allFilters.add(getFilter(table, cubeAlias, node, joinClause, dimToQuery)); } } CubeQueryContext(ASTNode ast, QB qb, Configuration queryConf, HiveConf metastoreConf); }
CubeQueryContext extends TracksQueriedColumns implements QueryAST, TrackDenormContext { protected static void getAllFilters(ASTNode node, String cubeAlias, List<String> allFilters, JoinClause joinClause, Map<Dimension, CandidateDim> dimToQuery) throws LensException { if (node.getToken().getType() == HiveParser.KW_AND || node.getToken().getType() == HiveParser.TOK_WHERE) { for (int i = 0; i < node.getChildCount(); i++) { ASTNode child = (ASTNode) node.getChild(i); getAllFilters(child, cubeAlias, allFilters, joinClause, dimToQuery); } } else { String table = getTableFromFilterAST(node); allFilters.add(getFilter(table, cubeAlias, node, joinClause, dimToQuery)); } } CubeQueryContext(ASTNode ast, QB qb, Configuration queryConf, HiveConf metastoreConf); AbstractCubeTable getCubeTableForAlias(String alias); Map<Dimension, Set<CandidateDim>> getCandidateDimTables(); void addDimPruningMsgs(Dimension dim, CubeDimensionTable dimtable, CandidateTablePruneCause msg); String getAliasForTableName(Named named); String getAliasForTableName(String tableName); void print(); String getSelectString(); void setWhereString(String whereString); String getWhereString(); String getGroupByString(); String getHavingString(); ASTNode getJoinAST(); @Override void setJoinAST(ASTNode node); String getOrderByString(); Integer getLimitValue(); void setLimitValue(Integer value); QueryWriterContext getQueryWriterContext(Candidate cand, Map<Dimension, CandidateDim> dimsToQuery); String toHQL(); ASTNode toAST(Context ctx); AbstractCubeTable getQueriedTable(String alias); boolean shouldReplaceTimeDimWithPart(); }
CubeQueryContext extends TracksQueriedColumns implements QueryAST, TrackDenormContext { protected static void getAllFilters(ASTNode node, String cubeAlias, List<String> allFilters, JoinClause joinClause, Map<Dimension, CandidateDim> dimToQuery) throws LensException { if (node.getToken().getType() == HiveParser.KW_AND || node.getToken().getType() == HiveParser.TOK_WHERE) { for (int i = 0; i < node.getChildCount(); i++) { ASTNode child = (ASTNode) node.getChild(i); getAllFilters(child, cubeAlias, allFilters, joinClause, dimToQuery); } } else { String table = getTableFromFilterAST(node); allFilters.add(getFilter(table, cubeAlias, node, joinClause, dimToQuery)); } } CubeQueryContext(ASTNode ast, QB qb, Configuration queryConf, HiveConf metastoreConf); AbstractCubeTable getCubeTableForAlias(String alias); Map<Dimension, Set<CandidateDim>> getCandidateDimTables(); void addDimPruningMsgs(Dimension dim, CubeDimensionTable dimtable, CandidateTablePruneCause msg); String getAliasForTableName(Named named); String getAliasForTableName(String tableName); void print(); String getSelectString(); void setWhereString(String whereString); String getWhereString(); String getGroupByString(); String getHavingString(); ASTNode getJoinAST(); @Override void setJoinAST(ASTNode node); String getOrderByString(); Integer getLimitValue(); void setLimitValue(Integer value); QueryWriterContext getQueryWriterContext(Candidate cand, Map<Dimension, CandidateDim> dimsToQuery); String toHQL(); ASTNode toAST(Context ctx); AbstractCubeTable getQueriedTable(String alias); boolean shouldReplaceTimeDimWithPart(); static final String NOW; }