Java Code Examples for org.apache.pig.data.DataType#BYTEARRAY

The following examples show how to use org.apache.pig.data.DataType#BYTEARRAY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchemaTupleClassGenerator.java    From spork with Apache License 2.0 6 votes vote down vote up
@Override
public void process(int fieldPos, Schema.FieldSchema fs) {
    add("public "+typeName()+" getDummy_"+fieldPos+"() {");
    switch (fs.type) {
    case (DataType.INTEGER): add("    return 0;"); break;
    case (DataType.LONG): add("    return 0L;"); break;
    case (DataType.FLOAT): add("    return 0.0f;"); break;
    case (DataType.DOUBLE): add("    return 0.0;"); break;
    case (DataType.BOOLEAN): add("    return true;"); break;
    case (DataType.DATETIME): add("    return new DateTime();"); break;
    case (DataType.BIGDECIMAL): add("    return (BigDecimal)null;"); break;
    case (DataType.BIGINTEGER): add("    return (BigInteger)null;"); break;
    case (DataType.BYTEARRAY): add("    return (byte[])null;"); break;
    case (DataType.CHARARRAY): add("    return (String)null;"); break;
    case (DataType.TUPLE): add("    return (Tuple)null;"); break;
    case (DataType.BAG): add("    return (DataBag)null;"); break;
    case (DataType.MAP): add("    return (Map<String,Object>)null;"); break;
    default: throw new RuntimeException("Unsupported type");
    }
    add("}");
    addBreak();
}
 
Example 2
Source File: POPartialAgg.java    From spork with Apache License 2.0 6 votes vote down vote up
private Result getResult(ExpressionOperator op) throws ExecException {
    Result res;
    switch (op.getResultType()) {
    case DataType.BAG:
    case DataType.BOOLEAN:
    case DataType.BYTEARRAY:
    case DataType.CHARARRAY:
    case DataType.DOUBLE:
    case DataType.FLOAT:
    case DataType.INTEGER:
    case DataType.LONG:
    case DataType.BIGINTEGER:
    case DataType.BIGDECIMAL:
    case DataType.DATETIME:
    case DataType.MAP:
    case DataType.TUPLE:
        res = op.getNext(op.getResultType());
        break;
    default:
        String msg = "Invalid result type: "
                + DataType.findType(op.getResultType());
        throw new ExecException(msg, 2270, PigException.BUG);
    }

    return res;
}
 
Example 3
Source File: TypeCheckingExpVisitor.java    From spork with Apache License 2.0 6 votes vote down vote up
@Override
public void visit(DereferenceExpression deref) throws FrontendException{
    byte inputType = deref.getReferredExpression().getType();
    switch(inputType){
    case DataType.TUPLE:
    case DataType.BAG:
    case DataType.BYTEARRAY: // ideally determine type at runtime
        //allowed types
        break;
    default:
        int errCode = 1129;
        String msg = "Referring to column(s) within a column of type " +
        DataType.findTypeName(inputType)
        + " is not allowed";
        throw new TypeCheckerException(deref, msg, errCode, PigException.INPUT);
    }
}
 
Example 4
Source File: TypeCheckingExpVisitor.java    From spork with Apache License 2.0 6 votes vote down vote up
@Override
public void visit(NegativeExpression negExp) throws FrontendException {
    byte type = negExp.getExpression().getType() ;
    if (DataType.isNumberType(type)) {
        //do nothing
    }
    else if (type == DataType.BYTEARRAY) {
        // cast bytearray to double
        insertCast(negExp, DataType.DOUBLE, negExp.getExpression());
    }
    else {
        int errCode = 1041;
        String msg = "NEG can be used with numbers or Bytearray only" ;
        msgCollector.collect(msg, MessageType.Error);
        throw new TypeCheckerException(negExp, msg, errCode, PigException.INPUT) ;
    }

}
 
Example 5
Source File: CastLineageSetter.java    From spork with Apache License 2.0 6 votes vote down vote up
/**
 * @param fs
 * @return true if fs is of complex type and contains a bytearray 
 *  or empty inner schema
 * @throws FrontendException
 */
