You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Damien Carol (JIRA)" <ji...@apache.org> on 2015/06/09 10:19:01 UTC

[jira] [Updated] (HIVE-10933) Hive 0.13 returns precision 0 for varchar(32) from DatabaseMetadata.getColumns()

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

Damien Carol updated HIVE-10933:
--------------------------------
    Description: 
DatabaseMetadata.getColumns() returns "COLUMN_SIZE" as 0 for a column defined as varchar(32), or char(32).   While ResultSetMetaData.getPrecision() returns correct value 32.

Here is the segment program that reproduces the issue.
{code}
try {
	statement = connection.createStatement();
			
	statement.execute("drop table if exists son_table");
			
	statement.execute("create table son_table( col1 varchar(32) )");
			
	statement.close();
			
} catch ( Exception e) {
	   return;
}		
		
// get column info using metadata
try {
	DatabaseMetaData dmd = null;
	ResultSet resultSet = null;
			
	dmd = connection.getMetaData();
			
	resultSet = dmd.getColumns(null, null, "son_table", "col1");
			
	if ( resultSet.next() ) {
		String tabName = resultSet.getString("TABLE_NAME");
		String colName = resultSet.getString("COLUMN_NAME");
		String dataType = resultSet.getString("DATA_TYPE");
		String typeName = resultSet.getString("TYPE_NAME");
		int precision = resultSet.getInt("COLUMN_SIZE");
				
		// output is: colName = col1, dataType = 12, typeName = VARCHAR, precision = 0.
	      System.out.format("colName = %s, dataType = %s, typeName = %s, precision = %d.",
		colName, dataType, typeName, precision);
	}

} catch ( Exception e) {
	return;
}
{code}

  was:
DatabaseMetadata.getColumns() returns "COLUMN_SIZE" as 0 for a column defined as varchar(32), or char(32).   While ResultSetMetaData.getPrecision() returns correct value 32.

Here is the segment program that reproduces the issue.

try {
	statement = connection.createStatement();
			
	statement.execute("drop table if exists son_table");
			
	statement.execute("create table son_table( col1 varchar(32) )");
			
	statement.close();
			
} catch ( Exception e) {
	   return;
}		
		
// get column info using metadata
try {
	DatabaseMetaData dmd = null;
	ResultSet resultSet = null;
			
	dmd = connection.getMetaData();
			
	resultSet = dmd.getColumns(null, null, "son_table", "col1");
			
	if ( resultSet.next() ) {
		String tabName = resultSet.getString("TABLE_NAME");
		String colName = resultSet.getString("COLUMN_NAME");
		String dataType = resultSet.getString("DATA_TYPE");
		String typeName = resultSet.getString("TYPE_NAME");
		int precision = resultSet.getInt("COLUMN_SIZE");
				
		// output is: colName = col1, dataType = 12, typeName = VARCHAR, precision = 0.
	      System.out.format("colName = %s, dataType = %s, typeName = %s, precision = %d.",
		colName, dataType, typeName, precision);
	}

} catch ( Exception e) {
	return;
}




> Hive 0.13 returns precision 0 for varchar(32) from DatabaseMetadata.getColumns()
> --------------------------------------------------------------------------------
>
>                 Key: HIVE-10933
>                 URL: https://issues.apache.org/jira/browse/HIVE-10933
>             Project: Hive
>          Issue Type: Bug
>          Components: API
>    Affects Versions: 0.13.0
>            Reporter: Son Nguyen
>            Assignee: Chaoyu Tang
>
> DatabaseMetadata.getColumns() returns "COLUMN_SIZE" as 0 for a column defined as varchar(32), or char(32).   While ResultSetMetaData.getPrecision() returns correct value 32.
> Here is the segment program that reproduces the issue.
> {code}
> try {
> 	statement = connection.createStatement();
> 			
> 	statement.execute("drop table if exists son_table");
> 			
> 	statement.execute("create table son_table( col1 varchar(32) )");
> 			
> 	statement.close();
> 			
> } catch ( Exception e) {
> 	   return;
> }		
> 		
> // get column info using metadata
> try {
> 	DatabaseMetaData dmd = null;
> 	ResultSet resultSet = null;
> 			
> 	dmd = connection.getMetaData();
> 			
> 	resultSet = dmd.getColumns(null, null, "son_table", "col1");
> 			
> 	if ( resultSet.next() ) {
> 		String tabName = resultSet.getString("TABLE_NAME");
> 		String colName = resultSet.getString("COLUMN_NAME");
> 		String dataType = resultSet.getString("DATA_TYPE");
> 		String typeName = resultSet.getString("TYPE_NAME");
> 		int precision = resultSet.getInt("COLUMN_SIZE");
> 				
> 		// output is: colName = col1, dataType = 12, typeName = VARCHAR, precision = 0.
> 	      System.out.format("colName = %s, dataType = %s, typeName = %s, precision = %d.",
> 		colName, dataType, typeName, precision);
> 	}
> } catch ( Exception e) {
> 	return;
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)