hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kassem Tohme (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (HIVE-5724) Java API: comments are always null
Date Fri, 01 Nov 2013 13:06:19 GMT

     [ https://issues.apache.org/jira/browse/HIVE-5724?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Kassem Tohme updated HIVE-5724:
-------------------------------

    Description: 
Hey
I'm new to jira (just to let u know)

Following scenario:

Configuration config = new Configuration();
		config.addResource(new Path("/etc/hive/conf.cloudera.hive1/hive-site.xml"));
		
		try {
			HiveConf hiveConfig = HCatUtil.getHiveConf(config);
			HiveMetaStoreClient hmsClient = HCatUtil.getHiveClient(hiveConfig);
			Table table = hmsClient.getTable("testdb", "testtable");
			
			for (FieldSchema colFS : table.getSd().getCols()) {
				HCatFieldSchema col = HCatSchemaUtils.getHCatFieldSchema(colFS);
				System.out.println(col.getName() + " " + col.getComment());
			} 
			
			
		} catch (Exception e) {
			e.printStackTrace();
		}

Output :

id null
value null

HCatSchemaUtils.getHCatFieldSchema(String, TypInfo) seems ignores it.

public static HCatFieldSchema getHCatFieldSchema(FieldSchema fs) throws HCatException {
    String fieldName = fs.getName();
    TypeInfo baseTypeInfo = TypeInfoUtils.getTypeInfoFromTypeString(fs.getType());
    return getHCatFieldSchema(fieldName, baseTypeInfo);
  }

  private static HCatFieldSchema getHCatFieldSchema(String fieldName, TypeInfo fieldTypeInfo)
throws HCatException {
    Category typeCategory = fieldTypeInfo.getCategory();
    HCatFieldSchema hCatFieldSchema;
    if (Category.PRIMITIVE == typeCategory) {
      hCatFieldSchema = new HCatFieldSchema(fieldName, getPrimitiveHType(fieldTypeInfo), null);
    } else if (Category.STRUCT == typeCategory) {
      HCatSchema subSchema = constructHCatSchema((StructTypeInfo) fieldTypeInfo);
      hCatFieldSchema = new HCatFieldSchema(fieldName, HCatFieldSchema.Type.STRUCT, subSchema,
null);
    } else if (Category.LIST == typeCategory) {
      HCatSchema subSchema = getHCatSchema(((ListTypeInfo) fieldTypeInfo).getListElementTypeInfo());
      hCatFieldSchema = new HCatFieldSchema(fieldName, HCatFieldSchema.Type.ARRAY, subSchema,
null);
    } else if (Category.MAP == typeCategory) {
      HCatFieldSchema.Type mapKeyType = getPrimitiveHType(((MapTypeInfo) fieldTypeInfo).getMapKeyTypeInfo());
      HCatSchema subSchema = getHCatSchema(((MapTypeInfo) fieldTypeInfo).getMapValueTypeInfo());
      hCatFieldSchema = new HCatFieldSchema(fieldName, HCatFieldSchema.Type.MAP, mapKeyType,
subSchema, null);
    } else {
      throw new TypeNotPresentException(fieldTypeInfo.getTypeName(), null);
    }
    return hCatFieldSchema;
  }

Additional parameter FieldSchema in getHCatFieldSchema(String, TypeInfo) and replacing null
with fs.getComment() should fix it.
This "bug" also impacts on HCatalogs Java API.

        Summary: Java API: comments are always null  (was: Java API always returning null
)

> Java API: comments are always null
> ----------------------------------
>
>                 Key: HIVE-5724
>                 URL: https://issues.apache.org/jira/browse/HIVE-5724
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Kassem Tohme
>
> Hey
> I'm new to jira (just to let u know)
> Following scenario:
> Configuration config = new Configuration();
> 		config.addResource(new Path("/etc/hive/conf.cloudera.hive1/hive-site.xml"));
> 		
> 		try {
> 			HiveConf hiveConfig = HCatUtil.getHiveConf(config);
> 			HiveMetaStoreClient hmsClient = HCatUtil.getHiveClient(hiveConfig);
> 			Table table = hmsClient.getTable("testdb", "testtable");
> 			
> 			for (FieldSchema colFS : table.getSd().getCols()) {
> 				HCatFieldSchema col = HCatSchemaUtils.getHCatFieldSchema(colFS);
> 				System.out.println(col.getName() + " " + col.getComment());
> 			} 
> 			
> 			
> 		} catch (Exception e) {
> 			e.printStackTrace();
> 		}
> Output :
> id null
> value null
> HCatSchemaUtils.getHCatFieldSchema(String, TypInfo) seems ignores it.
> public static HCatFieldSchema getHCatFieldSchema(FieldSchema fs) throws HCatException
{
>     String fieldName = fs.getName();
>     TypeInfo baseTypeInfo = TypeInfoUtils.getTypeInfoFromTypeString(fs.getType());
>     return getHCatFieldSchema(fieldName, baseTypeInfo);
>   }
>   private static HCatFieldSchema getHCatFieldSchema(String fieldName, TypeInfo fieldTypeInfo)
throws HCatException {
>     Category typeCategory = fieldTypeInfo.getCategory();
>     HCatFieldSchema hCatFieldSchema;
>     if (Category.PRIMITIVE == typeCategory) {
>       hCatFieldSchema = new HCatFieldSchema(fieldName, getPrimitiveHType(fieldTypeInfo),
null);
>     } else if (Category.STRUCT == typeCategory) {
>       HCatSchema subSchema = constructHCatSchema((StructTypeInfo) fieldTypeInfo);
>       hCatFieldSchema = new HCatFieldSchema(fieldName, HCatFieldSchema.Type.STRUCT, subSchema,
null);
>     } else if (Category.LIST == typeCategory) {
>       HCatSchema subSchema = getHCatSchema(((ListTypeInfo) fieldTypeInfo).getListElementTypeInfo());
>       hCatFieldSchema = new HCatFieldSchema(fieldName, HCatFieldSchema.Type.ARRAY, subSchema,
null);
>     } else if (Category.MAP == typeCategory) {
>       HCatFieldSchema.Type mapKeyType = getPrimitiveHType(((MapTypeInfo) fieldTypeInfo).getMapKeyTypeInfo());
>       HCatSchema subSchema = getHCatSchema(((MapTypeInfo) fieldTypeInfo).getMapValueTypeInfo());
>       hCatFieldSchema = new HCatFieldSchema(fieldName, HCatFieldSchema.Type.MAP, mapKeyType,
subSchema, null);
>     } else {
>       throw new TypeNotPresentException(fieldTypeInfo.getTypeName(), null);
>     }
>     return hCatFieldSchema;
>   }
> Additional parameter FieldSchema in getHCatFieldSchema(String, TypeInfo) and replacing
null with fs.getComment() should fix it.
> This "bug" also impacts on HCatalogs Java API.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message