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();
}
Aggregations