Search in sources :

Example 1 with InfoSchemaFilter

use of org.apache.drill.exec.store.ischema.InfoSchemaFilter in project drill by axbaretto.

the class MetadataProvider method createInfoSchemaFilter.

/**
 * Helper method to create a {@link InfoSchemaFilter} that combines the given filters with an AND.
 * @param catalogNameFilter Optional filter on <code>catalog name</code>
 * @param schemaNameFilter Optional filter on <code>schema name</code>
 * @param tableNameFilter Optional filter on <code>table name</code>
 * @param tableTypeFilter Optional filter on <code>table type</code>
 * @param columnNameFilter Optional filter on <code>column name</code>
 * @return
 */
private static InfoSchemaFilter createInfoSchemaFilter(final LikeFilter catalogNameFilter, final LikeFilter schemaNameFilter, final LikeFilter tableNameFilter, List<String> tableTypeFilter, final LikeFilter columnNameFilter) {
    FunctionExprNode exprNode = createLikeFunctionExprNode(CATS_COL_CATALOG_NAME, catalogNameFilter);
    exprNode = combineFunctions(AND_FUNCTION, exprNode, combineFunctions(OR_FUNCTION, createLikeFunctionExprNode(SHRD_COL_TABLE_SCHEMA, schemaNameFilter), createLikeFunctionExprNode(SCHS_COL_SCHEMA_NAME, schemaNameFilter)));
    exprNode = combineFunctions(AND_FUNCTION, exprNode, createLikeFunctionExprNode(SHRD_COL_TABLE_NAME, tableNameFilter));
    exprNode = combineFunctions(AND_FUNCTION, exprNode, createInFunctionExprNode(TBLS_COL_TABLE_TYPE, tableTypeFilter));
    exprNode = combineFunctions(AND_FUNCTION, exprNode, createLikeFunctionExprNode(COLS_COL_COLUMN_NAME, columnNameFilter));
    return exprNode != null ? new InfoSchemaFilter(exprNode) : null;
}
Also used : InfoSchemaFilter(org.apache.drill.exec.store.ischema.InfoSchemaFilter) FunctionExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.FunctionExprNode)

Example 2 with InfoSchemaFilter

use of org.apache.drill.exec.store.ischema.InfoSchemaFilter in project drill by apache.

the class MetadataProvider method createInfoSchemaFilter.

/**
 * Helper method to create a {@link InfoSchemaFilter} that combines the given filters with an AND.
 *
 * @param catalogNameFilter Optional filter on <code>catalog name</code>
 * @param schemaNameFilter Optional filter on <code>schema name</code>
 * @param tableNameFilter Optional filter on <code>table name</code>
 * @param tableTypeFilter Optional filter on <code>table type</code>
 * @param columnNameFilter Optional filter on <code>column name</code>
 * @return information schema filter
 */
private static InfoSchemaFilter createInfoSchemaFilter(LikeFilter catalogNameFilter, LikeFilter schemaNameFilter, LikeFilter tableNameFilter, List<String> tableTypeFilter, LikeFilter columnNameFilter) {
    FunctionExprNode exprNode = createLikeFunctionExprNode(CATS_COL_CATALOG_NAME, catalogNameFilter);
    // convert like filter condition elements to lower case
    if (schemaNameFilter != null) {
        LikeFilter.Builder builder = LikeFilter.newBuilder();
        if (schemaNameFilter.hasPattern()) {
            builder.setPattern(schemaNameFilter.getPattern().toLowerCase());
        }
        if (schemaNameFilter.hasEscape()) {
            builder.setEscape(schemaNameFilter.getEscape().toLowerCase());
        }
        schemaNameFilter = builder.build();
    }
    exprNode = combineFunctions(AND_FUNCTION, exprNode, combineFunctions(OR_FUNCTION, createLikeFunctionExprNode(SHRD_COL_TABLE_SCHEMA, schemaNameFilter), createLikeFunctionExprNode(SCHS_COL_SCHEMA_NAME, schemaNameFilter)));
    exprNode = combineFunctions(AND_FUNCTION, exprNode, createLikeFunctionExprNode(SHRD_COL_TABLE_NAME, tableNameFilter));
    exprNode = combineFunctions(AND_FUNCTION, exprNode, createInFunctionExprNode(TBLS_COL_TABLE_TYPE, tableTypeFilter));
    exprNode = combineFunctions(AND_FUNCTION, exprNode, createLikeFunctionExprNode(COLS_COL_COLUMN_NAME, columnNameFilter));
    return exprNode != null ? new InfoSchemaFilter(exprNode) : null;
}
Also used : LikeFilter(org.apache.drill.exec.proto.UserProtos.LikeFilter) InfoSchemaFilter(org.apache.drill.exec.store.ischema.InfoSchemaFilter) FunctionExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.FunctionExprNode)

Aggregations

InfoSchemaFilter (org.apache.drill.exec.store.ischema.InfoSchemaFilter)2 FunctionExprNode (org.apache.drill.exec.store.ischema.InfoSchemaFilter.FunctionExprNode)2 LikeFilter (org.apache.drill.exec.proto.UserProtos.LikeFilter)1