Search in sources :

Example 1 with SqlDropAllAliases

use of org.apache.drill.exec.planner.sql.parser.SqlDropAllAliases in project drill by apache.

the class DropAllAliasesHandler method getPlan.

@Override
public PhysicalPlan getPlan(SqlNode sqlNode) throws ForemanSetupException, IOException {
    checkAliasesEnabled();
    SqlDropAllAliases node = unwrap(sqlNode, SqlDropAllAliases.class);
    String aliasTarget = ((SqlLiteral) node.getAliasKind()).toValue();
    AliasRegistry aliasRegistry = getAliasRegistry(aliasTarget);
    boolean isPublicAlias = ((SqlLiteral) node.getIsPublic()).booleanValue();
    if (isPublicAlias) {
        deletePublicAliases(node.getUser(), aliasRegistry);
    } else {
        deleteUserAliases(node.getUser(), aliasRegistry);
    }
    return DirectPlan.createDirectPlan(context, true, String.format("%s aliases dropped successfully", StringUtils.capitalize(aliasTarget.toLowerCase(Locale.ROOT))));
}
Also used : AliasRegistry(org.apache.drill.exec.alias.AliasRegistry) SqlDropAllAliases(org.apache.drill.exec.planner.sql.parser.SqlDropAllAliases) SqlLiteral(org.apache.calcite.sql.SqlLiteral)

Aggregations

SqlLiteral (org.apache.calcite.sql.SqlLiteral)1 AliasRegistry (org.apache.drill.exec.alias.AliasRegistry)1 SqlDropAllAliases (org.apache.drill.exec.planner.sql.parser.SqlDropAllAliases)1