You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@tajo.apache.org by "Seungun Choe (JIRA)" <ji...@apache.org> on 2014/04/04 07:00:22 UTC
[jira] [Comment Edited] (TAJO-637) Enhance to_char() function
[ https://issues.apache.org/jira/browse/TAJO-637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13959634#comment-13959634 ]
Seungun Choe edited comment on TAJO-637 at 4/4/14 4:59 AM:
-----------------------------------------------------------
This patch just support '0, 9 and comma(,)' patterns.
These are test cases and results are some as Postgresql.
{code}
testSimpleEval("select to_char(123, '9999999') ", new String[]{" 123"});
testSimpleEval("select to_char(-12345, '0000099') ", new String[]{"-0012345"});
testSimpleEval("select to_char(12345, '99999') ", new String[]{"12345"});
testSimpleEval("select to_char(12345, '999') ", new String[]{"###"});
testSimpleEval("select to_char(-12345, '999') ", new String[]{"-###"});
testSimpleEval("select to_char(123.123, '999.999') ", new String[]{"123.123"});
testSimpleEval("select to_char(123.325, '999.99') ", new String[]{"123.33"});
testSimpleEval("select to_char(123.12345, '9999999.9999999') ", new String[]{" 123.1234500"});
testSimpleEval("select to_char(123.325, '99999999.99') ", new String[]{" 123.33"});
testSimpleEval("select to_char(123.325, '0999.99') ", new String[]{"0123.33"});
testSimpleEval("select to_char(0.325, '0999.99') ", new String[]{"0000.33"});
testSimpleEval("select to_char(-0.325, '0999.99') ", new String[]{"-0000.33"});
testSimpleEval("select to_char(-0.325, '9999.99') ", new String[]{" -0.33"});
testSimpleEval("select to_char(123.325, '999RN9999.999') ", new String[]{""});
testSimpleEval("select to_char(12345, '99D999') ", new String[]{""});
testSimpleEval("select to_char(12345, '90999999.99999') ", new String[]{"00012345.00000"});
testSimpleEval("select to_char(12345.12345, '99999') ", new String[]{"12345"});
testSimpleEval("select to_char(12345.12345, '99999.9999.9999') ", new String[]{""});
testSimpleEval("select to_char(123456, '09,999,999') ", new String[]{"00,123,456"});
testSimpleEval("select to_char(123.12345, '0999999.999,999,9') ", new String[]{"0000123.123,450,0"});
testSimpleEval("select to_char(123456, '99,999,999') ", new String[]{" 123,456"});
testSimpleEval("select to_char(123.12345, '999999.999,999,9') ", new String[]{" 123.123,450,0"});
testSimpleEval("select to_char(-123456, '09,999,999') ", new String[]{"-00,123,456"});
testSimpleEval("select to_char(-123.12345, '0999999.999,999,9') ", new String[]{"-0000123.123,450,0"});
testSimpleEval("select to_char(-123456, '99,999,999') ", new String[]{" -123,456"});
testSimpleEval("select to_char(-123.12345, '999999.999,999,9') ", new String[]{" -123.123,450,0"});
Schema schema = new Schema();
schema.addColumn("col1", FLOAT8);
schema.addColumn("col2", TEXT);
testEval(schema, "table1", ",", "select to_char(col1, col2) from table1", new String[]{""});
testEval(schema, "table1", "0,", "select to_char(col1, col2) from table1", new String[]{""});
testEval(schema, "table1", ",'999'", "select to_char(col1, col2) from table1", new String[]{""});
{code}
I'll develop more and more this function. (Support almost postgresql's patterns)
was (Author: seungunchoe):
This patch just support '0, 9 and comma(,)' patterns.
These are test cases and results are some as Postgresql.
testSimpleEval("select to_char(123, '9999999') ", new String[]{" 123"});
testSimpleEval("select to_char(-12345, '0000099') ", new String[]{"-0012345"});
testSimpleEval("select to_char(12345, '99999') ", new String[]{"12345"});
testSimpleEval("select to_char(12345, '999') ", new String[]{"###"});
testSimpleEval("select to_char(-12345, '999') ", new String[]{"-###"});
testSimpleEval("select to_char(123.123, '999.999') ", new String[]{"123.123"});
testSimpleEval("select to_char(123.325, '999.99') ", new String[]{"123.33"});
testSimpleEval("select to_char(123.12345, '9999999.9999999') ", new String[]{" 123.1234500"});
testSimpleEval("select to_char(123.325, '99999999.99') ", new String[]{" 123.33"});
testSimpleEval("select to_char(123.325, '0999.99') ", new String[]{"0123.33"});
testSimpleEval("select to_char(0.325, '0999.99') ", new String[]{"0000.33"});
testSimpleEval("select to_char(-0.325, '0999.99') ", new String[]{"-0000.33"});
testSimpleEval("select to_char(-0.325, '9999.99') ", new String[]{" -0.33"});
testSimpleEval("select to_char(123.325, '999RN9999.999') ", new String[]{""});
testSimpleEval("select to_char(12345, '99D999') ", new String[]{""});
testSimpleEval("select to_char(12345, '90999999.99999') ", new String[]{"00012345.00000"});
testSimpleEval("select to_char(12345.12345, '99999') ", new String[]{"12345"});
testSimpleEval("select to_char(12345.12345, '99999.9999.9999') ", new String[]{""});
testSimpleEval("select to_char(123456, '09,999,999') ", new String[]{"00,123,456"});
testSimpleEval("select to_char(123.12345, '0999999.999,999,9') ", new String[]{"0000123.123,450,0"});
testSimpleEval("select to_char(123456, '99,999,999') ", new String[]{" 123,456"});
testSimpleEval("select to_char(123.12345, '999999.999,999,9') ", new String[]{" 123.123,450,0"});
testSimpleEval("select to_char(-123456, '09,999,999') ", new String[]{"-00,123,456"});
testSimpleEval("select to_char(-123.12345, '0999999.999,999,9') ", new String[]{"-0000123.123,450,0"});
testSimpleEval("select to_char(-123456, '99,999,999') ", new String[]{" -123,456"});
testSimpleEval("select to_char(-123.12345, '999999.999,999,9') ", new String[]{" -123.123,450,0"});
Schema schema = new Schema();
schema.addColumn("col1", FLOAT8);
schema.addColumn("col2", TEXT);
testEval(schema, "table1", ",", "select to_char(col1, col2) from table1", new String[]{""});
testEval(schema, "table1", "0,", "select to_char(col1, col2) from table1", new String[]{""});
testEval(schema, "table1", ",'999'", "select to_char(col1, col2) from table1", new String[]{""});
I'll develop more and more this function. (Support almost postgresql's patterns)
> Enhance to_char() function
> --------------------------
>
> Key: TAJO-637
> URL: https://issues.apache.org/jira/browse/TAJO-637
> Project: Tajo
> Issue Type: Improvement
> Reporter: Keuntae Park
> Assignee: Seungun Choe
> Priority: Minor
> Attachments: TAJO-637.patch, TAJO-637_1.patch
>
>
> Currently, Tajo only supports to_char(timestamp, text) function.
> However, PostgreSQL supports to_char() for timestamp, interval, int, double, and numeric types
> Tajo needs to support more data types in to_char() as shown in
> http://www.postgresql.org/docs/9.3/static/functions-formatting.html
--
This message was sent by Atlassian JIRA
(v6.2#6252)