[ https://issues.apache.org/jira/browse/HIVE-16881?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16062210#comment-16062210 ]
BELUGA BEHR commented on HIVE-16881: ------------------------------------ Future-proofs the code if something changes later. The consistent results will be helpful. > 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 > Assignee: BELUGA BEHR > Priority: Trivial > Attachments: HIVE-16881.1.patch, HIVE-16881.2.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.4.14#64029)