本文整理汇总了Java中org.apache.drill.common.types.TypeProtos类的典型用法代码示例。如果您正苦于以下问题:Java TypeProtos类的具体用法?Java TypeProtos怎么用?Java TypeProtos使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeProtos类属于org.apache.drill.common.types包,在下文中一共展示了TypeProtos类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCSVVerification_extra_column_fails
import org.apache.drill.common.types.TypeProtos; //导入依赖的package包/类
@Test
public void testCSVVerification_extra_column_fails() throws Exception {
try {
testBuilder()
.sqlQuery("select " + CSV_COLS + ", columns[3] as address from cp.`testframework/small_test_data_extra_col.tsv`")
.ordered()
.csvBaselineFile("testframework/small_test_data.tsv")
.baselineTypes(TypeProtos.MinorType.BIGINT, TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.VARCHAR)
.baselineColumns("employee_id", "first_name", "last_name")
.build().run();
} catch (AssertionError ex) {
assertEquals("Unexpected extra column `address` returned by query.", ex.getMessage());
// this indicates successful completion of the test
return;
}
throw new Exception("Test framework verification failed, expected failure on extra column.");
}
示例2: materialize
import org.apache.drill.common.types.TypeProtos; //导入依赖的package包/类
@Override
boolean materialize(final NamedExpression ne, final VectorContainer batch, final FunctionLookupContext registry)
throws SchemaChangeException {
final FunctionCall call = (FunctionCall) ne.getExpr();
final LogicalExpression input = ExpressionTreeMaterializer.materializeAndCheckErrors(call.args.get(0), batch, registry);
if (input == null) {
return false;
}
// make sure output vector type is Nullable, because we will write a null value in the first row of each partition
TypeProtos.MajorType majorType = input.getMajorType();
if (majorType.getMode() == TypeProtos.DataMode.REQUIRED) {
majorType = Types.optional(majorType.getMinorType());
}
// add corresponding ValueVector to container
final MaterializedField output = MaterializedField.create(ne.getRef(), majorType);
batch.addOrGet(output).allocateNew();
final TypedFieldId outputId = batch.getValueVectorId(ne.getRef());
writeInputToLead = new ValueVectorWriteExpression(outputId, input, true);
return true;
}
示例3: allowImplicitCast
import org.apache.drill.common.types.TypeProtos; //导入依赖的package包/类
/**
* Checks if implicit cast is allowed between the two input types of the join condition. Currently we allow
* implicit casts in join condition only between numeric types and varchar/varbinary types.
* @param input1
* @param input2
* @return true if implicit cast is allowed false otherwise
*/
private static boolean allowImplicitCast(TypeProtos.MinorType input1, TypeProtos.MinorType input2) {
// allow implicit cast if both the input types are numeric
if (TypeCastRules.isNumericType(input1) && TypeCastRules.isNumericType(input2)) {
return true;
}
// allow implicit cast if input types are date/ timestamp
if ((input1 == TypeProtos.MinorType.DATE || input1 == TypeProtos.MinorType.TIMESTAMP) &&
(input2 == TypeProtos.MinorType.DATE || input2 == TypeProtos.MinorType.TIMESTAMP)) {
return true;
}
// allow implicit cast if both the input types are varbinary/ varchar
if ((input1 == TypeProtos.MinorType.VARCHAR || input1 == TypeProtos.MinorType.VARBINARY) &&
(input2 == TypeProtos.MinorType.VARCHAR || input2 == TypeProtos.MinorType.VARBINARY)) {
return true;
}
return false;
}
示例4: OrderedPartitionRecordBatch
import org.apache.drill.common.types.TypeProtos; //导入依赖的package包/类
public OrderedPartitionRecordBatch(OrderedPartitionSender pop, RecordBatch incoming, FragmentContext context) throws OutOfMemoryException {
super(pop, context);
this.incoming = incoming;
this.partitions = pop.getDestinations().size();
this.sendingMajorFragmentWidth = pop.getSendingWidth();
this.recordsToSample = pop.getRecordsToSample();
this.samplingFactor = pop.getSamplingFactor();
this.completionFactor = pop.getCompletionFactor();
DistributedCache cache = null;
this.mmap = cache.getMultiMap(MULTI_CACHE_CONFIG);
this.tableMap = cache.getMap(SINGLE_CACHE_CONFIG);
Preconditions.checkNotNull(tableMap);
this.mapKey = String.format("%s_%d", context.getHandle().getQueryId(), context.getHandle().getMajorFragmentId());
this.minorFragmentSampleCount = cache.getCounter(mapKey);
SchemaPath outputPath = popConfig.getRef();
MaterializedField outputField = MaterializedField.create(outputPath, Types.required(TypeProtos.MinorType.INT));
this.partitionKeyVector = (IntVector) TypeHelper.getNewVector(outputField, oContext.getAllocator());
}
示例5: testProjectWithExpressionPushDownOverUnionDistinct
import org.apache.drill.common.types.TypeProtos; //导入依赖的package包/类
@Test
public void testProjectWithExpressionPushDownOverUnionDistinct() throws Exception {
String query = "select 2 * n_nationkey as col from \n" +
"(select n_nationkey, n_name, n_comment from cp.`tpch/nation.parquet` \n" +
"union select r_regionkey, r_name, r_comment from cp.`tpch/region.parquet`)";
// Validate the result
testBuilder()
.sqlQuery(query)
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/testProjectWithExpressionPushDownOverUnionDistinct.tsv")
.baselineTypes(TypeProtos.MinorType.INT)
.baselineColumns("col")
.build()
.run();
}
示例6: logFunctionResolutionError
import org.apache.drill.common.types.TypeProtos; //导入依赖的package包/类
private static void logFunctionResolutionError(ErrorCollector errorCollector, FunctionCall call) {
// add error to collector
StringBuilder sb = new StringBuilder();
sb.append("Missing function implementation: ");
sb.append("[");
sb.append(call.getName());
sb.append("(");
boolean first = true;
for(LogicalExpression e : call.args) {
TypeProtos.MajorType mt = e.getMajorType();
if (first) {
first = false;
} else {
sb.append(", ");
}
sb.append(mt.getMinorType().name());
sb.append("-");
sb.append(mt.getMode().name());
}
sb.append(")");
sb.append("]");
errorCollector.addGeneralError(call.getPosition(), sb.toString());
}
示例7: TestBuilder
import org.apache.drill.common.types.TypeProtos; //导入依赖的package包/类
public TestBuilder(BufferAllocator allocator, String query, UserBitShared.QueryType queryType, Boolean ordered,
boolean approximateEquality, Map<SchemaPath, TypeProtos.MajorType> baselineTypeMap,
String baselineOptionSettingQueries, String testOptionSettingQueries, boolean highPerformanceComparison,
int expectedNumBatches) {
this(allocator);
if (ordered == null) {
throw new RuntimeException("Ordering not set, when using a baseline file or query you must explicitly call the ordered() or unOrdered() method on the " + this.getClass().getSimpleName());
}
this.query = query;
this.queryType = queryType;
this.ordered = ordered;
this.approximateEquality = approximateEquality;
this.baselineTypeMap = baselineTypeMap;
this.baselineOptionSettingQueries = baselineOptionSettingQueries;
this.testOptionSettingQueries = testOptionSettingQueries;
this.highPerformanceComparison = highPerformanceComparison;
this.expectedNumBatches = expectedNumBatches;
}
示例8: getReturnType
import org.apache.drill.common.types.TypeProtos; //导入依赖的package包/类
@Override
public MajorType getReturnType(List<LogicalExpression> args) {
TypeProtos.DataMode mode = returnValue.type.getMode();
boolean nullInput = false;
int scale = 0;
int precision = 0;
for (LogicalExpression e : args) {
if (e.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) {
nullInput = true;
}
scale = Math.max(scale, e.getMajorType().getScale());
precision = Math.max(precision, e.getMajorType().getPrecision());
}
if (nullHandling == NullHandling.NULL_IF_NULL && nullInput) {
mode = TypeProtos.DataMode.OPTIONAL;
}
return (TypeProtos.MajorType.newBuilder().setMinorType(returnValue.type.getMinorType()).setScale(scale).setPrecision(precision).setMode(mode).build());
}
示例9: testGroupByUnionDistinct
import org.apache.drill.common.types.TypeProtos; //导入依赖的package包/类
@Test // DRILL-3296
public void testGroupByUnionDistinct() throws Exception {
String query = "select n_nationkey from \n" +
"(select n_nationkey from cp.`tpch/nation.parquet` \n" +
"union select n_nationkey from cp.`tpch/nation.parquet`) \n" +
"group by n_nationkey";
// Validate the plan
final String[] expectedPlan = {"HashAgg.*\n" +
".*UnionAll"};
final String[] excludedPlan = {"HashAgg.*\n.*HashAgg"};
PlanTestBase.testPlanMatchingPatterns(query, expectedPlan, excludedPlan);
// Validate the result
testBuilder()
.sqlQuery(query)
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/testGroupByUnionDistinct.tsv")
.baselineTypes(TypeProtos.MinorType.INT)
.baselineColumns("n_nationkey")
.build()
.run();
}
示例10: getReturnType
import org.apache.drill.common.types.TypeProtos; //导入依赖的package包/类
@Override
public MajorType getReturnType(List<LogicalExpression> args) {
int precision = 0;
TypeProtos.DataMode mode = returnValue.type.getMode();
if (nullHandling == NullHandling.NULL_IF_NULL) {
// if any one of the input types is nullable, then return nullable return type
for (LogicalExpression e : args) {
if (e.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL) {
mode = TypeProtos.DataMode.OPTIONAL;
}
precision = Math.max(precision, e.getMajorType().getPrecision());
}
}
return (TypeProtos.MajorType.newBuilder().setMinorType(returnValue.type.getMinorType()).setScale(0).setPrecision(precision).setMode(mode).build());
}
示例11: visitValueVectorReadExpression
import org.apache.drill.common.types.TypeProtos; //导入依赖的package包/类
protected ValueHolder visitValueVectorReadExpression(ValueVectorReadExpression e, Integer inIndex)
throws RuntimeException {
TypeProtos.MajorType type = e.getMajorType();
ValueVector vv;
ValueHolder holder;
try {
switch (type.getMode()) {
case OPTIONAL:
case REQUIRED:
vv = incoming.getValueAccessorById(TypeHelper.getValueVectorClass(type.getMinorType(),type.getMode()), e.getFieldId().getFieldIds()).getValueVector();
holder = TypeHelper.getValue(vv, inIndex.intValue());
return holder;
default:
throw new UnsupportedOperationException("Type of " + type + " is not supported yet in interpreted expression evaluation!");
}
} catch (Exception ex){
throw new DrillRuntimeException("Error when evaluate a ValueVectorReadExpression: " + ex);
}
}
示例12: visitBooleanOr
import org.apache.drill.common.types.TypeProtos; //导入依赖的package包/类
private ValueHolder visitBooleanOr(BooleanOperator op, Integer inIndex) {
ValueHolder [] args = new ValueHolder [op.args.size()];
boolean hasNull = false;
for (int i = 0; i < op.args.size(); i++) {
args[i] = op.args.get(i).accept(this, inIndex);
Trivalent flag = isBitOn(args[i]);
switch (flag) {
case TRUE:
return op.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL? TypeHelper.nullify(ValueHolderHelper.getBitHolder(1)) : ValueHolderHelper.getBitHolder(1);
case NULL:
hasNull = true;
case FALSE:
}
}
if (hasNull) {
return ValueHolderHelper.getNullableBitHolder(true, 0);
} else {
return op.getMajorType().getMode() == TypeProtos.DataMode.OPTIONAL? TypeHelper.nullify(ValueHolderHelper.getBitHolder(0)) : ValueHolderHelper.getBitHolder(0);
}
}
示例13: testUnionAll9
import org.apache.drill.common.types.TypeProtos; //导入依赖的package包/类
@Test // DRILL-1905: Union-all of * column from JSON files in different directories
public void testUnionAll9() throws Exception {
String file0 = FileUtils.getResourceAsFile("/multilevel/json/1994/Q1/orders_94_q1.json").toURI().toString();
String file1 = FileUtils.getResourceAsFile("/multilevel/json/1995/Q1/orders_95_q1.json").toURI().toString();
String query = String.format("select o_custkey, o_orderstatus, o_totalprice, o_orderdate, o_orderpriority, o_clerk, o_shippriority, o_comment, o_orderkey from dfs_test.`%s` union all " +
"select o_custkey, o_orderstatus, o_totalprice, o_orderdate, o_orderpriority, o_clerk, o_shippriority, o_comment, o_orderkey from dfs_test.`%s`", file0, file1);
testBuilder()
.sqlQuery(query)
.unOrdered()
.csvBaselineFile("testframework/testUnionAllQueries/q9.tsv")
.baselineTypes(TypeProtos.MinorType.BIGINT, TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.FLOAT8, TypeProtos.MinorType.VARCHAR,
TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.BIGINT,TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.BIGINT)
.baselineColumns("o_custkey", "o_orderstatus", "o_totalprice", "o_orderdate",
"o_orderpriority", "o_clerk", "o_shippriority", "o_comment", "o_orderkey")
.build().run();
}
示例14: testDiffDataTypesAndModes
import org.apache.drill.common.types.TypeProtos; //导入依赖的package包/类
@Test
public void testDiffDataTypesAndModes() throws Exception {
test("use dfs_test.tmp");
test("create view nation_view_testunionall as select n_name, n_nationkey from cp.`tpch/nation.parquet`;");
test("create view region_view_testunionall as select r_name, r_regionkey from cp.`tpch/region.parquet`;");
String t1 = "(select n_comment, n_regionkey from cp.`tpch/nation.parquet` limit 5)";
String t2 = "(select * from nation_view_testunionall limit 5)";
String t3 = "(select full_name, store_id from cp.`employee.json` limit 5)";
String t4 = "(select * from region_view_testunionall limit 5)";
String query1 = t1 + " union all " + t2 + " union all " + t3 + " union all " + t4;
try {
testBuilder()
.sqlQuery(query1)
.unOrdered()
.csvBaselineFile("testframework/testUnionAllQueries/q13.tsv")
.baselineTypes(TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.BIGINT)
.baselineColumns("n_comment", "n_regionkey")
.build().run();
} finally {
test("drop view nation_view_testunionall");
test("drop view region_view_testunionall");
}
}
示例15: testUnionDistinct9
import org.apache.drill.common.types.TypeProtos; //导入依赖的package包/类
@Test // Union-Distinct of * column from JSON files in different directories
public void testUnionDistinct9() throws Exception {
String file0 = FileUtils.getResourceAsFile("/multilevel/json/1994/Q1/orders_94_q1.json").toURI().toString();
String file1 = FileUtils.getResourceAsFile("/multilevel/json/1995/Q1/orders_95_q1.json").toURI().toString();
String query = String.format("select o_custkey, o_orderstatus, o_totalprice, o_orderdate, o_orderpriority, o_clerk, o_shippriority, o_comment, o_orderkey from dfs_test.`%s` union \n" +
"select o_custkey, o_orderstatus, o_totalprice, o_orderdate, o_orderpriority, o_clerk, o_shippriority, o_comment, o_orderkey from dfs_test.`%s`", file0, file1);
testBuilder()
.sqlQuery(query)
.unOrdered()
.csvBaselineFile("testframework/unionDistinct/q9.tsv")
.baselineTypes(TypeProtos.MinorType.BIGINT, TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.FLOAT8, TypeProtos.MinorType.VARCHAR,
TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.BIGINT,TypeProtos.MinorType.VARCHAR, TypeProtos.MinorType.BIGINT)
.baselineColumns("o_custkey", "o_orderstatus", "o_totalprice", "o_orderdate",
"o_orderpriority", "o_clerk", "o_shippriority", "o_comment", "o_orderkey")
.build()
.run();
}