Java Code Examples for org.apache.kylin.metadata.model.ColumnDesc#getName()
The following examples show how to use
org.apache.kylin.metadata.model.ColumnDesc#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlatTableSqlQuoteUtils.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
/** * Used to quote identifiers for JDBC ext job when quoting cc expr * @param tableDesc * @param sqlExpr * @return */ public static String quoteIdentifierInSqlExpr(TableDesc tableDesc, String sqlExpr, SqlDialect sqlDialect) { String table = tableDesc.getName(); boolean tableMatched = false; List<String> tabPatterns = getTableNameOrAliasPatterns(table); if (isIdentifierNeedToQuote(sqlExpr, table, tabPatterns)) { sqlExpr = quoteIdentifier(sqlExpr, table, tabPatterns, sqlDialect); tableMatched = true; } if (tableMatched) { for (ColumnDesc columnDesc : tableDesc.getColumns()) { String column = columnDesc.getName(); List<String> colPatterns = getColumnNameOrAliasPatterns(column); if (isIdentifierNeedToQuote(sqlExpr, column, colPatterns)) { sqlExpr = quoteIdentifier(sqlExpr, column, colPatterns, sqlDialect); } } } return sqlExpr; }
Example 2
Source File: FlatTableSqlQuoteUtils.java From kylin with Apache License 2.0 | 6 votes |
/** * Used to quote identifiers for JDBC ext job when quoting cc expr * @param tableDesc * @param sqlExpr * @return */ public static String quoteIdentifierInSqlExpr(TableDesc tableDesc, String sqlExpr, SqlDialect sqlDialect) { String table = tableDesc.getName(); boolean tableMatched = false; List<String> tabPatterns = getTableNameOrAliasPatterns(table); if (isIdentifierNeedToQuote(sqlExpr, table, tabPatterns)) { sqlExpr = quoteIdentifier(sqlExpr, table, tabPatterns, sqlDialect); tableMatched = true; } if (tableMatched) { for (ColumnDesc columnDesc : tableDesc.getColumns()) { String column = columnDesc.getName(); List<String> colPatterns = getColumnNameOrAliasPatterns(column); if (isIdentifierNeedToQuote(sqlExpr, column, colPatterns)) { sqlExpr = quoteIdentifier(sqlExpr, column, colPatterns, sqlDialect); } } } return sqlExpr; }
Example 3
Source File: ColumnGenerator.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
public RandomGen(ColumnDesc col, String format, int randStart, int randEnd, int cardinality) { this.type = col.getType(); if (type.isStringFamily()) { // string if (StringUtils.isBlank(format)) { String name = col.getName(); format = name.substring(0, Math.min(4, name.length())) + ColumnGenConfig.$RANDOM; } Preconditions.checkArgument(format.contains(ColumnGenConfig.$RANDOM)); initNumberRange(randStart, randEnd, cardinality); } else if (type.isTimeFamily()) { // time format = StringUtil.noBlank(format, DateFormat.DEFAULT_DATETIME_PATTERN_WITHOUT_MILLISECONDS); initDateTimeRange(randStart, randEnd, 0); } else if (type.isDateTimeFamily()) { // date format = StringUtil.noBlank(format, DateFormat.DEFAULT_DATE_PATTERN); initDateTimeRange(randStart, randEnd, cardinality); } else if (type.isIntegerFamily()) { // integer initNumberRange(randStart, randEnd, cardinality); format = StringUtil.noBlank(format, "#"); } else if (type.isNumberFamily()) { // double initNumberRange(randStart, randEnd, 0); format = StringUtil.noBlank(format, ".##"); } else { throw new IllegalArgumentException(); } this.format = format; this.rand = new Random(); }
Example 4
Source File: ColumnGenerator.java From kylin with Apache License 2.0 | 5 votes |
public RandomGen(ColumnDesc col, String format, int randStart, int randEnd, int cardinality) { this.type = col.getType(); if (type.isStringFamily()) { // string if (StringUtils.isBlank(format)) { String name = col.getName(); format = name.substring(0, Math.min(4, name.length())) + ColumnGenConfig.$RANDOM; } Preconditions.checkArgument(format.contains(ColumnGenConfig.$RANDOM)); initNumberRange(randStart, randEnd, cardinality); } else if (type.isTimeFamily()) { // time format = StringUtil.noBlank(format, DateFormat.DEFAULT_DATETIME_PATTERN_WITHOUT_MILLISECONDS); initDateTimeRange(randStart, randEnd, 0); } else if (type.isDateTimeFamily()) { // date format = StringUtil.noBlank(format, DateFormat.DEFAULT_DATE_PATTERN); initDateTimeRange(randStart, randEnd, cardinality); } else if (type.isIntegerFamily()) { // integer initNumberRange(randStart, randEnd, cardinality); format = StringUtil.noBlank(format, "#"); } else if (type.isNumberFamily()) { // double initNumberRange(randStart, randEnd, 0); format = StringUtil.noBlank(format, ".##"); } else { throw new IllegalArgumentException(); } this.format = format; this.rand = new Random(); }
Example 5
Source File: FactTableGenerator.java From Kylin with Apache License 2.0 | 5 votes |
private String createCell(ColumnDesc cDesc) throws Exception { ColumnConfig cConfig = null; if ((cConfig = genConf.getColumnConfigByName(cDesc.getName())) == null) { // if the column is not configured, use random values return (createRandomCell(cDesc)); } else { // the column has a configuration if (!cConfig.isAsRange() && !cConfig.isExclusive() && r.nextBoolean()) { // if the column still allows random values return (createRandomCell(cDesc)); } else { // use specified values ArrayList<String> valueSet = cConfig.getValueSet(); if (valueSet == null || valueSet.size() == 0) throw new Exception("Did you forget to specify value set for " + cDesc.getName()); if (!cConfig.isAsRange()) { return (randomPick(valueSet)); } else { if (valueSet.size() != 2) throw new Exception("Only two values can be set for range values, the column: " + cDesc.getName()); return (createRandomCell(cDesc, valueSet)); } } } }
Example 6
Source File: FactTableGenerator.java From Kylin with Apache License 2.0 | 5 votes |
private LinkedList<String> createRow(TreeMap<String, String> factTableCol2LookupCol, TreeSet<String> usedCols, TreeSet<String> defaultColumns) throws Exception { KylinConfig config = KylinConfig.getInstanceFromEnv(); LinkedList<String> columnValues = new LinkedList<String>(); for (ColumnDesc cDesc : MetadataManager.getInstance(config).getTableDesc(factTableName).getColumns()) { String colName = cDesc.getName(); if (factTableCol2LookupCol.containsKey(colName)) { // if the current column is a fk column in fact table ArrayList<String> candidates = this.feasibleValues.get(factTableCol2LookupCol.get(colName)); columnValues.add(candidates.get(r.nextInt(candidates.size()))); } else if (usedCols.contains(colName)) { // if the current column is a metric column in fact table columnValues.add(createCell(cDesc)); } else { // otherwise this column is not useful in OLAP columnValues.add(createDefaultsCell(cDesc.getTypeName())); defaultColumns.add(colName); } } return columnValues; }
Example 7
Source File: DictionaryInfo.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
public DictionaryInfo(ColumnDesc col, String dataType) { this(col.getTable().getIdentity(), col.getName(), col.getZeroBasedIndex(), dataType, null); }
Example 8
Source File: DictionaryInfo.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
public DictionaryInfo(ColumnDesc col, String dataType, TableSignature input) { this(col.getTable().getIdentity(), col.getName(), col.getZeroBasedIndex(), dataType, input); }
Example 9
Source File: DictionaryInfo.java From kylin with Apache License 2.0 | 4 votes |
public DictionaryInfo(ColumnDesc col, String dataType) { this(col.getTable().getIdentity(), col.getName(), col.getZeroBasedIndex(), dataType, null); }
Example 10
Source File: DictionaryInfo.java From kylin with Apache License 2.0 | 4 votes |
public DictionaryInfo(ColumnDesc col, String dataType, TableSignature input) { this(col.getTable().getIdentity(), col.getName(), col.getZeroBasedIndex(), dataType, input); }