private boolean containsByteArrayOrEmtpyInSchema(LogicalFieldSchema fs)
throws FrontendException {
    
    if(fs.type == DataType.BYTEARRAY)
        return true;
    
    if(DataType.isAtomic(fs.type))
        return false;
    
    if(fs.schema == null || fs.schema.size() == 0)
        return true;
    
    for(LogicalFieldSchema inFs : fs.schema.getFields()){
        if(containsByteArrayOrEmtpyInSchema(inFs))
            return true;
    }

    return false;
}
 
Example 6
Source File: SchemaUtil.java    From iceberg with Apache License 2.0 6 votes vote down vote up
private static byte convertType(Type type) throws IOException {
  switch (type.typeId()) {
    case BOOLEAN:   return DataType.BOOLEAN;
    case INTEGER:   return DataType.INTEGER;
    case LONG:      return DataType.LONG;
    case FLOAT:     return DataType.FLOAT;
    case DOUBLE:    return DataType.DOUBLE;
    case TIMESTAMP: return DataType.CHARARRAY;
    case DATE:      return DataType.CHARARRAY;
    case STRING:    return DataType.CHARARRAY;
    case FIXED:     return DataType.BYTEARRAY;
    case BINARY:    return DataType.BYTEARRAY;
    case DECIMAL:   return DataType.BIGDECIMAL;
    case STRUCT:    return DataType.TUPLE;
    case LIST:      return DataType.BAG;
    case MAP:       return DataType.MAP;
    default:
      throw new FrontendException("Unsupported primitive type:" + type);
  }
}
 
Example 7
Source File: JsFunction.java    From spork with Apache License 2.0 6 votes vote down vote up
public JsFunction(String functionName) {
    this.jsScriptEngine = JsScriptEngine.getInstance();
    this.functionName = functionName;
    Object outputSchemaObj = jsScriptEngine.jsEval(this.getClass().getName() + "(String)",
            functionName + ".outputSchema");
    //if no schema defined, fall back to bytearray
    if (outputSchemaObj == null || outputSchemaObj instanceof Undefined) {
        this.outputSchema = new Schema(new Schema.FieldSchema(null, DataType.BYTEARRAY));
    }
    else {
        try {
            this.outputSchema = Utils.getSchemaFromString(outputSchemaObj.toString());
        }
        catch (ParserException e) {
            throw new IllegalArgumentException(functionName
                    + ".outputSchema is not a valid schema: " + e.getMessage(), e);
        }
    }

}
 
Example 8
Source File: DBStorage.java    From spork with Apache License 2.0 6 votes vote down vote up
protected int sqlDataTypeFromPigDataType(byte pigDataType) {
    switch(pigDataType) {
    case DataType.INTEGER:
        return java.sql.Types.INTEGER;
    case DataType.LONG:
        return java.sql.Types.BIGINT;
    case DataType.FLOAT:
        return java.sql.Types.FLOAT;
    case DataType.DOUBLE:
        return java.sql.Types.DOUBLE;
    case DataType.BOOLEAN:
        return java.sql.Types.BOOLEAN;
    case DataType.DATETIME:
        return java.sql.Types.DATE;
    case DataType.BYTEARRAY:
    case DataType.CHARARRAY:
    case DataType.BYTE:
        return java.sql.Types.VARCHAR;
    default:
        log.warn("Can not find SQL data type for " + pigDataType + " returning VARCHAR");
        return java.sql.Types.VARCHAR;
    }
}
 
