/** * Is the table name passed a dimension? * * @param tableName table name * @return true if it is dimension, false otherwise * @throws LensException */ public boolean isDimension(String tableName) throws LensException { if (allDimensionsPopulated) { if (allDims.containsKey(tableName.trim().toLowerCase())) { return true; } } else { Table tbl = getTable(tableName); return isDimension(tbl); } return false; }
/** * Is the table name passed a dimension? * * @param tableName table name * @return true if it is dimension, false otherwise * @throws LensException */ public boolean isDimension(String tableName) throws LensException { if (allDimensionsPopulated) { if (allDims.containsKey(tableName.trim().toLowerCase())) { return true; } } else { Table tbl = getTable(tableName); return isDimension(tbl); } return false; }
} else if (metastoreClient.isDimension(tblName)) { Dimension dim = metastoreClient.getDimension(tblName); if (!isOptional) {
} else if (metastoreClient.isDimension(tblName)) { Dimension dim = metastoreClient.getDimension(tblName); if (!isOptional) {
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 XJoinChains getAllJoinChains(LensSessionHandle sessionHandle, String tableName) throws LensException { try (SessionContext ignored = new SessionContext(sessionHandle)){ CubeMetastoreClient client = getClient(sessionHandle); Set<JoinChain> chains; if (client.isCube(tableName)) { chains = client.getCube(tableName).getJoinChains(); } else if (client.isDimension(tableName)) { chains = client.getDimension(tableName).getJoinChains(); } else { throw new BadRequestException("Can't get join chains. '" + tableName + "' is neither a cube nor a dimension"); } XJoinChains xJoinChains = new XJoinChains(); List<XJoinChain> joinChains = xJoinChains.getJoinChain(); if (chains != null) { for (JoinChain chain : chains) { joinChains.add(JAXBUtils.getXJoinChainFromJoinChain(chain)); } } return xJoinChains; } }
/** * return Cube or Dimension relationship depending on the source table of the join chain. * * @param client * @return * @throws HiveException */ TableRelationship toCubeOrDimRelationship(CubeMetastoreClient client) throws HiveException, LensException { if (relationShip == null) { AbstractCubeTable fromTable = null; if (client.isCube(from.getDestTable())) { fromTable = (AbstractCubeTable) client.getCube(from.getDestTable()); } else if (client.isDimension(from.getDestTable())) { fromTable = client.getDimension(from.getDestTable()); } if (fromTable != null) { relationShip = new TableRelationship(from.getDestColumn(), fromTable, to.getDestColumn(), client.getDimension(to.getDestTable()), to.isMapsToMany()); } } return relationShip; }
/** * return Cube or Dimension relationship depending on the source table of the join chain. * * @param client * @return * @throws HiveException */ TableRelationship toCubeOrDimRelationship(CubeMetastoreClient client) throws HiveException, LensException { if (relationShip == null) { AbstractCubeTable fromTable = null; if (client.isCube(from.getDestTable())) { fromTable = (AbstractCubeTable) client.getCube(from.getDestTable()); } else if (client.isDimension(from.getDestTable())) { fromTable = client.getDimension(from.getDestTable()); } if (fromTable != null) { relationShip = new TableRelationship(from.getDestColumn(), fromTable, to.getDestColumn(), client.getDimension(to.getDestTable()), to.isMapsToMany()); } } return relationShip; }
addAllChainedColsToFlattenedListFromCube(client, objectFactory, cube, columnList); } else if (client.isDimension(tableName)) { Dimension dimension = client.getDimension(tableName); addAllDirectAttributesToFlattenedListFromDimension(objectFactory, dimension, columnList, null);