hive-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Shelukhin (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HIVE-16881) Make extractSqlBoolean More Consistent
Date Mon, 12 Jun 2017 18:43:00 GMT

    [ https://issues.apache.org/jira/browse/HIVE-16881?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16046924#comment-16046924
] 

Sergey Shelukhin commented on HIVE-16881:
-----------------------------------------

It won't return true for 'YE' since it only handles single character strings. This looks like
an unnecessary change to me that needlessly adds a dependency for a very simple piece of code.

> 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.4.14#64029)

Mime
View raw message