presto-jdbc/src/main/java/io/prestosql/jdbc/ObjectCasts.java/ObjectCasts/castToBoolean
class ObjectCasts:    public static boolean castToBoolean(Object x, int targetSqlType)
            throws SQLException
    {
        if (x instanceof Boolean) {
            return (Boolean) x;
        }
        try {
            if (x instanceof Number) {
                return ((Number) x).intValue() != 0;
            }
            if (x instanceof String) {
                switch (((String) x).toLowerCase(ENGLISH)) {
                    case "0":
                    case "false":
                        return false;
                    case "1":
                    case "true":
                        return true;
                }
                throw new IllegalArgumentException("Invalid boolean value: " + x);
            }
        }
        catch (RuntimeException e) {
            throw invalidConversion(x, targetSqlType, e);
        }
        throw invalidConversion(x, targetSqlType);
    }