@Override public Map<String, String> getSourceFactProperties() { return getSourceCubeFactTable().getProperties(); }
private static Date getFactColumnStartTime(CandidateTable table, String factCol) { Date startTime = null; if (table instanceof StorageCandidate) { for (String key : ((StorageCandidate) table).getFact().getProperties().keySet()) { if (key.contains(MetastoreConstants.FACT_COL_START_TIME_PFX)) { String propCol = StringUtils.substringAfter(key, MetastoreConstants.FACT_COL_START_TIME_PFX); if (factCol.equals(propCol)) { startTime = MetastoreUtil.getDateFromProperty(((StorageCandidate) table).getFact().getProperties().get(key), false, true); } } } } return startTime; }
private static Date getFactColumnEndTime(CandidateTable table, String factCol) { Date endTime = null; if (table instanceof StorageCandidate) { for (String key : ((StorageCandidate) table).getFact().getProperties().keySet()) { if (key.contains(MetastoreConstants.FACT_COL_END_TIME_PFX)) { String propCol = StringUtils.substringAfter(key, MetastoreConstants.FACT_COL_END_TIME_PFX); if (factCol.equals(propCol)) { endTime = MetastoreUtil.getDateFromProperty(((StorageCandidate) table).getFact().getProperties().get(key), false, true); } } } } return endTime; }
private static Date getFactColumnEndTime(CandidateTable table, String factCol) { Date endTime = null; if (table instanceof StorageCandidate) { for (String key : ((StorageCandidate) table).getFact().getProperties().keySet()) { if (key.contains(MetastoreConstants.FACT_COL_END_TIME_PFX)) { String propCol = StringUtils.substringAfter(key, MetastoreConstants.FACT_COL_END_TIME_PFX); if (factCol.equals(propCol)) { endTime = MetastoreUtil.getDateFromProperty(((StorageCandidate) table).getFact().getProperties().get(key), false, true); } } } } return endTime; }
private static Date getFactColumnStartTime(CandidateTable table, String factCol) { Date startTime = null; if (table instanceof StorageCandidate) { for (String key : ((StorageCandidate) table).getFact().getProperties().keySet()) { if (key.contains(MetastoreConstants.FACT_COL_START_TIME_PFX)) { String propCol = StringUtils.substringAfter(key, MetastoreConstants.FACT_COL_START_TIME_PFX); if (factCol.equals(propCol)) { startTime = MetastoreUtil.getDateFromProperty(((StorageCandidate) table).getFact().getProperties().get(key), false, true); } } } } return startTime; }
FactTable fact = getFactTable(table, false); if (fact != null) { if (fact.getProperties().get(getSourceFactNameKey(fact.getName())) != null) { //is virtual fact if (includeVirtualFacts) { facts.add(fact);
FactTable fact = getFactTable(table, false); if (fact != null) { if (fact.getProperties().get(getSourceFactNameKey(fact.getName())) != null) { //is virtual fact if (includeVirtualFacts) { facts.add(fact);
/** * Drop a fact with cascade flag * * @param factName fact name * @param cascade If true, will drop all the storages of the fact * @throws LensException */ public void dropFact(String factName, boolean cascade) throws LensException { getTableWithTypeFailFast(factName, CubeTableType.FACT); FactTable fact = getFactTable(factName); if (cascade) { for (String storage : fact.getStorages()) { dropStorageFromFact(factName, storage, false); } } dropHiveTable(factName); allFactTables.remove(factName.trim().toLowerCase()); if (fact.isVirtualFact()) { String sourceFactTable = fact.getProperties().get(getSourceFactNameKey(fact.getName())); if (factToVirtualFactMapping.get(sourceFactTable) != null && factToVirtualFactMapping.get(sourceFactTable).contains(fact.getName())) { factToVirtualFactMapping.get(sourceFactTable).remove(fact.getName()); } } else { dropAllVirtualFactTables(factName); } }
/** * Alter a cubefact with new definition and alter underlying storage tables as well. * * @param factTableName fact table name * @param cubeFactTable cube fact table * @param storageTableDescs storage table desc objects * * @throws HiveException */ public void alterCubeFactTable(String factTableName, FactTable cubeFactTable, Map<String, StorageTableDesc> storageTableDescs, Map<String, String> props) throws HiveException, LensException { Table factTbl = getTableWithTypeFailFast(factTableName, CubeTableType.FACT); if (!props.isEmpty()) { cubeFactTable.getProperties().putAll(props); } alterCubeTable(factTableName, factTbl, (AbstractCubeTable) cubeFactTable); if (storageTableDescs != null) { // create/alter tables for each storage for (Map.Entry<String, StorageTableDesc> entry : storageTableDescs.entrySet()) { createOrAlterStorageHiveTable(getTable(factTableName), entry.getKey(), entry.getValue()); } } updateFactCache(factTableName); updateAllVirtualFacts(getFactTable(factTableName)); }
/** * Drop a fact with cascade flag * * @param factName fact name * @param cascade If true, will drop all the storages of the fact * @throws LensException */ public void dropFact(String factName, boolean cascade) throws LensException { getTableWithTypeFailFast(factName, CubeTableType.FACT); FactTable fact = getFactTable(factName); checkIfAuthorized(); if (cascade) { for (String storage : fact.getStorages()) { dropStorageFromFact(factName, storage, false); } } dropHiveTable(factName); allFactTables.remove(factName.trim().toLowerCase()); if (fact.isVirtualFact()) { String sourceFactTable = fact.getProperties().get(getSourceFactNameKey(fact.getName())); if (factToVirtualFactMapping.get(sourceFactTable) != null && factToVirtualFactMapping.get(sourceFactTable).contains(fact.getName())) { factToVirtualFactMapping.get(sourceFactTable).remove(fact.getName()); } } else { dropAllVirtualFactTables(factName); } }
/** * Alter a cubefact with new definition and alter underlying storage tables as well. * * @param factTableName fact table name * @param cubeFactTable cube fact table * @param storageTableDescs storage table desc objects * * @throws HiveException */ public void alterCubeFactTable(String factTableName, FactTable cubeFactTable, Map<String, StorageTableDesc> storageTableDescs, Map<String, String> props) throws HiveException, LensException { Table factTbl = getTableWithTypeFailFast(factTableName, CubeTableType.FACT); checkIfAuthorized(); if (!props.isEmpty()) { cubeFactTable.getProperties().putAll(props); } alterCubeTable(factTableName, factTbl, (AbstractCubeTable) cubeFactTable); if (storageTableDescs != null) { // create/alter tables for each storage for (Map.Entry<String, StorageTableDesc> entry : storageTableDescs.entrySet()) { createOrAlterStorageHiveTable(getTable(factTableName), entry.getKey(), entry.getValue()); } } updateFactCache(factTableName); updateAllVirtualFacts(getFactTable(factTableName)); }
@Override protected void setMissingExpressions() throws LensException { setFrom(getFromTable()); if (getQueryAst().getHavingAST() != null) { getStorageCandidate().getCubeQueryContext().getExprCtx().replaceHavingExpressions(); getQueryAst().setHavingAST(getCubeQueryContext().getHavingAST()); } String whereString = genWhereClauseWithDimPartitions(getWhere()); StringBuilder whereStringBuilder = (whereString != null) ? new StringBuilder(whereString) : new StringBuilder(); if (this.storageCandidate.getFact().getProperties().get(VIRTUAL_FACT_FILTER) != null) { appendWhereClause(whereStringBuilder, this.storageCandidate.getFact().getProperties().get(VIRTUAL_FACT_FILTER), whereString != null); } setWhere(whereStringBuilder.length() == 0 ? null : whereStringBuilder.toString()); if (isRoot()) { if (Objects.equals(getStorageCandidate(), getCubeQueryContext().getPickedCandidate())) { updateAnswerableSelectColumns(); // Check if the picked candidate is a StorageCandidate and in that case // update the selectAST with final alias. CandidateUtil.updateFinalAlias(queryAst.getSelectAST(), getCubeQueryContext()); CandidateUtil.updateOrderByWithFinalAlias(queryAst.getOrderByAST(), queryAst.getSelectAST()); setPrefix(getCubeQueryContext().getInsertClause()); } } }
@Override protected void setMissingExpressions() throws LensException { setFrom(getFromTable()); if (getQueryAst().getHavingAST() != null) { getStorageCandidate().getCubeQueryContext().getExprCtx().replaceHavingExpressions(); getQueryAst().setHavingAST(getCubeQueryContext().getHavingAST()); } String whereString = genWhereClauseWithDimPartitions(getWhere()); StringBuilder whereStringBuilder = (whereString != null) ? new StringBuilder(whereString) : new StringBuilder(); if (this.storageCandidate.getFact().getProperties().get(VIRTUAL_FACT_FILTER) != null) { appendWhereClause(whereStringBuilder, this.storageCandidate.getFact().getProperties().get(VIRTUAL_FACT_FILTER), whereString != null); } setWhere(whereStringBuilder.length() == 0 ? null : whereStringBuilder.toString()); if (isRoot()) { if (Objects.equals(getStorageCandidate(), getCubeQueryContext().getPickedCandidate())) { updateAnswerableSelectColumns(); // Check if the picked candidate is a StorageCandidate and in that case // update the selectAST with final alias. CandidateUtil.updateFinalAlias(queryAst.getSelectAST(), getCubeQueryContext()); CandidateUtil.updateOrderByWithFinalAlias(queryAst.getOrderByAST(), queryAst.getSelectAST()); setPrefix(getCubeQueryContext().getInsertClause()); } } }
public static XFactTable factTableFromCubeFactTable(FactTable cFact) { XFactTable fact = XCF.createXFactTable(); fact.setName(cFact.getName()); fact.setColumns(new XColumns()); fact.setProperties(new XProperties()); fact.setStorageTables(new XStorageTables()); fact.getProperties().getProperty().addAll(xPropertiesFromMap(cFact.getProperties())); fact.getColumns().getColumn().addAll(columnsFromFieldSchemaList(cFact.getColumns())); fact.setWeight(cFact.weight()); fact.setCubeName(cFact.getCubeName()); return fact; }
public static XFactTable factTableFromCubeFactTable(FactTable cFact) { XFactTable fact = XCF.createXFactTable(); fact.setName(cFact.getName()); fact.setColumns(new XColumns()); fact.setProperties(new XProperties()); fact.setStorageTables(new XStorageTables()); fact.getProperties().getProperty().addAll(xPropertiesFromMap(cFact.getProperties())); fact.getColumns().getColumn().addAll(columnsFromFieldSchemaList(cFact.getColumns())); fact.setWeight(cFact.weight()); fact.setCubeName(cFact.getCubeName()); return fact; }