Example 9
Source File: EqualToExpr.java    From spork with Apache License 2.0 5 votes vote down vote up
@Override
public Result getNextBoolean() throws ExecException {
  try {
    Result left, right;

    switch (operandType) {
    case DataType.BYTEARRAY:
    case DataType.DOUBLE:
    case DataType.FLOAT:
    case DataType.BOOLEAN:
    case DataType.INTEGER:
    case DataType.BIGINTEGER:
    case DataType.BIGDECIMAL:
    case DataType.LONG:
    case DataType.DATETIME:
    case DataType.CHARARRAY:
    case DataType.TUPLE:
    case DataType.MAP: {
        Result r = accumChild(null, operandType);
        if (r != null) {
            return r;
        }
        left = lhs.getNext(operandType);
        right = rhs.getNext(operandType);
        return doComparison(left, right);
    }

    default: {
        int errCode = 2067;
        String msg = this.getClass().getSimpleName() + " does not know how to " +
        "handle type: " + DataType.findTypeName(operandType);
        throw new ExecException(msg, errCode, PigException.BUG);
    }

    }
  } catch (RuntimeException e) {
      throw new ExecException("exception while executing " + this.toString() + ": " + e.toString(), 2067, PigException.BUG, e);
  }
}
 
Example 10
Source File: TypeCastInserter.java    From spork with Apache License 2.0 5 votes vote down vote up
private boolean atLeastOneCastNeeded(LogicalSchema determinedSchema, LogicalSchema s) {
    for (int i = 0; i < s.size(); i++) {
        LogicalSchema.LogicalFieldSchema fs = s.getField(i);
        if (fs.type != DataType.BYTEARRAY && (determinedSchema == null || (!fs.isEqual(determinedSchema.getField(i))))) {
            // we have to cast this field from the default BYTEARRAY type to
            // whatever the user specified in the 'AS' clause of the LOAD
            // statement (the fs.type).
            return true;
        }
    }
    return false;
}
 
Example 11
Source File: POIsNull.java    From spork with Apache License 2.0 5 votes vote down vote up
@Override
public Result getNextBoolean() throws ExecException {

    Result res = null;
    switch(operandType) {
    case DataType.BYTEARRAY:
    case DataType.DOUBLE:
    case DataType.INTEGER:
    case DataType.BIGINTEGER:
    case DataType.BIGDECIMAL:
    case DataType.CHARARRAY:
    case DataType.BOOLEAN:
    case DataType.LONG:
    case DataType.FLOAT:
    case DataType.DATETIME:
    case DataType.MAP:
    case DataType.TUPLE:
    case DataType.BAG:
        res = expr.getNext(operandType);
        if(res.returnStatus == POStatus.STATUS_OK) {
            if (res.result == null) {
                res.result = true;
            } else {
                res.result = false;
            }
            illustratorMarkup(null, res.result, (Boolean) res.result ? 0 : 1);
        }
        return res;
    default: {
        int errCode = 2067;
        String msg = this.getClass().getSimpleName() + " does not know how to " +
        "handle type: " + DataType.findTypeName(operandType);
        throw new ExecException(msg, errCode, PigException.BUG);
    }

    }
}
 
Example 12
Source File: ProjectExpression.java    From spork with Apache License 2.0 5 votes vote down vote up
@Override
public byte getType() throws FrontendException {
    // for boundary project, if
    if (getFieldSchema()==null) {
        if (attachedRelationalOp instanceof LOGenerate && findReferent() instanceof
                LOInnerLoad) {
            if (((LOInnerLoad)findReferent()).getProjection().isRangeOrStarProject())
                return DataType.TUPLE;
        }
        return DataType.BYTEARRAY;
    }
    return super.getType();
}
 
