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); } }
@Override public Set<String> getAllFieldNames() { Set<String> fieldNames = super.getAllFieldNames(); fieldNames.addAll(getAttributeNames()); return fieldNames; }
/** * 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; }
@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 boolean equals(Object obj) { if (!super.equals(obj)) { return false; } AbstractBaseTable other = (AbstractBaseTable) obj; if (this.getExpressions() == null) { if (other.getExpressions() != null) { return false; } } else if (!this.getExpressions().equals(other.getExpressions())) { return false; } if (this.getJoinChains() == null) { if (other.getJoinChains() != null) { return false; } } else if (!this.getJoinChains().equals(other.getJoinChains())) { return false; } return true; }
/** * 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 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); } } }
/** * 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(), ','))); }
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))); } } } } } }
public Set<String> getJoinChainNames() { Set<String> chainNames = new HashSet<>(); for (JoinChain f : getJoinChains()) { chainNames.add(f.getName().toLowerCase()); } return chainNames; }
public CubeColumn getColumnByName(String column) { return getExpressionByName(column); }
public Set<String> getExpressionNames() { Set<String> exprNames = new HashSet<>(); for (ExprColumn f : getExpressions()) { exprNames.add(f.getName().toLowerCase()); } return exprNames; }
@Override public void addProperties() { super.addProperties(); MetastoreUtil.addNameStrings(getProperties(), MetastoreUtil.getDimAttributeListKey(getName()), attributes); setAttributedProperties(getProperties(), attributes); }
public Set<String> getAllFieldNames() { return getExpressionNames(); }
@Override public boolean equals(Object obj) { if (!super.equals(obj)) { return false; } Dimension other = (Dimension) obj; if (this.getAttributes() == null) { if (other.getAttributes() != null) { return false; } } else if (!this.getAttributes().equals(other.getAttributes())) { return false; } if (this.getJoinChains() == null) { if (other.getJoinChains() != null) { return false; } } else if (!this.getJoinChains().equals(other.getJoinChains())) { return false; } return true; }
xcc.setChainName(crCol.getChainName()); xcc.setRefCol(crCol.getRefColumn()); if (baseTable.getChainByName(crCol.getChainName()) == null) { log.error("Missing chain definition for " + crCol.getChainName()); } else { xcc.setDestTable(baseTable.getChainByName(crCol.getChainName()).getDestTable());
if (!baseTable.getColumnByName(col).isColumnAvailableInTimeRange(range)) { toRemove = true; break;
@Override public void addProperties() { super.addProperties(); MetastoreUtil.addNameStrings(getProperties(), MetastoreUtil.getExpressionListKey(getName()), expressions); setExpressionProperties(getProperties(), expressions); MetastoreUtil.addNameStrings(getProperties(), getJoinChainListPropKey(getName()), joinChains); setJoinChainProperties(joinChains); }
/** * 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); } }
@Override public boolean equals(Object obj) { if (!super.equals(obj)) { return false; } AbstractBaseTable other = (AbstractBaseTable) obj; if (this.getExpressions() == null) { if (other.getExpressions() != null) { return false; } } else if (!this.getExpressions().equals(other.getExpressions())) { return false; } if (this.getJoinChains() == null) { if (other.getJoinChains() != null) { return false; } } else if (!this.getJoinChains().equals(other.getJoinChains())) { return false; } return true; }