@Override public Optional<Date> getColumnEndTime(String column) { Date endTime = null; for (String key : getTable().getProperties().keySet()) { if (key.contains(MetastoreConstants.FACT_COL_END_TIME_PFX)) { String propCol = StringUtils.substringAfter(key, MetastoreConstants.FACT_COL_END_TIME_PFX); if (column.equals(propCol)) { endTime = MetastoreUtil.getDateFromProperty(getTable().getProperties().get(key), false, true); } } } return Optional.ofNullable(endTime); }
public Optional<Date> getColumnStartTime(String column) { Date startTime = null; for (String key : getTable().getProperties().keySet()) { if (key.contains(MetastoreConstants.FACT_COL_START_TIME_PFX)) { String propCol = StringUtils.substringAfter(key, MetastoreConstants.FACT_COL_START_TIME_PFX); if (column.equals(propCol)) { startTime = MetastoreUtil.getDateFromProperty(getTable().getProperties().get(key), false, true); } } } return Optional.ofNullable(startTime); }
protected AbstractCubeTable(Table hiveTable) { this.name = hiveTable.getTableName().toLowerCase(); this.columns = hiveTable.getCols(); this.properties.putAll(hiveTable.getParameters()); this.weight = getWeight(getProperties(), getName()); }
protected AbstractCubeTable(Table hiveTable) { this.name = hiveTable.getTableName().toLowerCase(); this.columns = hiveTable.getCols(); this.properties.putAll(hiveTable.getParameters()); this.weight = getWeight(getProperties(), getName()); }
/** * * @param table table name * @param hiveTable hive table * @param cubeTable lens cube table * @return true if columns changed in alter * @throws LensException */ private boolean alterCubeTable(String table, Table hiveTable, AbstractCubeTable cubeTable) throws LensException { hiveTable.getParameters().putAll(cubeTable.getProperties()); boolean columnsChanged = !(hiveTable.getCols().equals(cubeTable.getColumns())); if (columnsChanged) { hiveTable.getTTable().getSd().setCols(cubeTable.getColumns()); } hiveTable.getTTable().getParameters().putAll(cubeTable.getProperties()); try { getClient().alterTable(table, hiveTable, null); } catch (Exception e) { throw new LensException(e); } return columnsChanged; }
/** * * @param table table name * @param hiveTable hive table * @param cubeTable lens cube table * @return true if columns changed in alter * @throws LensException */ private boolean alterCubeTable(String table, Table hiveTable, AbstractCubeTable cubeTable) throws LensException { hiveTable.getParameters().putAll(cubeTable.getProperties()); boolean columnsChanged = !(hiveTable.getCols().equals(cubeTable.getColumns())); if (columnsChanged) { hiveTable.getTTable().getSd().setCols(cubeTable.getColumns()); } hiveTable.getTTable().getParameters().putAll(cubeTable.getProperties()); try { getClient().alterTable(table, hiveTable, null); } catch (Exception e) { throw new LensException(e); } return columnsChanged; }
private Table createCubeHiveTable(AbstractCubeTable table) throws LensException { try { Table tbl = getClient().newTable(table.getName().toLowerCase()); tbl.setTableType(TableType.MANAGED_TABLE); tbl.getTTable().getSd().setCols(table.getColumns()); tbl.getTTable().getParameters().putAll(table.getProperties()); getClient().createTable(tbl); // do get to update cache getTable(tbl.getTableName()); return tbl; } catch (Exception e) { throw new LensException("Exception creating table", e); } }
private Table createCubeHiveTable(AbstractCubeTable table) throws LensException { try { Table tbl = getClient().newTable(table.getName().toLowerCase()); tbl.setTableType(TableType.MANAGED_TABLE); tbl.getTTable().getSd().setCols(table.getColumns()); tbl.getTTable().getParameters().putAll(table.getProperties()); getClient().createTable(tbl); // do get to update cache getTable(tbl.getTableName()); return tbl; } catch (Exception e) { throw new LensException("Exception creating table", e); } }
public static XDimension xdimensionFromDimension(Dimension dimension) { XDimension xd = XCF.createXDimension(); xd.setName(dimension.getName()); xd.setAttributes(new XDimAttributes()); xd.setExpressions(new XExpressions()); xd.setJoinChains(new XJoinChains()); xd.setProperties(new XProperties()); xd.getProperties().getProperty().addAll(xPropertiesFromMap(((AbstractCubeTable) dimension).getProperties())); for (CubeDimAttribute cd : dimension.getAttributes()) { xd.getAttributes().getDimAttribute().add(xDimAttrFromHiveDimAttr(cd, dimension)); } for (ExprColumn ec : dimension.getExpressions()) { xd.getExpressions().getExpression().add(xExprColumnFromHiveExprColumn(ec)); } for (JoinChain jc : dimension.getJoinChains()) { xd.getJoinChains().getJoinChain().add(getXJoinChainFromJoinChain(jc)); } return xd; }
public static XDimension xdimensionFromDimension(Dimension dimension) { XDimension xd = XCF.createXDimension(); xd.setName(dimension.getName()); xd.setAttributes(new XDimAttributes()); xd.setExpressions(new XExpressions()); xd.setJoinChains(new XJoinChains()); xd.setProperties(new XProperties()); xd.getProperties().getProperty().addAll(xPropertiesFromMap(((AbstractCubeTable) dimension).getProperties())); for (CubeDimAttribute cd : dimension.getAttributes()) { xd.getAttributes().getDimAttribute().add(xDimAttrFromHiveDimAttr(cd, dimension)); } for (ExprColumn ec : dimension.getExpressions()) { xd.getExpressions().getExpression().add(xExprColumnFromHiveExprColumn(ec)); } for (JoinChain jc : dimension.getJoinChains()) { xd.getJoinChains().getJoinChain().add(getXJoinChainFromJoinChain(jc)); } return xd; }
assertTrue(hcube.getMeasureByName("msr3").getAggregate().equals("sum")); assertNotNull(hcube.getDimAttributeByName("dim3")); assertEquals(((AbstractCubeTable) hcube).getProperties().get("foo2"), "bar2"); assertTrue(hdcube.getMeasureByName("msr3").getAggregate().equals("sum")); assertNotNull(hdcube.getDimAttributeByName("dim3")); assertEquals(((AbstractCubeTable) hdcube).getProperties().get("foo.derived2"), "bar.derived2");
xc.getProperties().getProperty().addAll(xPropertiesFromMap(((AbstractCubeTable) c).getProperties())); return xc;
xc.getProperties().getProperty().addAll(xPropertiesFromMap(((AbstractCubeTable) c).getProperties())); return xc;