/** * Get all dimension tables of the dimension. * * @param dim Dimension object * @return List of fact tables * @throws LensException */ public List<CubeDimensionTable> getAllDimensionTables(Dimension dim) throws LensException { List<CubeDimensionTable> dimTables = new ArrayList<>(); for (CubeDimensionTable dimTbl : getAllDimensionTables()) { if (dim == null || dimTbl.getDimName().equalsIgnoreCase(dim.getName().toLowerCase())) { dimTables.add(dimTbl); } } return dimTables; }
/** * @return the timedDimension */ public String getTimedDimension() { return getProperties().get(MetastoreUtil.getDimTimedDimensionKey(getName())); }
/** * @return the timedDimension */ public String getTimedDimension() { return getProperties().get(MetastoreUtil.getDimTimedDimensionKey(getName())); }
public AbstractCubeTable getQueriedTable(String alias) { if (cube != null && cube.getName().equalsIgnoreCase(qb.getTabNameForAlias((alias)))) { return (AbstractCubeTable) cube; } for (Dimension dim : dimensions) { if (dim.getName().equalsIgnoreCase(qb.getTabNameForAlias(alias))) { return dim; } } return null; }
/** * Remove the dimension with name specified * * @param attrName */ public void removeAttribute(String attrName) { if (attributeMap.containsKey(attrName.toLowerCase())) { log.info("Removing attribute {}", getAttributeByName(attrName)); attributes.remove(getAttributeByName(attrName)); attributeMap.remove(attrName.toLowerCase()); MetastoreUtil.addNameStrings(getProperties(), MetastoreUtil.getDimAttributeListKey(getName()), attributes); } }
public AbstractCubeTable getQueriedTable(String alias) { if (cube != null && cube.getName().equalsIgnoreCase(qb.getTabNameForAlias((alias)))) { return (AbstractCubeTable) cube; } for (Dimension dim : dimensions) { if (dim.getName().equalsIgnoreCase(qb.getTabNameForAlias(alias))) { return dim; } } return null; }
/** * Create dimension in metastore defined by {@link Dimension} object * * @param dim the {@link Dimension} object. * @throws LensException */ public void createDimension(Dimension dim) throws LensException { createCubeHiveTable(dim); // do a get to update cache getDimension(dim.getName()); }
@Override public List<String> getAllDimensionNames(LensSessionHandle sessionid) throws LensException { try (SessionContext ignored = new SessionContext(sessionid)){ Collection<Dimension> dimensions = getClient(sessionid).getAllDimensions(); if (dimensions != null && !dimensions.isEmpty()) { List<String> names = new ArrayList<>(dimensions.size()); for (Dimension dim : dimensions) { names.add(dim.getName()); } return names; } } return null; }
/** * Remove the dimension with name specified * * @param attrName */ public void removeAttribute(String attrName) { if (attributeMap.containsKey(attrName.toLowerCase())) { log.info("Removing attribute {}", getAttributeByName(attrName)); attributes.remove(getAttributeByName(attrName)); attributeMap.remove(attrName.toLowerCase()); MetastoreUtil.addNameStrings(getProperties(), MetastoreUtil.getDimAttributeListKey(getName()), attributes); } }
public Dimension(Table tbl) { super(tbl); this.attributes = getAttributes(getName(), getProperties()); attributeMap = new HashMap<>(); for (CubeDimAttribute attr : attributes) { addAllAttributesToMap(attr); } }
public Dimension(Table tbl) { super(tbl); this.attributes = getAttributes(getName(), getProperties()); attributeMap = new HashMap<>(); for (CubeDimAttribute attr : attributes) { addAllAttributesToMap(attr); } }
private void removeOptionalDimWithoutAlias(CubeQueryContext cubeql, Dimension dim) { for (Aliased<Dimension> aDim : cubeql.getOptionalDimensions()) { if (aDim.getName().equals(dim.getName())) { removeOptionalDim(cubeql, aDim); } } }
private void removeOptionalDimWithoutAlias(CubeQueryContext cubeql, Dimension dim) { for (Aliased<Dimension> aDim : cubeql.getOptionalDimensions()) { if (aDim.getName().equals(dim.getName())) { removeOptionalDim(cubeql, aDim); } } }
/** * Create dimension in metastore defined by {@link Dimension} object * * @param dim the {@link Dimension} object. * @throws LensException */ public void createDimension(Dimension dim) throws LensException { checkIfAuthorized(); createCubeHiveTable(dim); // do a get to update cache getDimension(dim.getName()); }
/** * Alters the attribute if already existing or just adds if it is new attribute * * @param attribute */ public void alterAttribute(@NonNull CubeDimAttribute attribute) { // Replace dimension if already existing if (attributeMap.containsKey(attribute.getName().toLowerCase())) { attributes.remove(getAttributeByName(attribute.getName())); log.info("Replacing attribute {} with {}", getAttributeByName(attribute.getName()), attribute); } attributes.add(attribute); attributeMap.put(attribute.getName().toLowerCase(), attribute); MetastoreUtil.addNameStrings(getProperties(), MetastoreUtil.getDimAttributeListKey(getName()), attributes); attribute.addProperties(getProperties()); }
/** * Alters the attribute if already existing or just adds if it is new attribute * * @param attribute */ public void alterAttribute(@NonNull CubeDimAttribute attribute) { // Replace dimension if already existing if (attributeMap.containsKey(attribute.getName().toLowerCase())) { attributes.remove(getAttributeByName(attribute.getName())); log.info("Replacing attribute {} with {}", getAttributeByName(attribute.getName()), attribute); } attributes.add(attribute); attributeMap.put(attribute.getName().toLowerCase(), attribute); MetastoreUtil.addNameStrings(getProperties(), MetastoreUtil.getDimAttributeListKey(getName()), attributes); attribute.addProperties(getProperties()); }
private void addAllDirectAttributesToFlattenedListFromDimension(ObjectFactory objectFactory, Dimension dimension, List<XFlattenedColumn> columnList, String chainName) { for (CubeDimAttribute cd : dimension.getAttributes()) { XFlattenedColumn fcol = objectFactory.createXFlattenedColumn(); fcol.setDimAttribute(JAXBUtils.xDimAttrFromHiveDimAttr(cd, dimension)); fcol.setTableName(dimension.getName()); if (chainName != null) { fcol.setChainName(chainName); } columnList.add(fcol); } }
private void validateDim(Dimension udim, Set<CubeDimAttribute> attrs, String basedim, String referdim) throws HiveException, LensException { assertTrue(client.tableExists(udim.getName())); Table dimTbl = client.getHiveTable(udim.getName()); assertTrue(client.isDimension(dimTbl)); Dimension dim = new Dimension(dimTbl); assertTrue(udim.equals(dim), "Equals failed for " + dim.getName()); assertTrue(udim.equals(client.getDimension(udim.getName()))); assertEquals(dim.getAttributes().size(), attrs.size()); assertNotNull(dim.getAttributeByName(basedim)); assertTrue(dim.getAttributeByName(basedim) instanceof BaseDimAttribute); if (referdim != null) { assertNotNull(dim.getAttributeByName(referdim)); assertTrue(dim.getAttributeByName(referdim) instanceof ReferencedDimAttribute); } assertEquals(udim.getAttributeNames().size() + udim.getExpressionNames().size(), dim.getAllFieldNames().size()); }
@Override public void addProperties() { super.addProperties(); MetastoreUtil.addNameStrings(getProperties(), MetastoreUtil.getDimAttributeListKey(getName()), attributes); setAttributedProperties(getProperties(), attributes); }
@Override public void addProperties() { super.addProperties(); MetastoreUtil.addNameStrings(getProperties(), MetastoreUtil.getDimAttributeListKey(getName()), attributes); setAttributedProperties(getProperties(), attributes); }