phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JamesRTaylor <...@git.apache.org>
Subject [GitHub] phoenix pull request: [PHOENIX-1814] Exponential notation parsing ...
Date Tue, 14 Apr 2015 22:54:39 GMT
Github user JamesRTaylor commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/67#discussion_r28379370
  
    --- Diff: phoenix-core/src/it/java/org/apache/phoenix/end2end/ArithmeticQueryIT.java ---
    @@ -985,4 +985,50 @@ public void testFloatingPointMultiplicationUpsert() throws Exception
{
             assertTrue(rs.next());
             assertEquals(-1.0f, rs.getFloat(1), 0.001);
         }
    +    
    +    @Test
    +    public void testFloatingPointWithExponentialNotation() throws Exception {
    +    	Float[] expected = {1.5E7f, 1.5E-7f, -1.5E-7f, 12E-5f, -.12E+34f};
    +    	String[] values = {"1.5e7", "1.5e-7", "-1.5e-7", "12E-5", "-.12E+34"};
    +        ResultSet rs = createTableWithValues(values, "FLOAT");
    +        for (int i = 0; i < expected.length; i++) {
    +        	assertEquals(expected[i], rs.getFloat(i+1), 0.001);
    +        }
    +    }
    +    
    +    @Test
    +    public void testDoubleWithExponentialNotation() throws Exception {
    +    	Double[] expected = {1.5E7d, 1.5E-7d, -1.5E-7d, 12E-5d, -.654E-321d, .1234E+56d};
    +    	String[] values = {"1.5e7", "1.5e-7", "-1.5e-7", "12E-5", "-.654E-321", ".1234E+56"};
    +    	ResultSet rs = createTableWithValues(values, "DOUBLE");
    +        for (int i = 0; i < expected.length; i++) {
    +        	assertEquals(expected[i], rs.getDouble(i+1), 0.001);
    +        }
    +    }
    +    
    +    private ResultSet createTableWithValues(String[] values, String valueType) throws
SQLException {
    +    	Connection conn = DriverManager.getConnection(getUrl());
    +        StringBuilder ddl = new StringBuilder("CREATE TABLE test (id VARCHAR not null
primary key");
    --- End diff --
    
    See comment [here](https://github.com/apache/phoenix/pull/67#discussion_r28377560). You
really just want to test how Phoenix translates the literal to an expression which you can
test that way. If you upsert the values into a column, there's quite a bit more going on.
We'll do automatic coercion from the source value to the target value, for example.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message