/** * Return restricted columns of the table, which can be specified by property * MetastoreUtil.getRestrictedColumnsKey(getName()) * * @return set of restricted columns */ public Set<String> getRestrictedColumns() { String restrictedColsStr = MetastoreUtil.getNamedStringValue(getProperties(), MetastoreUtil.getRestrictedColumnsKey(getName())); log.info("Restricted cols : "+ restrictedColsStr + " for table : "+ this.getName()); return restrictedColsStr == null ? new HashSet<>() : new HashSet<>(Arrays.asList(StringUtils.split(restrictedColsStr .toLowerCase(), ','))); }
/** * Remove the join chain with name specified * * @param chainName chain name */ public boolean removeJoinChain(String chainName) { if (chainMap.containsKey(chainName.toLowerCase())) { joinChains.remove(getChainByName(chainName)); chainMap.remove(chainName.toLowerCase()); MetastoreUtil.addNameStrings(getProperties(), getJoinChainListPropKey(getName()), joinChains); return true; } return false; }
private void pickExpressionsForTable(CandidateTable cTable) throws LensException { for (Map.Entry<String, Set<ExpressionContext>> ecEntry : allExprsQueried.entrySet()) { Set<ExpressionContext> ecSet = ecEntry.getValue(); for (ExpressionContext ec : ecSet) { if (ec.getSrcTable().getName().equals(cTable.getBaseTable().getName())) { if (!ec.directlyAvailableIn.contains(cTable)) { log.debug("{} is not directly evaluable in {}", ec, cTable); if (ec.evaluableExpressions.get(cTable) != null && !ec.evaluableExpressions.get(cTable).isEmpty()) { // pick first evaluable expression pickedExpressions.computeIfAbsent(ecEntry.getKey(), k -> new HashSet<>()) .add(new PickedExpression(ec.srcAlias, ec.evaluableExpressions.get(cTable).iterator().next())); } else { nonPickedExpressionsForCandidate.put(ecEntry.getKey(), getDefaultExpr(getExprAst(ec))); } } } } } }
/** * Remove the join chain with name specified * * @param chainName chain name */ public boolean removeJoinChain(String chainName) { if (chainMap.containsKey(chainName.toLowerCase())) { joinChains.remove(getChainByName(chainName)); chainMap.remove(chainName.toLowerCase()); MetastoreUtil.addNameStrings(getProperties(), getJoinChainListPropKey(getName()), joinChains); return true; } return false; }
public AbstractBaseTable(Table tbl) { super(tbl); this.expressions = getExpressions(getName(), getProperties()); exprMap = new HashMap<>(); for (ExprColumn expr : expressions) { exprMap.put(expr.getName().toLowerCase(), expr); } this.joinChains = getJoinChains(this, getJoinChainListPropKey(getName()), getProperties()); chainMap = new HashMap<>(); for (JoinChain chain : joinChains) { chainMap.put(chain.getName().toLowerCase(), chain); } }
/** * Remove the expression with name specified * * @param exprName expression name */ public void removeExpression(String exprName) { if (exprMap.containsKey(exprName.toLowerCase())) { log.info("Removing expression {}", getExpressionByName(exprName)); expressions.remove(getExpressionByName(exprName)); exprMap.remove(exprName.toLowerCase()); MetastoreUtil.addNameStrings(getProperties(), MetastoreUtil.getExpressionListKey(getName()), expressions); } }
private void pickExpressionsForTable(CandidateTable cTable) throws LensException { for (Map.Entry<String, Set<ExpressionContext>> ecEntry : allExprsQueried.entrySet()) { Set<ExpressionContext> ecSet = ecEntry.getValue(); for (ExpressionContext ec : ecSet) { if (ec.getSrcTable().getName().equals(cTable.getBaseTable().getName())) { if (!ec.directlyAvailableIn.contains(cTable)) { log.debug("{} is not directly evaluable in {}", ec, cTable); if (ec.evaluableExpressions.get(cTable) != null && !ec.evaluableExpressions.get(cTable).isEmpty()) { // pick first evaluable expression pickedExpressions.computeIfAbsent(ecEntry.getKey(), k -> new HashSet<>()) .add(new PickedExpression(ec.srcAlias, ec.evaluableExpressions.get(cTable).iterator().next())); } else { nonPickedExpressionsForCandidate.put(ecEntry.getKey(), getDefaultExpr(getExprAst(ec))); } } } } } }
/** * Remove the expression with name specified * * @param exprName expression name */ public void removeExpression(String exprName) { if (exprMap.containsKey(exprName.toLowerCase())) { log.info("Removing expression {}", getExpressionByName(exprName)); expressions.remove(getExpressionByName(exprName)); exprMap.remove(exprName.toLowerCase()); MetastoreUtil.addNameStrings(getProperties(), MetastoreUtil.getExpressionListKey(getName()), expressions); } }
public AbstractBaseTable(Table tbl) { super(tbl); this.expressions = getExpressions(getName(), getProperties()); exprMap = new HashMap<>(); for (ExprColumn expr : expressions) { exprMap.put(expr.getName().toLowerCase(), expr); } this.joinChains = getJoinChains(this, getJoinChainListPropKey(getName()), getProperties()); chainMap = new HashMap<>(); for (JoinChain chain : joinChains) { chainMap.put(chain.getName().toLowerCase(), chain); } }
/** * Alters the joinchain if already existing or just adds if it is new chain * * @param joinchain join chain */ public void alterJoinChain(JoinChain joinchain) { if (joinchain == null) { throw new NullPointerException("Cannot add null joinchain"); } // Replace dimension if already existing if (chainMap.containsKey(joinchain.getName().toLowerCase())) { joinChains.remove(getChainByName(joinchain.getName())); log.info("Replacing joinchain {} with {}", getChainByName(joinchain.getName()), joinchain); } joinChains.add(joinchain); chainMap.put(joinchain.getName().toLowerCase(), joinchain); MetastoreUtil.addNameStrings(getProperties(), getJoinChainListPropKey(getName()), joinChains); joinchain.addProperties(this); }
/** * Alters the expression if already existing or just adds if it is new expression. * * @param expr ExprColumn */ public void alterExpression(ExprColumn expr) { if (expr == null) { throw new NullPointerException("Cannot add null expression"); } // Replace measure if already existing if (exprMap.containsKey(expr.getName().toLowerCase())) { expressions.remove(getExpressionByName(expr.getName())); log.info("Replacing expression {} with {}", getExpressionByName(expr.getName()), expr); } expressions.add(expr); exprMap.put(expr.getName().toLowerCase(), expr); MetastoreUtil.addNameStrings(getProperties(), MetastoreUtil.getExpressionListKey(getName()), expressions); expr.addProperties(getProperties()); }
/** * Alters the joinchain if already existing or just adds if it is new chain * * @param joinchain join chain */ public void alterJoinChain(JoinChain joinchain) { if (joinchain == null) { throw new NullPointerException("Cannot add null joinchain"); } // Replace dimension if already existing if (chainMap.containsKey(joinchain.getName().toLowerCase())) { joinChains.remove(getChainByName(joinchain.getName())); log.info("Replacing joinchain {} with {}", getChainByName(joinchain.getName()), joinchain); } joinChains.add(joinchain); chainMap.put(joinchain.getName().toLowerCase(), joinchain); MetastoreUtil.addNameStrings(getProperties(), getJoinChainListPropKey(getName()), joinChains); joinchain.addProperties(this); }
/** * Alters the expression if already existing or just adds if it is new expression. * * @param expr ExprColumn */ public void alterExpression(ExprColumn expr) { if (expr == null) { throw new NullPointerException("Cannot add null expression"); } // Replace measure if already existing if (exprMap.containsKey(expr.getName().toLowerCase())) { expressions.remove(getExpressionByName(expr.getName())); log.info("Replacing expression {} with {}", getExpressionByName(expr.getName()), expr); } expressions.add(expr); exprMap.put(expr.getName().toLowerCase(), expr); MetastoreUtil.addNameStrings(getProperties(), MetastoreUtil.getExpressionListKey(getName()), expressions); expr.addProperties(getProperties()); }
@Override public void addProperties() { super.addProperties(); MetastoreUtil.addNameStrings(getProperties(), MetastoreUtil.getExpressionListKey(getName()), expressions); setExpressionProperties(getProperties(), expressions); MetastoreUtil.addNameStrings(getProperties(), getJoinChainListPropKey(getName()), joinChains); setJoinChainProperties(joinChains); }
@Override public void addProperties() { super.addProperties(); MetastoreUtil.addNameStrings(getProperties(), MetastoreUtil.getExpressionListKey(getName()), expressions); setExpressionProperties(getProperties(), expressions); MetastoreUtil.addNameStrings(getProperties(), getJoinChainListPropKey(getName()), joinChains); setJoinChainProperties(joinChains); }
private void addAllDirectExpressionsToFlattenedList(ObjectFactory objectFactory, AbstractBaseTable baseTbl, List<XFlattenedColumn> columnList, String chainName) { if (baseTbl.getExpressions() != null) { for (ExprColumn expr : baseTbl.getExpressions()) { XFlattenedColumn fcol = objectFactory.createXFlattenedColumn(); fcol.setExpression(JAXBUtils.xExprColumnFromHiveExprColumn(expr)); fcol.setTableName(baseTbl.getName()); if (chainName != null) { fcol.setChainName(chainName); } columnList.add(fcol); } } }
Set<ExpressionContext> ecSet = ecEntry.getValue(); for (ExpressionContext ec : ecSet) { if (ec.getSrcTable().getName().equals(cdim.getBaseTable().getName())) { if (!ec.isEvaluable(cdim)) { log.info("Not considering dim table:{} as {} is not evaluable", cdim, ec.exprCol.getName());
Set<ExpressionContext> ecSet = ecEntry.getValue(); for (ExpressionContext ec : ecSet) { if (ec.getSrcTable().getName().equals(cdim.getBaseTable().getName())) { if (!ec.isEvaluable(cdim)) { log.info("Not considering dim table:{} as {} is not evaluable", cdim, ec.exprCol.getName());