public String getExpressionInSourceDB() { if (!column.isComputedColumn()) { return getIdentity(); } else { return column.getComputedColumnExpr(); } }
TableRef(DataModelDesc model, String alias, TableDesc table, boolean filterOutComputedColumns) { this.model = model; this.modelName = model.getName(); this.alias = alias; this.table = table; this.columns = Maps.newLinkedHashMap(); for (ColumnDesc col : table.getColumns()) { if (!filterOutComputedColumns || !col.isComputedColumn()) { columns.put(col.getName(), new TblColRef(this, col)); } } }
if (existingColumns[i].getName().equalsIgnoreCase(computedColumns[j].getName())) { if (!existingColumns[i].isComputedColumn()) { String errorMsg = String.format(Locale.ROOT, "There is already a column named %s on table %s, please change your computed column name",
/** * check whether all columns used in `cube` has compatible schema in current hive schema denoted by `fieldsMap`. * @param cube cube to check, must use `table` in its model * @param origTable kylin's table metadata * @param fieldsMap current hive schema of `table` * @return true if all columns used in `cube` has compatible schema with `fieldsMap`, false otherwise */ private List<String> checkAllColumnsInCube(CubeInstance cube, TableDesc origTable, TableDesc newTable) { Set<ColumnDesc> usedColumns = Sets.newHashSet(); for (TblColRef col : cube.getAllColumns()) { usedColumns.add(col.getColumnDesc()); } List<String> violateColumns = Lists.newArrayList(); for (ColumnDesc column : origTable.getColumns()) { if (!column.isComputedColumn() && usedColumns.contains(column)) { ColumnDesc newCol = newTable.findColumnByName(column.getName()); if (newCol == null || !isColumnCompatible(column, newCol)) { violateColumns.add(column.getName()); } } } return violateColumns; }
void init(DataModelDesc model) { table = table.toUpperCase(Locale.ROOT); if (columns != null) { StringUtil.toUpperCaseArray(columns, columns); } if (model != null) { table = model.findTable(table).getAlias(); if (columns != null) { for (int i = 0; i < columns.length; i++) { TblColRef column = model.findColumn(table, columns[i]); if (column.getColumnDesc().isComputedColumn() && !model.isFactTable(column.getTableRef())) { throw new RuntimeException("Computed Column on lookup table is not allowed"); } columns[i] = column.getName(); } } } }
private String generateCreateH2TableSql(TableDesc tableDesc, String csvFilePath) { StringBuilder ddl = new StringBuilder(); StringBuilder csvColumns = new StringBuilder(); ddl.append("CREATE TABLE " + tableDesc.getIdentity() + "\n"); ddl.append("(" + "\n"); for (int i = 0; i < tableDesc.getColumns().length; i++) { ColumnDesc col = tableDesc.getColumns()[i]; if (col.isComputedColumn()) { continue; } if (i > 0) { ddl.append(","); csvColumns.append(","); } ddl.append(col.getName() + " " + getH2DataType((col.getDatatype())) + "\n"); csvColumns.append(col.getName()); } ddl.append(")" + "\n"); ddl.append("AS SELECT * FROM CSVREAD('" + csvFilePath + "', '" + csvColumns + "', 'charset=UTF-8 fieldSeparator=,');"); return ddl.toString(); }
if (!col.getColumnDesc().isComputedColumn()) { ColumnDesc foundCol = table.findColumnByName(col.getName()); if (col.getColumnDesc().equals(foundCol) == false) {
public static String getQuotedColExpressionInSourceDB(IJoinedFlatTableDesc flatDesc, TblColRef col) { if (!col.getColumnDesc().isComputedColumn()) { return quoteIdentifier(col.getTableAlias()) + "." + quoteIdentifier(col.getName()); } else { String computeExpr = col.getColumnDesc().getComputedColumnExpr(); return quoteIdentifierInSqlExpr(flatDesc, computeExpr, "`"); } } }
public String getExpressionInSourceDB() { if (!column.isComputedColumn()) { return getIdentity(); } else { return column.getComputedColumnExpr(); } }
TableRef(DataModelDesc model, String alias, TableDesc table, boolean filterOutComputedColumns) { this.model = model; this.modelName = model.getName(); this.alias = alias; this.table = table; this.columns = Maps.newLinkedHashMap(); for (ColumnDesc col : table.getColumns()) { if (!filterOutComputedColumns || !col.isComputedColumn()) { columns.put(col.getName(), new TblColRef(this, col)); } } }
if (existingColumns[i].getName().equalsIgnoreCase(computedColumns[j].getName())) { if (!existingColumns[i].isComputedColumn()) { String errorMsg = String.format(Locale.ROOT, "There is already a column named %s on table %s, please change your computed column name",
void init(DataModelDesc model) { table = table.toUpperCase(Locale.ROOT); if (columns != null) { StringUtil.toUpperCaseArray(columns, columns); } if (model != null) { table = model.findTable(table).getAlias(); if (columns != null) { for (int i = 0; i < columns.length; i++) { TblColRef column = model.findColumn(table, columns[i]); if (column.getColumnDesc().isComputedColumn() && !model.isFactTable(column.getTableRef())) { throw new RuntimeException("Computed Column on lookup table is not allowed"); } columns[i] = column.getName(); } } } }
public static String getQuotedColExpressionInSourceDB(IJoinedFlatTableDesc flatDesc, TblColRef col) { if (!col.getColumnDesc().isComputedColumn()) { return quoteIdentifier(col.getTableAlias()) + "." + quoteIdentifier(col.getName()); } else { String computeExpr = col.getColumnDesc().getComputedColumnExpr(); return quoteIdentifierInSqlExpr(flatDesc, computeExpr, "`"); } } }
if (!col.getColumnDesc().isComputedColumn()) { ColumnDesc foundCol = table.findColumnByName(col.getName()); if (col.getColumnDesc().equals(foundCol) == false) {