private Dimension getDimension(Table tbl) { return new Dimension(tbl); }
private Dimension getDimension(Table tbl) { return new Dimension(tbl); }
/** * Create dimension defined by attributes and properties * * @param name Name of the dimension * @param attributes Attributes of the dimension * @param properties Properties of the dimension * @param weight Weight of the dimension * @throws LensException */ public void createDimension(String name, Set<CubeDimAttribute> attributes, Map<String, String> properties, double weight) throws LensException { Dimension dim = new Dimension(name, attributes, properties, weight); createDimension(dim); }
/** * Create dimension defined by attributes and properties * * @param name Name of the dimension * @param attributes Attributes of the dimension * @param properties Properties of the dimension * @param weight Weight of the dimension * @throws LensException */ public void createDimension(String name, Set<CubeDimAttribute> attributes, Map<String, String> properties, double weight) throws LensException { Dimension dim = new Dimension(name, attributes, properties, weight); createDimension(dim); }
public static Dimension dimensionFromXDimension(XDimension dimension) throws LensException { Set<CubeDimAttribute> dims = new LinkedHashSet<CubeDimAttribute>(); for (XDimAttribute xd : dimension.getAttributes().getDimAttribute()) { dims.add(hiveDimAttrFromXDimAttr(xd)); } Set<ExprColumn> expressions = new LinkedHashSet<ExprColumn>(); if (dimension.getExpressions() != null && !dimension.getExpressions().getExpression().isEmpty()) { for (XExprColumn xe : dimension.getExpressions().getExpression()) { expressions.add(hiveExprColumnFromXExprColumn(xe)); } } Set<JoinChain> joinchains = new LinkedHashSet<JoinChain>(); if (dimension.getJoinChains() != null && !dimension.getJoinChains().getJoinChain().isEmpty()) { for (XJoinChain xj : dimension.getJoinChains().getJoinChain()) { joinchains.add(joinChainFromXJoinChain(xj)); } } Map<String, String> properties = mapFromXProperties(dimension.getProperties()); return new Dimension(dimension.getName(), dims, expressions, joinchains, properties, 0L); }
public static Dimension dimensionFromXDimension(XDimension dimension) throws LensException { Set<CubeDimAttribute> dims = new LinkedHashSet<CubeDimAttribute>(); for (XDimAttribute xd : dimension.getAttributes().getDimAttribute()) { dims.add(hiveDimAttrFromXDimAttr(xd)); } Set<ExprColumn> expressions = new LinkedHashSet<ExprColumn>(); if (dimension.getExpressions() != null && !dimension.getExpressions().getExpression().isEmpty()) { for (XExprColumn xe : dimension.getExpressions().getExpression()) { expressions.add(hiveExprColumnFromXExprColumn(xe)); } } Set<JoinChain> joinchains = new LinkedHashSet<JoinChain>(); if (dimension.getJoinChains() != null && !dimension.getJoinChains().getJoinChain().isEmpty()) { for (XJoinChain xj : dimension.getJoinChains().getJoinChain()) { joinchains.add(joinChainFromXJoinChain(xj)); } } Map<String, String> properties = mapFromXProperties(dimension.getProperties()); return new Dimension(dimension.getName(), dims, expressions, joinchains, properties, 0L); }
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()); }
Dimension toAlter = new Dimension(tbl); toAlter.alterAttribute(new BaseDimAttribute(new FieldSchema("newZipDim", "int", "new dim added"), null, null, null, null, 1000L));
zipDim = new Dimension("zipdim", zipAttrs, null, joinChains, dimProps, 0L); cityDim = new Dimension("citydim", cityAttrs, dimExpressions, joinChains, dimProps, 0L); stateDim = new Dimension("statedim", stateAttrs); countryAttrs.add(new BaseDimAttribute(new FieldSchema("capital", "string", "country capital"))); countryAttrs.add(new BaseDimAttribute(new FieldSchema("region", "string", "region name"))); countryDim = new Dimension("countrydim", countryAttrs);