[
https://issues.apache.org/jira/browse/PHOENIX-2942?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15321877#comment-15321877
]
James Taylor commented on PHOENIX-2942:
---------------------------------------
By putting parenthesis around the ORDER BY expressions, it becomes a row value
constructor expression. Without the parenthesis, the sort order is correct
(there's also a bug in your test - the sort order will be ascending by default).
{code}
@Test
public void testOrderByDecimalColumns() throws Exception {
Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
Connection conn = DriverManager.getConnection(getUrl(), props);
String ddl = "create table test1 (testpk varchar not null primary key,
l_quantity decimal(15,2), l_discount decimal(15,2))";
conn.createStatement().execute(ddl);
PreparedStatement stmt = conn.prepareStatement("upsert into test1
values ('a',0.1,0.9)");
stmt.execute();
stmt = conn.prepareStatement(" upsert into test1 values ('b',0.5,0.5)");
stmt.execute();
stmt = conn.prepareStatement(" upsert into test1 values ('c',0.9,0.1)");
stmt.execute();
conn.commit();
ResultSet rs;
stmt = conn.prepareStatement("select l_discount from test1 order by
l_discount,l_quantity");
rs = stmt.executeQuery();
assertTrue(rs.next());
assertEquals(0.1, rs.getDouble(1), 0.01);
assertTrue(rs.next());
assertEquals(0.5, rs.getDouble(1), 0.01);
assertTrue(rs.next());
assertEquals(0.9, rs.getDouble(1), 0.01);
}
{code}
It's still a bug, but not as severe as first expected.
> Order by incorrect for RVC
> --------------------------
>
> Key: PHOENIX-2942
> URL: https://issues.apache.org/jira/browse/PHOENIX-2942
> Project: Phoenix
> Issue Type: Bug
> Reporter: Mujtaba Chohan
> Fix For: 4.8.0
>
> Attachments: PHOENIX-2942-utest.patch
>
>
> {code}
> Incorrect
> select L_DISCOUNT, L_QUANTITY from lineitem_encoded order by
> (l_discount,L_QUANTITY) limit 10;
> +-------------+-------------+
> | L_DISCOUNT | L_QUANTITY |
> +-------------+-------------+
> | 0.04 | 17 |
> | 0.01 | 4 |
> | 0.09 | 28 |
> | 0.1 | 46 |
> | 0.06 | 27 |
> | 0.04 | 36 |
> | 0.1 | 49 |
> | 0.01 | 15 |
> | 0.1 | 34 |
> | 0.01 | 28 |
> +-------------+-------------+
> {code}
> {code}
> Correct
> select L_DISCOUNT, L_QUANTITY from lineitem_encoded order by (l_discount)
> limit 10;
> +-------------+-------------+
> | L_DISCOUNT | L_QUANTITY |
> +-------------+-------------+
> | 0 | 38 |
> | 0 | 24 |
> | 0 | 31 |
> | 0 | 41 |
> | 0 | 22 |
> | 0 | 5E+1 |
> | 0 | 1 |
> | 0 | 49 |
> | 0 | 28 |
> | 0 | 15 |
> +-------------+-------------+
> {code}
> {code}
> CREATE TABLE LINEITEM_ENCODED(L_ORDERKEY INTEGER not null, L_PARTKEY
> INTEGER, L_SUPPKEY INTEGER , L_LINENUMBER INTEGER not null, L_QUANTITY
> DECIMAL(15,2), L_EXTENDEDPRICE DECIMAL(15,2), L_DISCOUNT DECIMAL(15,2), L_TAX
> DECIMAL(15,2), L_RETURNFLAG CHAR(1), L_LINESTATUS CHAR(1), L_SHIPDATE DATE,
> L_COMMITDATE DATE, L_RECEIPTDATE DATE, L_SHIPINSTRUCT CHAR(25), L_SHIPMODE
> CHAR(10), L_COMMENT VARCHAR(44) constraint pk primary key(l_orderkey,
> l_linenumber));
> {code}
> I'll get a utest for it soon.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)