@Test public void testNamedStrings() { Set<CubeDimAttribute> attrs = new LinkedHashSet<CubeDimAttribute>(); attrs.add(new BaseDimAttribute(new FieldSchema("first", "string", ""))); attrs.add(new BaseDimAttribute(new FieldSchema("second", "string", ""))); attrs.add(new BaseDimAttribute(new FieldSchema("biggggger", "string", ""))); List<String> names = MetastoreUtil.getNamedStrs(attrs, 10); Assert.assertEquals(names.size(), 3); Assert.assertEquals(names.get(0), "first,"); Assert.assertEquals(names.get(1), "second,"); Assert.assertEquals(names.get(2), "biggggger"); Map<String, String> props = new HashMap<String, String>(); MetastoreUtil.addNameStrings(props, "test.key", attrs); String propValue = MetastoreUtil.getNamedStringValue(props, "test.key"); Assert.assertEquals(props.size(), 2); Assert.assertEquals(props.get("test.key.size"), "1"); Assert.assertEquals(propValue, "first,second,biggggger"); props = new HashMap<String, String>(); MetastoreUtil.addNameStrings(props, "test.key", attrs, 10); propValue = MetastoreUtil.getNamedStringValue(props, "test.key"); Assert.assertEquals(props.size(), 4); Assert.assertEquals(props.get("test.key.size"), "3"); Assert.assertEquals(propValue, "first,second,biggggger"); } }
cubeDimensions.add(new BaseDimAttribute(new FieldSchema("dim1", "id", "ref dim"), "dim with tag", null, null, null, null, null, tag1));
zipAttrs.add(new BaseDimAttribute(new FieldSchema("zipcode", "int", "code"))); zipAttrs.add(new BaseDimAttribute(new FieldSchema("f1", "string", "field1"))); zipAttrs.add(new BaseDimAttribute(new FieldSchema("f2", "string", "field1"))); zipAttrs.add(new BaseDimAttribute(new FieldSchema("stateid", "int", "state id"), "State refer", null, null, null)); zipAttrs.add(new BaseDimAttribute(new FieldSchema("cityid", "int", "city id"), "City refer", null, null, null)); zipAttrs.add(new BaseDimAttribute(new FieldSchema("countryid", "int", "country id"), "Country refer", null, null, null)); zipAttrs.add(new ReferencedDimAttribute(new FieldSchema("statename", "name", "state name"), "State Name", cityAttrs.add(new BaseDimAttribute(new FieldSchema("id", "int", "code"))); cityAttrs.add(new BaseDimAttribute(new FieldSchema("name", "string", "city name"))); cityAttrs.add(new BaseDimAttribute(new FieldSchema("stateid", "int", "state id"), "State refer", null, null, null)); cityAttrs.add(new ReferencedDimAttribute(new FieldSchema("statename", "name", "state name"), "State Name", "citystate", "name", null, null, null)); stateAttrs.add(new BaseDimAttribute(new FieldSchema("id", "int", "state id"), "State ID", null, null, null)); stateAttrs.add(new BaseDimAttribute(new FieldSchema("name", "string", "state name"))); stateAttrs.add(new BaseDimAttribute(new FieldSchema("capital", "string", "state capital"))); stateAttrs.add(new BaseDimAttribute(new FieldSchema("countryid", "int", "country id"), "Country refer", null, null, null)); stateAttrs.add(new ReferencedDimAttribute(new FieldSchema("countryname", "name", "country name"), "country Name", countryAttrs.add(new BaseDimAttribute(new FieldSchema("id", "int", "country id"))); countryAttrs.add(new BaseDimAttribute(new FieldSchema("name", "string", "country name"))); 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);
locationHierarchy.add(new BaseDimAttribute(new FieldSchema("zipcode", "int", "zip"))); locationHierarchy.add(new BaseDimAttribute(new FieldSchema("cityid", "int", "city"))); locationHierarchy.add(new BaseDimAttribute(new FieldSchema("stateid", "int", "state"))); locationHierarchy.add(new BaseDimAttribute(new FieldSchema("countryid", "int", "country"))); List<String> regions = Arrays.asList("APAC", "EMEA", "USA"); locationHierarchy.add(new BaseDimAttribute(new FieldSchema("regionname", "string", "region"), "regionname", null, null, null, null, regions)); cubeDimensions.add(new HierarchicalDimAttribute("location", "location hierarchy", locationHierarchy)); cubeDimensions.add(new BaseDimAttribute(new FieldSchema("dim1", "string", "basedim"))); cubeDimensions.add(new BaseDimAttribute(new FieldSchema("dim2", "id", "ref dim"), "Dim2 refer", null, null, null)); Set<CubeDimAttribute> dummyDimAttributes = Sets.newHashSet(); for (int i = 0; i < 5000; i++) { dummyDimAttributes.add(new BaseDimAttribute(new FieldSchema("dummy_dim" + i, "string", "dummy dim " + i), "dummy_dim" + i, null, null, null, null, regions)); locationHierarchyWithStartTime.add(new BaseDimAttribute(new FieldSchema("zipcode2", "int", "zip"), "Zip refer2", NOW, NOW, 100.0, 1000L)); locationHierarchyWithStartTime.add(new BaseDimAttribute(new FieldSchema("cityid2", "int", "city"), "City refer2", NOW, null, null)); locationHierarchyWithStartTime.add(new BaseDimAttribute(new FieldSchema("stateid2", "int", "state"), "state refer2", NOW, null, 100.0)); locationHierarchyWithStartTime.add(new BaseDimAttribute(new FieldSchema("countryid2", "int", "country"), "Country refer2", null, null, null)); locationHierarchyWithStartTime.add(new BaseDimAttribute(new FieldSchema("regionname2", "string", "region"), "regionname2", null, null, null, null, regions)); cubeDimensions.add(new BaseDimAttribute(new FieldSchema("dim1startTime", "string", "basedim"), "Dim With starttime", NOW, null, 100.0)); cubeDimensions.add(new BaseDimAttribute(new FieldSchema("dim2start", "string", "ref dim"),
); } else { hiveDim = new BaseDimAttribute(new FieldSchema(xd.getName(), xd.getType().toLowerCase(), xd.getDescription()), xd.getDisplayString(),
); } else { hiveDim = new BaseDimAttribute(new FieldSchema(xd.getName(), xd.getType().toLowerCase(), xd.getDescription()), xd.getDisplayString(),
toAlter.alterAttribute(new BaseDimAttribute(new FieldSchema("newZipDim", "int", "new dim added"), null, null, null, null, 1000L)); toAlter.alterAttribute(new ReferencedDimAttribute(new FieldSchema("newRefDim", "int", "new ref-dim added"), "New city ref", "cubecity", "name", null, null, null)); toAlter.alterAttribute(new BaseDimAttribute(new FieldSchema("f2", "varchar", "modified field"))); toAlter.alterAttribute(new BaseDimAttribute(new FieldSchema("stateid", "int", "state id"), "State refer altered", null, null, null)); toAlter.removeAttribute("f1");
"Measure3Altered", null, "MAX", "alterunit")); toAlter.removeMeasure("msr4"); toAlter.alterDimension(new BaseDimAttribute(new FieldSchema("testAddDim1", "string", "dim to add"))); toAlter.alterDimension(new BaseDimAttribute(new FieldSchema("dim1", "int", "basedim altered"))); toAlter.removeDimension("location2"); toAlter.addTimedDimension("zt");
new BaseDimAttribute(new FieldSchema(col.getName(), "string", "invalid col"), col.getDisplayString(), oneWeekBack, null, col.getCost(), null); cube.alterDimension(newDim2);