Search in sources :

Example 1 with CatalogSchemaContext

use of com.airbnb.airpal.core.execution.InputReferenceExtractor.CatalogSchemaContext in project airpal by airbnb.

the class QueryExecutionAuthorizer method tablesUsedByQuery.

public static Set<Table> tablesUsedByQuery(String query, String defaultConnector, String defaultSchema) {
    List<String> statements = STATEMENT_SPLITTER.splitToList(query);
    ImmutableSet.Builder<Table> tables = ImmutableSet.builder();
    CatalogSchemaContext context = new CatalogSchemaContext(defaultConnector, defaultSchema);
    for (String strStatement : statements) {
        InputReferenceExtractor extractor = new InputReferenceExtractor();
        Statement statement = SQL_PARSER.createStatement(strStatement);
        context = statement.accept(extractor, context);
        tables.addAll(extractor.getReferences());
    }
    return tables.build();
}
Also used : Table(com.airbnb.airpal.presto.Table) ImmutableSet(com.google.common.collect.ImmutableSet) Statement(com.facebook.presto.sql.tree.Statement) CatalogSchemaContext(com.airbnb.airpal.core.execution.InputReferenceExtractor.CatalogSchemaContext)

Aggregations

CatalogSchemaContext (com.airbnb.airpal.core.execution.InputReferenceExtractor.CatalogSchemaContext)1 Table (com.airbnb.airpal.presto.Table)1 Statement (com.facebook.presto.sql.tree.Statement)1 ImmutableSet (com.google.common.collect.ImmutableSet)1