[jira] [Commented] (DRILL-4618) random numbers generator function broken
[ https://issues.apache.org/jira/browse/DRILL-4618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15563626#comment-15563626 ] ASF GitHub Bot commented on DRILL-4618: --- Github user asfgit closed the pull request at: https://github.com/apache/drill/pull/509 > random numbers generator function broken > > > Key: DRILL-4618 > URL: https://issues.apache.org/jira/browse/DRILL-4618 > Project: Apache Drill > Issue Type: Bug >Reporter: Chunhui Shi >Assignee: Boaz Ben-Zvi > > File this JIRA based on the the bug description from Ted's email and > discussion in dev mail list for record purpose: > I am trying to generate some random numbers. I have a large base file (foo) > this is what I get: > 0: jdbc:drill:> select floor(1000*random()) as x, floor(1000*random()) as > y, floor(1000*rand()) as z from (select * from maprfs.tdunning.foo) a limit > 20; > ++++ > | x| y| z| > ++++ > | 556.0 | 556.0 | 618.0 | > | 564.0 | 564.0 | 618.0 | > | 129.0 | 129.0 | 618.0 | > | 48.0 | 48.0 | 618.0 | > | 696.0 | 696.0 | 618.0 | > | 642.0 | 642.0 | 618.0 | > | 535.0 | 535.0 | 618.0 | > | 440.0 | 440.0 | 618.0 | > | 894.0 | 894.0 | 618.0 | > | 24.0 | 24.0 | 618.0 | > | 508.0 | 508.0 | 618.0 | > | 28.0 | 28.0 | 618.0 | > | 816.0 | 816.0 | 618.0 | > | 717.0 | 717.0 | 618.0 | > | 334.0 | 334.0 | 618.0 | > | 978.0 | 978.0 | 618.0 | > | 646.0 | 646.0 | 618.0 | > | 787.0 | 787.0 | 618.0 | > | 260.0 | 260.0 | 618.0 | > | 711.0 | 711.0 | 618.0 | > ++++ > On this page, https://drill.apache.org/docs/math-and-trig/, the rand > function is described and random() is not. But it appears that rand() > delivers a constant instead (although a different constant each time the > query is run) and it appears that random() delivers the same value when > used multiple times in each returned value. > This seems very, very wrong. > The fault does not seem to be related to my querying a table: > 0: jdbc:drill:> select rand(), random(), random() from (values (1),(2),(3)) > x; > +-+---+---+ > | EXPR$0|EXPR$1 |EXPR$2 | > +-+---+---+ > | 0.1347749257216052 | 0.36724556209765014 | 0.36724556209765014 | > | 0.1347749257216052 | 0.006087161689924625 | 0.006087161689924625 | > | 0.1347749257216052 | 0.09417099142512142 | 0.09417099142512142 | > +-+---+---+ > For reference, postgres doesn't have rand() and does the right thing with > random(). -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (DRILL-4618) random numbers generator function broken
[ https://issues.apache.org/jira/browse/DRILL-4618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15563103#comment-15563103 ] ASF GitHub Bot commented on DRILL-4618: --- Github user sudheeshkatkam commented on the issue: https://github.com/apache/drill/pull/509 +1 > random numbers generator function broken > > > Key: DRILL-4618 > URL: https://issues.apache.org/jira/browse/DRILL-4618 > Project: Apache Drill > Issue Type: Bug >Reporter: Chunhui Shi >Assignee: Boaz Ben-Zvi > > File this JIRA based on the the bug description from Ted's email and > discussion in dev mail list for record purpose: > I am trying to generate some random numbers. I have a large base file (foo) > this is what I get: > 0: jdbc:drill:> select floor(1000*random()) as x, floor(1000*random()) as > y, floor(1000*rand()) as z from (select * from maprfs.tdunning.foo) a limit > 20; > ++++ > | x| y| z| > ++++ > | 556.0 | 556.0 | 618.0 | > | 564.0 | 564.0 | 618.0 | > | 129.0 | 129.0 | 618.0 | > | 48.0 | 48.0 | 618.0 | > | 696.0 | 696.0 | 618.0 | > | 642.0 | 642.0 | 618.0 | > | 535.0 | 535.0 | 618.0 | > | 440.0 | 440.0 | 618.0 | > | 894.0 | 894.0 | 618.0 | > | 24.0 | 24.0 | 618.0 | > | 508.0 | 508.0 | 618.0 | > | 28.0 | 28.0 | 618.0 | > | 816.0 | 816.0 | 618.0 | > | 717.0 | 717.0 | 618.0 | > | 334.0 | 334.0 | 618.0 | > | 978.0 | 978.0 | 618.0 | > | 646.0 | 646.0 | 618.0 | > | 787.0 | 787.0 | 618.0 | > | 260.0 | 260.0 | 618.0 | > | 711.0 | 711.0 | 618.0 | > ++++ > On this page, https://drill.apache.org/docs/math-and-trig/, the rand > function is described and random() is not. But it appears that rand() > delivers a constant instead (although a different constant each time the > query is run) and it appears that random() delivers the same value when > used multiple times in each returned value. > This seems very, very wrong. > The fault does not seem to be related to my querying a table: > 0: jdbc:drill:> select rand(), random(), random() from (values (1),(2),(3)) > x; > +-+---+---+ > | EXPR$0|EXPR$1 |EXPR$2 | > +-+---+---+ > | 0.1347749257216052 | 0.36724556209765014 | 0.36724556209765014 | > | 0.1347749257216052 | 0.006087161689924625 | 0.006087161689924625 | > | 0.1347749257216052 | 0.09417099142512142 | 0.09417099142512142 | > +-+---+---+ > For reference, postgres doesn't have rand() and does the right thing with > random(). -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (DRILL-4618) random numbers generator function broken
[ https://issues.apache.org/jira/browse/DRILL-4618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15563068#comment-15563068 ] ASF GitHub Bot commented on DRILL-4618: --- Github user sudheeshkatkam commented on a diff in the pull request: https://github.com/apache/drill/pull/509#discussion_r82657875 --- Diff: contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestInbuiltHiveUDFs.java --- @@ -84,7 +84,7 @@ public void testGetJsonObject() throws Exception { .go(); } - @Test // DRILL-3272 + @Test //DRILL-4618 --- End diff -- How is this test related to 4618? > random numbers generator function broken > > > Key: DRILL-4618 > URL: https://issues.apache.org/jira/browse/DRILL-4618 > Project: Apache Drill > Issue Type: Bug >Reporter: Chunhui Shi >Assignee: Boaz Ben-Zvi > > File this JIRA based on the the bug description from Ted's email and > discussion in dev mail list for record purpose: > I am trying to generate some random numbers. I have a large base file (foo) > this is what I get: > 0: jdbc:drill:> select floor(1000*random()) as x, floor(1000*random()) as > y, floor(1000*rand()) as z from (select * from maprfs.tdunning.foo) a limit > 20; > ++++ > | x| y| z| > ++++ > | 556.0 | 556.0 | 618.0 | > | 564.0 | 564.0 | 618.0 | > | 129.0 | 129.0 | 618.0 | > | 48.0 | 48.0 | 618.0 | > | 696.0 | 696.0 | 618.0 | > | 642.0 | 642.0 | 618.0 | > | 535.0 | 535.0 | 618.0 | > | 440.0 | 440.0 | 618.0 | > | 894.0 | 894.0 | 618.0 | > | 24.0 | 24.0 | 618.0 | > | 508.0 | 508.0 | 618.0 | > | 28.0 | 28.0 | 618.0 | > | 816.0 | 816.0 | 618.0 | > | 717.0 | 717.0 | 618.0 | > | 334.0 | 334.0 | 618.0 | > | 978.0 | 978.0 | 618.0 | > | 646.0 | 646.0 | 618.0 | > | 787.0 | 787.0 | 618.0 | > | 260.0 | 260.0 | 618.0 | > | 711.0 | 711.0 | 618.0 | > ++++ > On this page, https://drill.apache.org/docs/math-and-trig/, the rand > function is described and random() is not. But it appears that rand() > delivers a constant instead (although a different constant each time the > query is run) and it appears that random() delivers the same value when > used multiple times in each returned value. > This seems very, very wrong. > The fault does not seem to be related to my querying a table: > 0: jdbc:drill:> select rand(), random(), random() from (values (1),(2),(3)) > x; > +-+---+---+ > | EXPR$0|EXPR$1 |EXPR$2 | > +-+---+---+ > | 0.1347749257216052 | 0.36724556209765014 | 0.36724556209765014 | > | 0.1347749257216052 | 0.006087161689924625 | 0.006087161689924625 | > | 0.1347749257216052 | 0.09417099142512142 | 0.09417099142512142 | > +-+---+---+ > For reference, postgres doesn't have rand() and does the right thing with > random(). -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (DRILL-4618) random numbers generator function broken
[ https://issues.apache.org/jira/browse/DRILL-4618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15563062#comment-15563062 ] ASF GitHub Bot commented on DRILL-4618: --- Github user chunhui-shi commented on a diff in the pull request: https://github.com/apache/drill/pull/509#discussion_r82657521 --- Diff: contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestInbuiltHiveUDFs.java --- @@ -84,7 +84,6 @@ public void testGetJsonObject() throws Exception { .go(); } - @Test // DRILL-3272 public void testIf() throws Exception { --- End diff -- It was a merge error. Fixed. > random numbers generator function broken > > > Key: DRILL-4618 > URL: https://issues.apache.org/jira/browse/DRILL-4618 > Project: Apache Drill > Issue Type: Bug >Reporter: Chunhui Shi >Assignee: Boaz Ben-Zvi > > File this JIRA based on the the bug description from Ted's email and > discussion in dev mail list for record purpose: > I am trying to generate some random numbers. I have a large base file (foo) > this is what I get: > 0: jdbc:drill:> select floor(1000*random()) as x, floor(1000*random()) as > y, floor(1000*rand()) as z from (select * from maprfs.tdunning.foo) a limit > 20; > ++++ > | x| y| z| > ++++ > | 556.0 | 556.0 | 618.0 | > | 564.0 | 564.0 | 618.0 | > | 129.0 | 129.0 | 618.0 | > | 48.0 | 48.0 | 618.0 | > | 696.0 | 696.0 | 618.0 | > | 642.0 | 642.0 | 618.0 | > | 535.0 | 535.0 | 618.0 | > | 440.0 | 440.0 | 618.0 | > | 894.0 | 894.0 | 618.0 | > | 24.0 | 24.0 | 618.0 | > | 508.0 | 508.0 | 618.0 | > | 28.0 | 28.0 | 618.0 | > | 816.0 | 816.0 | 618.0 | > | 717.0 | 717.0 | 618.0 | > | 334.0 | 334.0 | 618.0 | > | 978.0 | 978.0 | 618.0 | > | 646.0 | 646.0 | 618.0 | > | 787.0 | 787.0 | 618.0 | > | 260.0 | 260.0 | 618.0 | > | 711.0 | 711.0 | 618.0 | > ++++ > On this page, https://drill.apache.org/docs/math-and-trig/, the rand > function is described and random() is not. But it appears that rand() > delivers a constant instead (although a different constant each time the > query is run) and it appears that random() delivers the same value when > used multiple times in each returned value. > This seems very, very wrong. > The fault does not seem to be related to my querying a table: > 0: jdbc:drill:> select rand(), random(), random() from (values (1),(2),(3)) > x; > +-+---+---+ > | EXPR$0|EXPR$1 |EXPR$2 | > +-+---+---+ > | 0.1347749257216052 | 0.36724556209765014 | 0.36724556209765014 | > | 0.1347749257216052 | 0.006087161689924625 | 0.006087161689924625 | > | 0.1347749257216052 | 0.09417099142512142 | 0.09417099142512142 | > +-+---+---+ > For reference, postgres doesn't have rand() and does the right thing with > random(). -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (DRILL-4618) random numbers generator function broken
[ https://issues.apache.org/jira/browse/DRILL-4618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15562858#comment-15562858 ] ASF GitHub Bot commented on DRILL-4618: --- Github user sudheeshkatkam commented on a diff in the pull request: https://github.com/apache/drill/pull/509#discussion_r82645626 --- Diff: contrib/storage-hive/core/src/test/java/org/apache/drill/exec/fn/hive/TestInbuiltHiveUDFs.java --- @@ -84,7 +84,6 @@ public void testGetJsonObject() throws Exception { .go(); } - @Test // DRILL-3272 public void testIf() throws Exception { --- End diff -- Why is this test being ignored? Is this test not relevant anymore? > random numbers generator function broken > > > Key: DRILL-4618 > URL: https://issues.apache.org/jira/browse/DRILL-4618 > Project: Apache Drill > Issue Type: Bug >Reporter: Chunhui Shi >Assignee: Boaz Ben-Zvi > > File this JIRA based on the the bug description from Ted's email and > discussion in dev mail list for record purpose: > I am trying to generate some random numbers. I have a large base file (foo) > this is what I get: > 0: jdbc:drill:> select floor(1000*random()) as x, floor(1000*random()) as > y, floor(1000*rand()) as z from (select * from maprfs.tdunning.foo) a limit > 20; > ++++ > | x| y| z| > ++++ > | 556.0 | 556.0 | 618.0 | > | 564.0 | 564.0 | 618.0 | > | 129.0 | 129.0 | 618.0 | > | 48.0 | 48.0 | 618.0 | > | 696.0 | 696.0 | 618.0 | > | 642.0 | 642.0 | 618.0 | > | 535.0 | 535.0 | 618.0 | > | 440.0 | 440.0 | 618.0 | > | 894.0 | 894.0 | 618.0 | > | 24.0 | 24.0 | 618.0 | > | 508.0 | 508.0 | 618.0 | > | 28.0 | 28.0 | 618.0 | > | 816.0 | 816.0 | 618.0 | > | 717.0 | 717.0 | 618.0 | > | 334.0 | 334.0 | 618.0 | > | 978.0 | 978.0 | 618.0 | > | 646.0 | 646.0 | 618.0 | > | 787.0 | 787.0 | 618.0 | > | 260.0 | 260.0 | 618.0 | > | 711.0 | 711.0 | 618.0 | > ++++ > On this page, https://drill.apache.org/docs/math-and-trig/, the rand > function is described and random() is not. But it appears that rand() > delivers a constant instead (although a different constant each time the > query is run) and it appears that random() delivers the same value when > used multiple times in each returned value. > This seems very, very wrong. > The fault does not seem to be related to my querying a table: > 0: jdbc:drill:> select rand(), random(), random() from (values (1),(2),(3)) > x; > +-+---+---+ > | EXPR$0|EXPR$1 |EXPR$2 | > +-+---+---+ > | 0.1347749257216052 | 0.36724556209765014 | 0.36724556209765014 | > | 0.1347749257216052 | 0.006087161689924625 | 0.006087161689924625 | > | 0.1347749257216052 | 0.09417099142512142 | 0.09417099142512142 | > +-+---+---+ > For reference, postgres doesn't have rand() and does the right thing with > random(). -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (DRILL-4618) random numbers generator function broken
[ https://issues.apache.org/jira/browse/DRILL-4618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15562857#comment-15562857 ] ASF GitHub Bot commented on DRILL-4618: --- Github user sudheeshkatkam commented on a diff in the pull request: https://github.com/apache/drill/pull/509#discussion_r82645633 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/EqualityVisitor.java --- @@ -75,6 +75,9 @@ public Boolean visitFunctionHolderExpression(FunctionHolderExpression holder, Lo if (!holder.getName().equals(((FunctionHolderExpression) value).getName())) { return false; } +if(holder.isRandom()) { --- End diff -- spacing: `if (` > random numbers generator function broken > > > Key: DRILL-4618 > URL: https://issues.apache.org/jira/browse/DRILL-4618 > Project: Apache Drill > Issue Type: Bug >Reporter: Chunhui Shi >Assignee: Boaz Ben-Zvi > > File this JIRA based on the the bug description from Ted's email and > discussion in dev mail list for record purpose: > I am trying to generate some random numbers. I have a large base file (foo) > this is what I get: > 0: jdbc:drill:> select floor(1000*random()) as x, floor(1000*random()) as > y, floor(1000*rand()) as z from (select * from maprfs.tdunning.foo) a limit > 20; > ++++ > | x| y| z| > ++++ > | 556.0 | 556.0 | 618.0 | > | 564.0 | 564.0 | 618.0 | > | 129.0 | 129.0 | 618.0 | > | 48.0 | 48.0 | 618.0 | > | 696.0 | 696.0 | 618.0 | > | 642.0 | 642.0 | 618.0 | > | 535.0 | 535.0 | 618.0 | > | 440.0 | 440.0 | 618.0 | > | 894.0 | 894.0 | 618.0 | > | 24.0 | 24.0 | 618.0 | > | 508.0 | 508.0 | 618.0 | > | 28.0 | 28.0 | 618.0 | > | 816.0 | 816.0 | 618.0 | > | 717.0 | 717.0 | 618.0 | > | 334.0 | 334.0 | 618.0 | > | 978.0 | 978.0 | 618.0 | > | 646.0 | 646.0 | 618.0 | > | 787.0 | 787.0 | 618.0 | > | 260.0 | 260.0 | 618.0 | > | 711.0 | 711.0 | 618.0 | > ++++ > On this page, https://drill.apache.org/docs/math-and-trig/, the rand > function is described and random() is not. But it appears that rand() > delivers a constant instead (although a different constant each time the > query is run) and it appears that random() delivers the same value when > used multiple times in each returned value. > This seems very, very wrong. > The fault does not seem to be related to my querying a table: > 0: jdbc:drill:> select rand(), random(), random() from (values (1),(2),(3)) > x; > +-+---+---+ > | EXPR$0|EXPR$1 |EXPR$2 | > +-+---+---+ > | 0.1347749257216052 | 0.36724556209765014 | 0.36724556209765014 | > | 0.1347749257216052 | 0.006087161689924625 | 0.006087161689924625 | > | 0.1347749257216052 | 0.09417099142512142 | 0.09417099142512142 | > +-+---+---+ > For reference, postgres doesn't have rand() and does the right thing with > random(). -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (DRILL-4618) random numbers generator function broken
[ https://issues.apache.org/jira/browse/DRILL-4618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15553879#comment-15553879 ] ASF GitHub Bot commented on DRILL-4618: --- Github user Ben-Zvi commented on the issue: https://github.com/apache/drill/pull/509 Tested and checked ... LGTM > random numbers generator function broken > > > Key: DRILL-4618 > URL: https://issues.apache.org/jira/browse/DRILL-4618 > Project: Apache Drill > Issue Type: Bug >Reporter: Chunhui Shi >Assignee: Boaz Ben-Zvi > > File this JIRA based on the the bug description from Ted's email and > discussion in dev mail list for record purpose: > I am trying to generate some random numbers. I have a large base file (foo) > this is what I get: > 0: jdbc:drill:> select floor(1000*random()) as x, floor(1000*random()) as > y, floor(1000*rand()) as z from (select * from maprfs.tdunning.foo) a limit > 20; > ++++ > | x| y| z| > ++++ > | 556.0 | 556.0 | 618.0 | > | 564.0 | 564.0 | 618.0 | > | 129.0 | 129.0 | 618.0 | > | 48.0 | 48.0 | 618.0 | > | 696.0 | 696.0 | 618.0 | > | 642.0 | 642.0 | 618.0 | > | 535.0 | 535.0 | 618.0 | > | 440.0 | 440.0 | 618.0 | > | 894.0 | 894.0 | 618.0 | > | 24.0 | 24.0 | 618.0 | > | 508.0 | 508.0 | 618.0 | > | 28.0 | 28.0 | 618.0 | > | 816.0 | 816.0 | 618.0 | > | 717.0 | 717.0 | 618.0 | > | 334.0 | 334.0 | 618.0 | > | 978.0 | 978.0 | 618.0 | > | 646.0 | 646.0 | 618.0 | > | 787.0 | 787.0 | 618.0 | > | 260.0 | 260.0 | 618.0 | > | 711.0 | 711.0 | 618.0 | > ++++ > On this page, https://drill.apache.org/docs/math-and-trig/, the rand > function is described and random() is not. But it appears that rand() > delivers a constant instead (although a different constant each time the > query is run) and it appears that random() delivers the same value when > used multiple times in each returned value. > This seems very, very wrong. > The fault does not seem to be related to my querying a table: > 0: jdbc:drill:> select rand(), random(), random() from (values (1),(2),(3)) > x; > +-+---+---+ > | EXPR$0|EXPR$1 |EXPR$2 | > +-+---+---+ > | 0.1347749257216052 | 0.36724556209765014 | 0.36724556209765014 | > | 0.1347749257216052 | 0.006087161689924625 | 0.006087161689924625 | > | 0.1347749257216052 | 0.09417099142512142 | 0.09417099142512142 | > +-+---+---+ > For reference, postgres doesn't have rand() and does the right thing with > random(). -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (DRILL-4618) random numbers generator function broken
[ https://issues.apache.org/jira/browse/DRILL-4618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15383317#comment-15383317 ] ASF GitHub Bot commented on DRILL-4618: --- Github user chunhui-shi commented on the issue: https://github.com/apache/drill/pull/509 @StevenMPhillips Hi Steven, is this fix addressing your concern now? Thanks. > random numbers generator function broken > > > Key: DRILL-4618 > URL: https://issues.apache.org/jira/browse/DRILL-4618 > Project: Apache Drill > Issue Type: Bug >Reporter: Chunhui Shi >Assignee: Chunhui Shi > > File this JIRA based on the the bug description from Ted's email and > discussion in dev mail list for record purpose: > I am trying to generate some random numbers. I have a large base file (foo) > this is what I get: > 0: jdbc:drill:> select floor(1000*random()) as x, floor(1000*random()) as > y, floor(1000*rand()) as z from (select * from maprfs.tdunning.foo) a limit > 20; > ++++ > | x| y| z| > ++++ > | 556.0 | 556.0 | 618.0 | > | 564.0 | 564.0 | 618.0 | > | 129.0 | 129.0 | 618.0 | > | 48.0 | 48.0 | 618.0 | > | 696.0 | 696.0 | 618.0 | > | 642.0 | 642.0 | 618.0 | > | 535.0 | 535.0 | 618.0 | > | 440.0 | 440.0 | 618.0 | > | 894.0 | 894.0 | 618.0 | > | 24.0 | 24.0 | 618.0 | > | 508.0 | 508.0 | 618.0 | > | 28.0 | 28.0 | 618.0 | > | 816.0 | 816.0 | 618.0 | > | 717.0 | 717.0 | 618.0 | > | 334.0 | 334.0 | 618.0 | > | 978.0 | 978.0 | 618.0 | > | 646.0 | 646.0 | 618.0 | > | 787.0 | 787.0 | 618.0 | > | 260.0 | 260.0 | 618.0 | > | 711.0 | 711.0 | 618.0 | > ++++ > On this page, https://drill.apache.org/docs/math-and-trig/, the rand > function is described and random() is not. But it appears that rand() > delivers a constant instead (although a different constant each time the > query is run) and it appears that random() delivers the same value when > used multiple times in each returned value. > This seems very, very wrong. > The fault does not seem to be related to my querying a table: > 0: jdbc:drill:> select rand(), random(), random() from (values (1),(2),(3)) > x; > +-+---+---+ > | EXPR$0|EXPR$1 |EXPR$2 | > +-+---+---+ > | 0.1347749257216052 | 0.36724556209765014 | 0.36724556209765014 | > | 0.1347749257216052 | 0.006087161689924625 | 0.006087161689924625 | > | 0.1347749257216052 | 0.09417099142512142 | 0.09417099142512142 | > +-+---+---+ > For reference, postgres doesn't have rand() and does the right thing with > random(). -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (DRILL-4618) random numbers generator function broken
[ https://issues.apache.org/jira/browse/DRILL-4618?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15304412#comment-15304412 ] ASF GitHub Bot commented on DRILL-4618: --- Github user StevenMPhillips commented on a diff in the pull request: https://github.com/apache/drill/pull/509#discussion_r64940411 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/EvaluationVisitor.java --- @@ -811,7 +811,7 @@ public HoldingContainer visitFunctionCall(FunctionCall call, ClassGenerator g @Override public HoldingContainer visitFunctionHolderExpression(FunctionHolderExpression holder, ClassGenerator generator) throws RuntimeException { HoldingContainer hc = getPrevious(holder, generator.getMappingSet()); - if (hc == null) { + if (hc == null || holder.isRandom()) { --- End diff -- I think this change is not sufficient to cover all cases. If random() is just part of the expression, then this won't help. For example, the expression 2 * random(). I think a better way to fix this would be to modify EqualityVisitor.visitFunctionHolderExpression() to return false if the function is random. That way any expression which contains a random function will never be considered equal to another expression. > random numbers generator function broken > > > Key: DRILL-4618 > URL: https://issues.apache.org/jira/browse/DRILL-4618 > Project: Apache Drill > Issue Type: Bug >Reporter: Chunhui Shi >Assignee: Chunhui Shi > > File this JIRA based on the the bug description from Ted's email and > discussion in dev mail list for record purpose: > I am trying to generate some random numbers. I have a large base file (foo) > this is what I get: > 0: jdbc:drill:> select floor(1000*random()) as x, floor(1000*random()) as > y, floor(1000*rand()) as z from (select * from maprfs.tdunning.foo) a limit > 20; > ++++ > | x| y| z| > ++++ > | 556.0 | 556.0 | 618.0 | > | 564.0 | 564.0 | 618.0 | > | 129.0 | 129.0 | 618.0 | > | 48.0 | 48.0 | 618.0 | > | 696.0 | 696.0 | 618.0 | > | 642.0 | 642.0 | 618.0 | > | 535.0 | 535.0 | 618.0 | > | 440.0 | 440.0 | 618.0 | > | 894.0 | 894.0 | 618.0 | > | 24.0 | 24.0 | 618.0 | > | 508.0 | 508.0 | 618.0 | > | 28.0 | 28.0 | 618.0 | > | 816.0 | 816.0 | 618.0 | > | 717.0 | 717.0 | 618.0 | > | 334.0 | 334.0 | 618.0 | > | 978.0 | 978.0 | 618.0 | > | 646.0 | 646.0 | 618.0 | > | 787.0 | 787.0 | 618.0 | > | 260.0 | 260.0 | 618.0 | > | 711.0 | 711.0 | 618.0 | > ++++ > On this page, https://drill.apache.org/docs/math-and-trig/, the rand > function is described and random() is not. But it appears that rand() > delivers a constant instead (although a different constant each time the > query is run) and it appears that random() delivers the same value when > used multiple times in each returned value. > This seems very, very wrong. > The fault does not seem to be related to my querying a table: > 0: jdbc:drill:> select rand(), random(), random() from (values (1),(2),(3)) > x; > +-+---+---+ > | EXPR$0|EXPR$1 |EXPR$2 | > +-+---+---+ > | 0.1347749257216052 | 0.36724556209765014 | 0.36724556209765014 | > | 0.1347749257216052 | 0.006087161689924625 | 0.006087161689924625 | > | 0.1347749257216052 | 0.09417099142512142 | 0.09417099142512142 | > +-+---+---+ > For reference, postgres doesn't have rand() and does the right thing with > random(). -- This message was sent by Atlassian JIRA (v6.3.4#6332)