本文整理汇总了Java中org.apache.spark.sql.types.DataTypes.ShortType方法的典型用法代码示例。如果您正苦于以下问题:Java DataTypes.ShortType方法的具体用法?Java DataTypes.ShortType怎么用?Java DataTypes.ShortType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.spark.sql.types.DataTypes
的用法示例。
在下文中一共展示了DataTypes.ShortType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataTypeFromReturnType
import org.apache.spark.sql.types.DataTypes; //导入方法依赖的package包/类
private static DataType getDataTypeFromReturnType(Method method) {
String typeName = method.getReturnType().getSimpleName();
switch (typeName) {
case "int":
case "Integer":
return DataTypes.IntegerType;
case "long":
case "Long":
return DataTypes.LongType;
case "float":
case "Float":
return DataTypes.FloatType;
case "boolean":
case "Boolean":
return DataTypes.BooleanType;
case "double":
case "Double":
return DataTypes.DoubleType;
case "String":
return DataTypes.StringType;
case "Date":
case "date":
return DataTypes.DateType;
case "Timestamp":
return DataTypes.TimestampType;
case "short":
case "Short":
return DataTypes.ShortType;
case "Object":
return DataTypes.BinaryType;
default:
log.debug("Using default for type [{}]", typeName);
return DataTypes.BinaryType;
}
}
示例2: convertSqlTypeToSparkSqlDataType
import org.apache.spark.sql.types.DataTypes; //导入方法依赖的package包/类
public static org.apache.spark.sql.types.DataType convertSqlTypeToSparkSqlDataType(int sqlType) {
if (sqlType == java.sql.Types.BOOLEAN) {
return DataTypes.BooleanType;
} else if (sqlType == Types.TINYINT) {
return DataTypes.ByteType;
} else if (sqlType == Types.SMALLINT) {
return DataTypes.ShortType;
} else if (sqlType == java.sql.Types.INTEGER) {
return DataTypes.IntegerType;
} else if (sqlType == java.sql.Types.BIGINT) {
return DataTypes.LongType;
} else if (sqlType == Types.DECIMAL) {
return DataTypes.createDecimalType();
} else if (sqlType == java.sql.Types.FLOAT) {
return DataTypes.FloatType;
} else if (sqlType == java.sql.Types.DOUBLE) {
return DataTypes.DoubleType;
} else if (sqlType == Types.DATE) {
return DataTypes.DateType;
} else if (sqlType == Types.TIME) {
return DataTypes.TimestampType;
} else if (sqlType == Types.TIMESTAMP) {
return DataTypes.TimestampType;
} else if (sqlType == java.sql.Types.VARCHAR) {
return DataTypes.StringType;
} else {
logger.warn(String.format("Using string for unsupported sql type %s", sqlType));
return DataTypes.StringType;
}
}
示例3: parseDataType
import org.apache.spark.sql.types.DataTypes; //导入方法依赖的package包/类
private static DataType parseDataType(Config fieldsConfig) {
String type = fieldsConfig.getString(FIELD_TYPE_CONFIG);
switch (type) {
case "string":
return DataTypes.StringType;
case "byte":
return DataTypes.ByteType;
case "short":
return DataTypes.ShortType;
case "int":
return DataTypes.IntegerType;
case "long":
return DataTypes.LongType;
case "float":
return DataTypes.FloatType;
case "double":
return DataTypes.DoubleType;
case "decimal":
ConfigUtils.assertConfig(fieldsConfig, DECIMAL_SCALE_CONFIG);
ConfigUtils.assertConfig(fieldsConfig, DECIMAL_PRECISION_CONFIG);
return DataTypes.createDecimalType(
fieldsConfig.getInt(DECIMAL_SCALE_CONFIG),
fieldsConfig.getInt(DECIMAL_PRECISION_CONFIG));
case "boolean":
return DataTypes.BooleanType;
case "binary":
return DataTypes.BinaryType;
case "date":
return DataTypes.DateType;
case "timestamp":
return DataTypes.TimestampType;
case "array":
case "map":
case "struct":
throw new RuntimeException("Schema check does not currently support complex types");
default:
throw new RuntimeException("Unknown type: " + type);
}
}