[ https://issues.apache.org/jira/browse/HIVE-16881?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
BELUGA BEHR updated HIVE-16881: ------------------------------- Description: {code:title=org.apache.hadoop.hive.metastore.MetaStoreDirectSql|borderStyle=solid} private static Boolean extractSqlBoolean(Object value) throws MetaException { // MySQL has booleans, but e.g. Derby uses 'Y'/'N' mapping. People using derby probably // don't care about performance anyway, but let's cover the common case. if (value == null) return null; if (value instanceof Boolean) return (Boolean)value; Character c = null; if (value instanceof String && ((String)value).length() == 1) { c = ((String)value).charAt(0); } if (c == null) return null; if (c == 'Y') return true; if (c == 'N') return false; throw new MetaException("Cannot extract boolean from column value " + value); } {code} It's not very clear here what the code intends. For example, if the _value_ is "YE" then the code returns _null_. If the _value_ is "Z" then an exception is thrown. # Change this to throw an exception when any invalid value is encountered # Add comments # Use Apache Commons Library for parsing was: {code:title=org.apache.hadoop.hive.metastore.MetaStoreDirectSql|borderStyle=solid} private static Boolean extractSqlBoolean(Object value) throws MetaException { // MySQL has booleans, but e.g. Derby uses 'Y'/'N' mapping. People using derby probably // don't care about performance anyway, but let's cover the common case. if (value == null) return null; if (value instanceof Boolean) return (Boolean)value; Character c = null; if (value instanceof String && ((String)value).length() == 1) { c = ((String)value).charAt(0); } if (c == null) return null; if (c == 'Y') return true; if (c == 'N') return false; throw new MetaException("Cannot extract boolean from column value " + value); } {code} It's not very clear here what the code intends. For example, if the _value_ is "YE" then the code returns _null_. If the _value_ is "Z" then an exception is thrown. # Change this to throw an exception when any invalid value is encountered # Add comments # User Apache Commons Library for parsing > Make extractSqlBoolean More Consistent > -------------------------------------- > > Key: HIVE-16881 > URL: https://issues.apache.org/jira/browse/HIVE-16881 > Project: Hive > Issue Type: Improvement > Components: Metastore > Affects Versions: 2.1.1, 3.0.0 > Reporter: BELUGA BEHR > Priority: Trivial > Attachments: HIVE-16881.1.patch > > > {code:title=org.apache.hadoop.hive.metastore.MetaStoreDirectSql|borderStyle=solid} > private static Boolean extractSqlBoolean(Object value) throws MetaException { > // MySQL has booleans, but e.g. Derby uses 'Y'/'N' mapping. People using > derby probably > // don't care about performance anyway, but let's cover the common case. > if (value == null) return null; > if (value instanceof Boolean) return (Boolean)value; > Character c = null; > if (value instanceof String && ((String)value).length() == 1) { > c = ((String)value).charAt(0); > } > if (c == null) return null; > if (c == 'Y') return true; > if (c == 'N') return false; > throw new MetaException("Cannot extract boolean from column value " + > value); > } > {code} > It's not very clear here what the code intends. For example, if the _value_ > is "YE" then the code returns _null_. If the _value_ is "Z" then an > exception is thrown. > # Change this to throw an exception when any invalid value is encountered > # Add comments > # Use Apache Commons Library for parsing -- This message was sent by Atlassian JIRA (v6.3.15#6346)