Example 13
Source File: TestSchema.java    From spork with Apache License 2.0 4 votes vote down vote up
@Test
public void testSchemaEqual1() {

    List<FieldSchema> innerList1 = new ArrayList<FieldSchema>();
    innerList1.add(new FieldSchema("11a", DataType.INTEGER));
    innerList1.add(new FieldSchema("11b", DataType.LONG));

    List<FieldSchema> innerList2 = new ArrayList<FieldSchema>();
    innerList2.add(new FieldSchema("11a", DataType.INTEGER));
    innerList2.add(new FieldSchema("11b", DataType.LONG));

    Schema innerSchema1 = new Schema(innerList1);
    Schema innerSchema2 = new Schema(innerList2);

    List<FieldSchema> list1 = new ArrayList<FieldSchema>();
    list1.add(new FieldSchema("1a", DataType.BYTEARRAY));
    list1.add(new FieldSchema("1b", innerSchema1));
    list1.add(new FieldSchema("1c", DataType.INTEGER));

    List<FieldSchema> list2 = new ArrayList<FieldSchema>();
    list2.add(new FieldSchema("1a", DataType.BYTEARRAY));
    list2.add(new FieldSchema("1b", innerSchema2));
    list2.add(new FieldSchema("1c", DataType.INTEGER));

    Schema schema1 = new Schema(list1);
    Schema schema2 = new Schema(list2);

    assertTrue(Schema.equals(schema1, schema2, false, false));

    innerList2.get(1).alias = "pi";

    assertFalse(Schema.equals(schema1, schema2, false, false));
    assertTrue(Schema.equals(schema1, schema2, false, true));

    innerList2.get(1).alias = "11b";
    innerList2.get(1).type = DataType.BYTEARRAY;

    assertFalse(Schema.equals(schema1, schema2, false, false));
    assertTrue(Schema.equals(schema1, schema2, true, false));

    innerList2.get(1).type = DataType.LONG;

    assertTrue(Schema.equals(schema1, schema2, false, false));

    list2.get(0).type = DataType.CHARARRAY;
    assertFalse(Schema.equals(schema1, schema2, false, false));
}
 
Example 14
Source File: TestTypeCheckingValidatorNewLP.java    From spork with Apache License 2.0 4 votes vote down vote up
@Test
public void testExpressionTypeChecking8() throws Throwable {
    LogicalExpressionPlan plan = new LogicalExpressionPlan();

    TupleFactory tupleFactory = TupleFactory.getInstance();

    ArrayList<Object> innerObjList = new ArrayList<Object>();
    ArrayList<Object> objList = new ArrayList<Object>();

    innerObjList.add(10);
    innerObjList.add(3);
    innerObjList.add(7);
    innerObjList.add(17);

    Tuple innerTuple = tupleFactory.newTuple(innerObjList);

    objList.add("World");
    objList.add(42);
    objList.add(innerTuple);

    Tuple tuple = tupleFactory.newTuple(objList);

    ArrayList<Schema.FieldSchema> innerFss = new ArrayList<Schema.FieldSchema>();
    ArrayList<Schema.FieldSchema> fss = new ArrayList<Schema.FieldSchema>();
    ArrayList<Schema.FieldSchema> castFss = new ArrayList<Schema.FieldSchema>();

    Schema.FieldSchema stringFs = new Schema.FieldSchema(null, DataType.CHARARRAY);
    Schema.FieldSchema intFs = new Schema.FieldSchema(null, DataType.INTEGER);

    for(int i = 0; i < innerObjList.size(); ++i) {
        innerFss.add(intFs);
    }

    Schema innerTupleSchema = new Schema(innerFss);

    fss.add(stringFs);
    fss.add(intFs);
    fss.add(new Schema.FieldSchema(null, innerTupleSchema, DataType.TUPLE));

    Schema tupleSchema = new Schema(fss);

    Schema.FieldSchema byteArrayFs = new Schema.FieldSchema(null, DataType.BYTEARRAY);
    for(int i = 0; i < 4; ++i) {
        castFss.add(byteArrayFs);
    }

    Schema castSchema = new Schema(castFss);


    ConstantExpression constant1 = new ConstantExpression(plan, innerTuple);
    ConstantExpression constant2 =  new ConstantExpression(plan, tuple);
    CastExpression cast1 = new CastExpression(plan, constant1,
            org.apache.pig.newplan.logical.Util.translateFieldSchema(new FieldSchema(null, castSchema, DataType.TUPLE)));

    EqualExpression equal1 = new EqualExpression(plan, cast1, constant2);

    CompilationMessageCollector collector = new CompilationMessageCollector();

    LogicalRelationalOperator dummyRelOp = createDummyRelOpWithAlias();
    TypeCheckingExpVisitor expTypeChecker = new TypeCheckingExpVisitor(plan, collector, dummyRelOp);
    expTypeChecker.visit();
    printMessageCollector(collector);
    //printTypeGraph(plan);

    if (collector.hasError()) {
        throw new Exception("Error during type checking");
    }

    assertEquals(DataType.BOOLEAN, equal1.getType());
    assertEquals(DataType.TUPLE, equal1.getRhs().getType());
    assertEquals(DataType.TUPLE, equal1.getLhs().getType());
}
 
