for (String fk : joinDesc.getForeignKey()) { String columnIdentity = (dataModelDesc.findTable(fk.substring(0, fk.indexOf("."))) .getTableIdentity() + fk.substring(fk.indexOf("."))).replace('.', '#');
throw new IllegalStateException("Missing join conditions on table " + dimTable); StringUtil.toUpperCaseArray(join.getForeignKey(), join.getForeignKey()); StringUtil.toUpperCaseArray(join.getPrimaryKey(), join.getPrimaryKey()); String[] fks = join.getForeignKey(); TblColRef[] fkCols = new TblColRef[fks.length]; for (int i = 0; i < fks.length; i++) {
@Test public void testCiModel() { DataModelManager mgr = getInstance(getTestConfig()); DataModelDesc lm = mgr.getDataModelDesc("ci_left_join_model"); DataModelDesc im = mgr.getDataModelDesc("ci_inner_join_model"); assertSnowflakeQuality(lm); assertSnowflakeQuality(im); // check inner/left models are identical apart from the left/inner difference assertEquals(lm.getJoinTables().length, im.getJoinTables().length); for (int i = 0, n = im.getJoinTables().length; i < n; i++) { JoinTableDesc lt = lm.getJoinTables()[i]; JoinTableDesc it = im.getJoinTables()[i]; assertEquals(lt.getAlias(), it.getAlias()); assertEquals(lt.getKind(), it.getKind()); assertEquals(lt.getTable(), it.getTable()); assertArrayEquals(lt.getJoin().getForeignKey(), it.getJoin().getForeignKey()); assertArrayEquals(lt.getJoin().getPrimaryKey(), it.getJoin().getPrimaryKey()); assertTrue(lt.getJoin().isLeftJoin()); assertTrue(it.getJoin().isInnerJoin()); } assertEquals(lm.getDimensions().size(), im.getDimensions().size()); for (int i = 0, n = im.getDimensions().size(); i < n; i++) { ModelDimensionDesc ld = lm.getDimensions().get(i); ModelDimensionDesc id = im.getDimensions().get(i); assertEquals(ld.getTable(), id.getTable()); assertArrayEquals(ld.getColumns(), id.getColumns()); } assertArrayEquals(lm.getMetrics(), im.getMetrics()); }
public void init(Map<String, TableDesc> tables) { if (name != null) name = name.toUpperCase(); if (table != null) table = table.toUpperCase(); if (column != null) column = column.toUpperCase(); TableDesc tableDesc = tables.get(table); if (tableDesc == null) throw new IllegalStateException("Can't find table " + table + " on dimension " + name); if (hierarchy != null && hierarchy.length == 0) hierarchy = null; if (derived != null && derived.length == 0) derived = null; if (join != null) { StringUtil.toUpperCaseArray(join.getForeignKey(), join.getForeignKey()); StringUtil.toUpperCaseArray(join.getPrimaryKey(), join.getPrimaryKey()); } if (hierarchy != null) { for (HierarchyDesc h : hierarchy) h.setColumn(h.getColumn().toUpperCase()); } if (derived != null) { StringUtil.toUpperCaseArray(derived, derived); } }
continue; StringUtil.toUpperCaseArray(join.getForeignKey(), join.getForeignKey()); StringUtil.toUpperCaseArray(join.getPrimaryKey(), join.getPrimaryKey()); throw new IllegalStateException("Fact table does not exist:" + this.getFactTable()); String[] fks = join.getForeignKey(); TblColRef[] fkCols = new TblColRef[fks.length]; for (int i = 0; i < fks.length; i++) {
newDim.setTable(getMetadataManager().appendDBName(newModel.getFactTable())); newDim.setColumn(dim.getJoin().getForeignKey());
for (org.apache.kylin.cube.model.v1.DimensionDesc dim : oldDimensions) { JoinDesc join = dim.getJoin(); if (join != null && !StringUtils.isEmpty(join.getType()) && join.getForeignKey() != null && join.getForeignKey().length > 0) { LookupDesc lookup = new LookupDesc(); lookup.setJoin(join);
JoinDesc jDesc = dim.getJoin(); if (jDesc != null) { String[] fks = jDesc.getForeignKey(); String[] pks = jDesc.getPrimaryKey(); int num = fks.length;
addError("Fact table does not exist:" + this.factTable); String[] fks = join.getForeignKey(); TblColRef[] fkCols = new TblColRef[fks.length]; for (int i = 0; i < fks.length; i++) {
public void init(Map<String, TableDesc> tables) { if (name != null) name = name.toUpperCase(); if (table != null) table = table.toUpperCase(); if (column != null) column = column.toUpperCase(); TableDesc tableDesc = tables.get(table); if (tableDesc == null) throw new IllegalStateException("Can't find table " + table + " on dimension " + name); if (hierarchy != null && hierarchy.length == 0) hierarchy = null; if (derived != null && derived.length == 0) derived = null; if (join != null) { StringUtil.toUpperCaseArray(join.getForeignKey(), join.getForeignKey()); StringUtil.toUpperCaseArray(join.getPrimaryKey(), join.getPrimaryKey()); } if (hierarchy != null) { for (HierarchyDesc h : hierarchy) h.setColumn(h.getColumn().toUpperCase()); } if (derived != null) { StringUtil.toUpperCaseArray(derived, derived); } }
private void updateRowkeyDictionary(org.apache.kylin.cube.model.CubeDesc newModel) { DataModelDesc modelDesc = newModel.getModel(); Map<String, String> pkToFK = Maps.newHashMap(); for (LookupDesc lookupDesc : modelDesc.getLookups()) { if (lookupDesc.getJoin() != null) { JoinDesc join = lookupDesc.getJoin(); for (int i = 0; i < join.getForeignKey().length; i++) { pkToFK.put(join.getPrimaryKey()[i], join.getForeignKey()[i]); } } } RowKeyDesc rowKey = newModel.getRowkey(); for (RowKeyColDesc rowkeyCol : rowKey.getRowKeyColumns()) { if (rowkeyCol.getDictionary() != null && rowkeyCol.getDictionary().length() > 0) rowkeyCol.setDictionary("true"); if (pkToFK.containsKey(rowkeyCol.getColumn())) { rowkeyCol.setColumn(pkToFK.get(rowkeyCol.getColumn())); } } for (String[] aggregationGroup : rowKey.getAggregationGroups()) { for (int i = 0; i < aggregationGroup.length; i++) { if (pkToFK.containsKey(aggregationGroup[i])) { aggregationGroup[i] = pkToFK.get(aggregationGroup[i]); } } } }
if (lookupDesc.getJoin() != null) { JoinDesc join = lookupDesc.getJoin(); for (int i = 0; i < join.getForeignKey().length; i++) { pkToFK.put(lookupDesc.getTable() + "/" + join.getPrimaryKey()[i], dataModelDesc.getFactTable() + "/" + join.getForeignKey()[i]);
throw new IllegalStateException("Missing join conditions on table " + dimTable); StringUtil.toUpperCaseArray(join.getForeignKey(), join.getForeignKey()); StringUtil.toUpperCaseArray(join.getPrimaryKey(), join.getPrimaryKey()); String[] fks = join.getForeignKey(); TblColRef[] fkCols = new TblColRef[fks.length]; for (int i = 0; i < fks.length; i++) {
continue; StringUtil.toUpperCaseArray(join.getForeignKey(), join.getForeignKey()); StringUtil.toUpperCaseArray(join.getPrimaryKey(), join.getPrimaryKey()); throw new IllegalStateException("Fact table does not exist:" + this.getFactTable()); String[] fks = join.getForeignKey(); TblColRef[] fkCols = new TblColRef[fks.length]; for (int i = 0; i < fks.length; i++) {
for (org.apache.kylin.cube.model.v1.DimensionDesc dim : oldDimensions) { JoinDesc join = dim.getJoin(); if (join != null && !StringUtils.isEmpty(join.getType()) && join.getForeignKey() != null && join.getForeignKey().length > 0) { String table = dim.getTable(); table = getMetadataManager().appendDBName(table);
newDim.setTable(getMetadataManager().appendDBName(newModel.getFactTable())); newDim.setColumn(dim.getJoin().getForeignKey());
addError("Fact table does not exist:" + this.factTable); String[] fks = join.getForeignKey(); TblColRef[] fkCols = new TblColRef[fks.length]; for (int i = 0; i < fks.length; i++) {