Search in sources :

Example 1 with FieldExprNode

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

the class InfoSchemaFilterBuilder method visitCastExpression.

@Override
public ExprNode visitCastExpression(CastExpression e, Void value) throws RuntimeException {
    if (e.getInput() instanceof FieldReference) {
        FieldReference fieldRef = (FieldReference) e.getInput();
        String field = fieldRef.getRootSegmentPath().toUpperCase();
        if (field.equals(CATS_COL_CATALOG_NAME) || field.equals(SCHS_COL_SCHEMA_NAME) || field.equals(SHRD_COL_TABLE_NAME) || field.equals(SHRD_COL_TABLE_SCHEMA) || field.equals(COLS_COL_COLUMN_NAME)) {
            return new FieldExprNode(field);
        }
    }
    return visitUnknown(e, value);
}
Also used : FieldReference(org.apache.drill.common.expression.FieldReference) FieldExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.FieldExprNode) QuotedString(org.apache.drill.common.expression.ValueExpressions.QuotedString)

Example 2 with FieldExprNode

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

the class MetadataProvider method createInFunctionExprNode.

/**
 * Helper method to create {@link FunctionExprNode} from {@code List<String>}.
 * @param fieldName Name of the filed on which the like expression is applied.
 * @param valuesFilter a list of values
 * @return {@link FunctionExprNode} for given arguments. Null if the <code>valuesFilter</code> is null.
 */
private static FunctionExprNode createInFunctionExprNode(String fieldName, List<String> valuesFilter) {
    if (valuesFilter == null) {
        return null;
    }
    ImmutableList.Builder<ExprNode> nodes = ImmutableList.builder();
    nodes.add(new FieldExprNode(fieldName));
    for (String type : valuesFilter) {
        nodes.add(new ConstantExprNode(type));
    }
    return new FunctionExprNode(IN_FUNCTION, nodes.build());
}
Also used : ExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.ExprNode) FunctionExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.FunctionExprNode) FieldExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.FieldExprNode) ConstantExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.ConstantExprNode) ImmutableList(com.google.common.collect.ImmutableList) FieldExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.FieldExprNode) FunctionExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.FunctionExprNode) ConstantExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.ConstantExprNode)

Example 3 with FieldExprNode

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

the class MetadataProvider method createInFunctionExprNode.

/**
 * Helper method to create {@link FunctionExprNode} from {@code List<String>}.
 * @param fieldName Name of the filed on which the like expression is applied.
 * @param valuesFilter a list of values
 * @return {@link FunctionExprNode} for given arguments. Null if the <code>valuesFilter</code> is null.
 */
private static FunctionExprNode createInFunctionExprNode(String fieldName, List<String> valuesFilter) {
    if (valuesFilter == null) {
        return null;
    }
    ImmutableList.Builder<ExprNode> nodes = ImmutableList.builder();
    nodes.add(new FieldExprNode(fieldName));
    for (String type : valuesFilter) {
        nodes.add(new ConstantExprNode(type));
    }
    return new FunctionExprNode(IN_FUNCTION, nodes.build());
}
Also used : ExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.ExprNode) FunctionExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.FunctionExprNode) FieldExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.FieldExprNode) ConstantExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.ConstantExprNode) ImmutableList(org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList) FieldExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.FieldExprNode) FunctionExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.FunctionExprNode) ConstantExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.ConstantExprNode)

Example 4 with FieldExprNode

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

the class InfoSchemaFilterBuilder method visitCastExpression.

@Override
public ExprNode visitCastExpression(CastExpression e, Void value) throws RuntimeException {
    if (e.getInput() instanceof FieldReference) {
        FieldReference fieldRef = (FieldReference) e.getInput();
        String field = fieldRef.getRootSegmentPath().toUpperCase();
        if (field.equals(CATS_COL_CATALOG_NAME) || field.equals(SCHS_COL_SCHEMA_NAME) || field.equals(SHRD_COL_TABLE_NAME) || field.equals(SHRD_COL_TABLE_SCHEMA) || field.equals(COLS_COL_COLUMN_NAME) || field.equals(FILES_COL_ROOT_SCHEMA_NAME) || field.equals(FILES_COL_WORKSPACE_NAME)) {
            return new FieldExprNode(field);
        }
    }
    return visitUnknown(e, value);
}
Also used : FieldReference(org.apache.drill.common.expression.FieldReference) FieldExprNode(org.apache.drill.exec.store.ischema.InfoSchemaFilter.FieldExprNode) QuotedString(org.apache.drill.common.expression.ValueExpressions.QuotedString)

Aggregations

FieldExprNode (org.apache.drill.exec.store.ischema.InfoSchemaFilter.FieldExprNode)4 FieldReference (org.apache.drill.common.expression.FieldReference)2 QuotedString (org.apache.drill.common.expression.ValueExpressions.QuotedString)2 ConstantExprNode (org.apache.drill.exec.store.ischema.InfoSchemaFilter.ConstantExprNode)2 ExprNode (org.apache.drill.exec.store.ischema.InfoSchemaFilter.ExprNode)2 FunctionExprNode (org.apache.drill.exec.store.ischema.InfoSchemaFilter.FunctionExprNode)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList (org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList)1