Example 15
Source File: TypeCheckingExpVisitor.java    From spork with Apache License 2.0 4 votes vote down vote up
/***************************************************************************
 * Compare two schemas for equality for argument matching purposes. This is
 * a more relaxed form of Schema.equals wherein first the Datatypes of the
 * field schema are checked for equality. Then if a field schema in the udf
 * schema is for a complex type AND if the inner schema is NOT null, check
 * for schema equality of the inner schemas of the UDF field schema and
 * input field schema
 *
 * @param inputSchema
 * @param udfSchema
 * @param ignoreByteArrays
 * @return true if FieldSchemas are equal for argument matching, false
 *         otherwise
 * @throws FrontendException
 */
public static boolean schemaEqualsForMatching(Schema inputSchema,
        Schema udfSchema, SchemaType udfSchemaType, boolean ignoreByteArrays) throws FrontendException {


    // If both of them are null, they are equal
    if ((inputSchema == null) && (udfSchema == null)) {
        return true;
    }

    // otherwise
    if (inputSchema == null) {
        return false;
    }

    if (udfSchema == null) {
        return false;
    }

    // the old udf schemas might not have tuple inside bag
    // fix that!
    udfSchema = Util.fixSchemaAddTupleInBag(udfSchema);

    if ((udfSchemaType == SchemaType.NORMAL) && (inputSchema.size() != udfSchema.size()))
        return false;
    if ((udfSchemaType == SchemaType.VARARG) && inputSchema.size() < udfSchema.size())
        return false;

    Iterator<FieldSchema> i = inputSchema.getFields().iterator();
    Iterator<FieldSchema> j = udfSchema.getFields().iterator();

    FieldSchema udfFieldSchema = null;
    while (i.hasNext()) {

        FieldSchema inputFieldSchema = i.next();
        if(inputFieldSchema == null)
            return false;

        //if there's no more UDF field: take the last one which is the vararg field
        udfFieldSchema = j.hasNext() ? j.next() : udfFieldSchema;
        
        if(ignoreByteArrays && inputFieldSchema.type == DataType.BYTEARRAY) {
            continue;
        }
        
        if (inputFieldSchema.type != udfFieldSchema.type) {
            return false;
        }

        // if a field schema in the udf schema is for a complex
        // type AND if the inner schema is NOT null, check for schema
        // equality of the inner schemas of the UDF field schema and
        // input field schema. If the field schema in the udf schema is
        // for a complex type AND if the inner schema IS null it means
        // the udf is applicable for all input which has the same type
        // for that field (irrespective of inner schema)
        // if it is a bag with empty tuple, then just rely on the field type
        if (DataType.isSchemaType(udfFieldSchema.type)
                && udfFieldSchema.schema != null
                && isNotBagWithEmptyTuple(udfFieldSchema)
        ) {
            // Compare recursively using field schema
            if (!FieldSchema.equals(inputFieldSchema, udfFieldSchema,
                    false, true)) {
                //try modifying any empty tuple to type of bytearray
                // and see if that matches. Need to do this for
                // backward compatibility -
                // User might have specified tuple with a bytearray
                // and this should also match an empty tuple

                FieldSchema inputFSWithBytearrayinTuple =
                    new FieldSchema(inputFieldSchema);

                convertEmptyTupleToBytearrayTuple(inputFSWithBytearrayinTuple);

                if (!FieldSchema.equals(inputFSWithBytearrayinTuple, udfFieldSchema,
                        false, true)) {
                    return false;
                }
            }
        }

    }
    return true;
}
 
