Java Code Examples for org.apache.kylin.metadata.model.TableDesc#getName()

The following examples show how to use org.apache.kylin.metadata.model.TableDesc#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: OLAPSchema.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
private Map<String, Table> buildTableMap() {
    Map<String, Table> olapTables = new HashMap<String, Table>();

    Collection<TableDesc> projectTables = ProjectManager.getInstance(config).listExposedTables(projectName,
            exposeMore);

    for (TableDesc tableDesc : projectTables) {
        if (tableDesc.getDatabase().equals(schemaName)) {
            final String tableName = tableDesc.getName();//safe to use tableDesc.getName() here, it is in a DB context now
            final OLAPTable table = new OLAPTable(this, tableDesc, exposeMore);
            olapTables.put(tableName, table);
            //logger.debug("Project " + projectName + " exposes table " + tableName);
        }
    }

    return olapTables;
}
 
Example 2
Source File: FlatTableSqlQuoteUtils.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * 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: OLAPSchema.java    From kylin with Apache License 2.0 6 votes vote down vote up
private Map<String, Table> buildTableMap() {
    Map<String, Table> olapTables = new HashMap<String, Table>();

    Collection<TableDesc> projectTables = ProjectManager.getInstance(config).listExposedTables(projectName,
            exposeMore);

    for (TableDesc tableDesc : projectTables) {
        if (tableDesc.getDatabase().equals(schemaName)) {
            final String tableName = tableDesc.getName();//safe to use tableDesc.getName() here, it is in a DB context now
            final OLAPTable table = new OLAPTable(this, tableDesc, exposeMore);
            olapTables.put(tableName, table);
            //logger.debug("Project " + projectName + " exposes table " + tableName);
        }
    }

    return olapTables;
}
 
Example 4
Source File: FlatTableSqlQuoteUtils.java    From kylin with Apache License 2.0 6 votes vote down vote up
/**
 * 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 5
Source File: HiveTable.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public HiveTable(TableDesc tableDesc) {
    this.database = tableDesc.getDatabase();
    this.hiveTable = tableDesc.getName();
    try {
        this.hiveTableMeta = getHiveClient().getHiveTableMeta(database, hiveTable);
    } catch (Exception e) {
        throw new RuntimeException("cannot get HiveTableMeta", e);
    }
}
 
Example 6
Source File: ValidateUtil.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private Set<String> getAllColumns(String project, String table) throws IOException {
    List<TableDesc> tableDescByProject = tableService.getTableDescByProject(project, true);
    Set<String> cols = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);

    for (TableDesc tableDesc : tableDescByProject) {
        String tbl = tableDesc.getDatabase() + "." + tableDesc.getName();
        if (tbl.equalsIgnoreCase(table)) {
            for (ColumnDesc column : tableDesc.getColumns()) {
                cols.add(column.getName());
            }
            break;
        }
    }
    return cols;
}
 
Example 7
Source File: HiveTable.java    From kylin with Apache License 2.0 5 votes vote down vote up
public HiveTable(TableDesc tableDesc) {
    this.database = tableDesc.getDatabase();
    this.hiveTable = tableDesc.getName();
    try {
        this.hiveTableMeta = getHiveClient().getHiveTableMeta(database, hiveTable);
    } catch (Exception e) {
        throw new RuntimeException("cannot get HiveTableMeta", e);
    }
}
 
Example 8
Source File: ValidateUtil.java    From kylin with Apache License 2.0 5 votes vote down vote up
private Set<String> getAllColumns(String project, String table) throws IOException {
    List<TableDesc> tableDescByProject = tableService.getTableDescByProject(project, true);
    Set<String> cols = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);

    for (TableDesc tableDesc : tableDescByProject) {
        String tbl = tableDesc.getDatabase() + "." + tableDesc.getName();
        if (tbl.equalsIgnoreCase(table)) {
            for (ColumnDesc column : tableDesc.getColumns()) {
                cols.add(column.getName());
            }
            break;
        }
    }
    return cols;
}
 
Example 9
Source File: OLAPSchema.java    From Kylin with Apache License 2.0 5 votes vote down vote up
private Map<String, Table> buildTableMap() {
    Map<String, Table> olapTables = new HashMap<String, Table>();
    Set<TableDesc> projectTables = ProjectManager.getInstance(config).listExposedTables(projectName);

    for (TableDesc tableDesc : projectTables) {
        if (tableDesc.getDatabase().equals(schemaName)) {
            final String tableName = tableDesc.getName();//safe to use tableDesc.getName() here, it is in a DB context now
            final OLAPTable table = new OLAPTable(this, tableDesc);
            olapTables.put(tableName, table);
            //            logger.debug("Project " + projectName + " exposes table " + tableName);
        }
    }

    return olapTables;
}
 
Example 10
Source File: HiveInputBase.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
protected static String getTableNameForHCat(TableDesc table, String uuid) {
    String tableName = (table.isView()) ? table.getMaterializedName(uuid) : table.getName();
    String database = (table.isView()) ? KylinConfig.getInstanceFromEnv().getHiveDatabaseForIntermediateTable()
            : table.getDatabase();
    return String.format(Locale.ROOT, "%s.%s", database, tableName).toUpperCase(Locale.ROOT);
}
 
Example 11
Source File: JdbcTable.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
public JdbcTable(JdbcConnector dataSource, TableDesc tableDesc) {
    this.dataSource = dataSource;
    this.database = tableDesc.getDatabase();
    this.tableName = tableDesc.getName();
}
 
Example 12
Source File: JdbcTable.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
public JdbcTable(TableDesc tableDesc) {
    this.database = tableDesc.getDatabase();
    this.tableName = tableDesc.getName();
}
 
Example 13
Source File: HiveInputBase.java    From kylin with Apache License 2.0 4 votes vote down vote up
protected static String getTableNameForHCat(TableDesc table, String uuid) {
    String tableName = (table.isView()) ? table.getMaterializedName(uuid) : table.getName();
    String database = (table.isView()) ? KylinConfig.getInstanceFromEnv().getHiveDatabaseForIntermediateTable()
            : table.getDatabase();
    return String.format(Locale.ROOT, "%s.%s", database, tableName).toUpperCase(Locale.ROOT);
}
 
Example 14
Source File: JdbcTable.java    From kylin with Apache License 2.0 4 votes vote down vote up
public JdbcTable(JdbcConnector dataSource, TableDesc tableDesc) {
    this.dataSource = dataSource;
    this.database = tableDesc.getDatabase();
    this.tableName = tableDesc.getName();
}
 
Example 15
Source File: JdbcTable.java    From kylin with Apache License 2.0 4 votes vote down vote up
public JdbcTable(TableDesc tableDesc) {
    this.database = tableDesc.getDatabase();
    this.tableName = tableDesc.getName();
}
 
Example 16
Source File: HiveTable.java    From Kylin with Apache License 2.0 4 votes vote down vote up
public HiveTable(MetadataManager metaMgr, String table) {
    TableDesc tableDesc = metaMgr.getTableDesc(table);
    this.database = tableDesc.getDatabase();
    this.hiveTable = tableDesc.getName();
    this.nColumns = tableDesc.getColumnCount();
}