Example 16
Source File: LOLoad.java    From spork with Apache License 2.0 4 votes vote down vote up
/**
 * Get the schema for this load.  The schema will be either be what was
 * given by the user in the script or what the load functions getSchema
 * call returned.  Otherwise null will be returned, indicating that the
 * schema is unknown.
 * @return schema, or null if unknown
 */
@Override
public LogicalSchema getSchema() throws FrontendException {
    if (schema != null)
        return schema;
    
    LogicalSchema originalSchema = null;
    
    if (scriptSchema != null && determinedSchema != null) {
        originalSchema = LogicalSchema.merge(scriptSchema, determinedSchema, LogicalSchema.MergeMode.LoadForEach);
    } else if (scriptSchema != null)  originalSchema = scriptSchema;
    else if (determinedSchema != null) originalSchema = determinedSchema;
    
    if (isCastAdjusted()) {
        for (int i=0;i<originalSchema.size();i++) {
            LogicalSchema.LogicalFieldSchema fs = originalSchema.getField(i);
            if(determinedSchema == null) {
                // Reset the loads field schema to byte array so that it
                // will reflect reality.
                fs.type = DataType.BYTEARRAY;
            } else {
                // Reset the type to what determinedSchema says it is
                fs.type = determinedSchema.getField(i).type;
            }
        }
    }
    
    if (originalSchema!=null) {
        uidOnlySchema = originalSchema.mergeUid(uidOnlySchema);
    }
    
    if (requiredFields!=null) {
        schema = new LogicalSchema();
        for (int i=0;i<originalSchema.size();i++) {
            if (requiredFields.contains(i))
                schema.addField(originalSchema.getField(i));
        }
    } else
        schema = originalSchema;
    
    return schema;
}
 
Example 17
Source File: TypeCheckingExpVisitor.java    From spork with Apache License 2.0 4 votes vote down vote up
/**
 * Add casts to promote numeric type to larger of two input numeric types of
 * the {@link BinaryExpression}  binOp . If one of the inputs is numeric
 * and other bytearray, cast the bytearray type to other numeric type.
 * If both inputs are bytearray, cast them to double.
 * @param binOp
 * @throws FrontendException
 */
private void addCastsToNumericBinExpression(BinaryExpression binOp)
throws FrontendException {
    LogicalExpression lhs = binOp.getLhs() ;
    LogicalExpression rhs = binOp.getRhs() ;

    byte lhsType = lhs.getType() ;
    byte rhsType = rhs.getType() ;

    if ( DataType.isNumberType(lhsType) &&
            DataType.isNumberType(rhsType) ) {

        // return the bigger type
        byte biggerType = lhsType > rhsType ? lhsType:rhsType ;

        // Cast smaller type to the bigger type
        if (lhsType != biggerType) {
            insertCast(binOp, biggerType, binOp.getLhs());
        }
        else if (rhsType != biggerType) {
            insertCast(binOp, biggerType, binOp.getRhs());
        }
    }
    else if ( (lhsType == DataType.BYTEARRAY) &&
            (DataType.isNumberType(rhsType)) ) {
        insertCast(binOp, rhsType, binOp.getLhs());
    }
    else if ( (rhsType == DataType.BYTEARRAY) &&
            (DataType.isNumberType(lhsType)) ) {
        insertCast(binOp, lhsType, binOp.getRhs());
    }
    else if ( (lhsType == DataType.BYTEARRAY) &&
            (rhsType == DataType.BYTEARRAY) ) {
        // Cast both operands to double
        insertCast(binOp, DataType.DOUBLE, binOp.getLhs());
        insertCast(binOp, DataType.DOUBLE, binOp.getRhs());
    }
    else {
        int errCode = 1039;
        String msg = generateIncompatibleTypesMessage(binOp);
        msgCollector.collect(msg, MessageType.Error);
        throw new TypeCheckerException(binOp, msg, errCode, PigException.INPUT) ;
    }

}
 
Example 18
Source File: TypeUtil.java    From phoenix with Apache License 2.0 4 votes vote down vote up
/**
 * This method returns the most appropriate PDataType associated with 
 * the incoming Pig type. Note for Pig DataType DATETIME, returns DATE as 
 * inferredSqlType. 
 * 
 * This is later used to make a cast to targetPhoenixType accordingly. See
 * {@link #castPigTypeToPhoenix(Object, byte, PDataType)}
 * 
 * @param obj
 * @return PDataType
 */
public static PDataType getType(Object obj, byte type) {
	if (obj == null) {
		return null;
	}
	PDataType sqlType;

	switch (type) {
	case DataType.BYTEARRAY:
		sqlType = PVarbinary.INSTANCE;
		break;
	case DataType.CHARARRAY:
		sqlType = PVarchar.INSTANCE;
		break;
	case DataType.DOUBLE:
	case DataType.BIGDECIMAL:
		sqlType = PDouble.INSTANCE;
		break;
	case DataType.FLOAT:
		sqlType = PFloat.INSTANCE;
		break;
	case DataType.INTEGER:
		sqlType = PInteger.INSTANCE;
		break;
	case DataType.LONG:
	case DataType.BIGINTEGER:
		sqlType = PLong.INSTANCE;
		break;
	case DataType.BOOLEAN:
		sqlType = PBoolean.INSTANCE;
		break;
	case DataType.DATETIME:
		sqlType = PDate.INSTANCE;
		break;
	case DataType.BYTE:
		sqlType = PTinyint.INSTANCE;
		break;
	default:
		throw new RuntimeException("Unknown type " + obj.getClass().getName()
				+ " passed to PhoenixHBaseStorage");
	}

	return sqlType;

}
 
Example 19
Source File: BuildBloom.java    From spork with Apache License 2.0 4 votes vote down vote up
@Override
public Schema outputSchema(Schema input) {
    return new Schema(new Schema.FieldSchema(null, DataType.BYTEARRAY)); 
}
 
Example 20
Source File: TestPackage.java    From spork with Apache License 2.0 4 votes vote down vote up
/**
 * To show that it does not have any type specific
 * code
 */
private void pickTest(byte t, boolean[] inner) throws ExecException, IOException {
    Random r = new Random();
    switch (t) {
    case DataType.BAG:
        runTest(GenRandomData.genRandSmallTupDataBag(r, 10, 100), inner, DataType.BAG);
        break;
    case DataType.BOOLEAN:
        runTest(r.nextBoolean(), inner, DataType.BOOLEAN);
        break;
    case DataType.BYTEARRAY:
        runTest(GenRandomData.genRandDBA(r), inner, DataType.BYTEARRAY);
        break;
    case DataType.BIGCHARARRAY: {
        String s = GenRandomData.genRandString(r);
        for (; s.length() < 65535;) {
            s += GenRandomData.genRandString(r);
        }
        runTest(s, inner, DataType.CHARARRAY);
        break;
    }
    case DataType.CHARARRAY:
        runTest(GenRandomData.genRandString(r), inner, DataType.CHARARRAY);
        break;
    case DataType.DOUBLE:
        runTest(r.nextDouble(), inner, DataType.DOUBLE);
        break;
    case DataType.FLOAT:
        runTest(r.nextFloat(), inner, DataType.FLOAT);
        break;
    case DataType.INTEGER:
        runTest(r.nextInt(), inner, DataType.INTEGER);
        break;
    case DataType.LONG:
        runTest(r.nextLong(), inner, DataType.LONG);
        break;
    case DataType.DATETIME:
        runTest(new DateTime(r.nextLong()), inner, DataType.DATETIME);
        break;
    case DataType.MAP:
    case DataType.INTERNALMAP:
    case DataType.BYTE:
        return; // map not key type
    case DataType.TUPLE:
        runTest(GenRandomData.genRandSmallBagTuple(r, 10, 100), inner, DataType.TUPLE);
        break;
    case DataType.BIGINTEGER:
        runTest(new BigInteger(256, r), inner, DataType.BIGINTEGER);
        break;
    case DataType.BIGDECIMAL:
        runTest(new BigDecimal(r.nextDouble()), inner, DataType.BIGDECIMAL);
        break;
    default:
        fail("No test case for type " + DataType.findTypeName(t));
    }
}