Skip to content

[C++] random function can't actually be used #33181

Closed

Description

@asfimport

random() is currently implemented as a nullary function. It doesn't let you specify the number of values you want to generate because it's designed to generate however many the given ExecBatch has. The only option RandomOptions takes seems to be an optional seed value. Unfortunately, the result is that the function is not usable, AFAICT.

Calling the compute function directly, you get 0 values (all examples from R):

library(arrow)
call_function("random")
# Array
# <double>
# []

Calling it from within an ExecPlan, it errors because it is not a proper scalar function, despite what the filenames say (scalar_random.cc, etc.):

library(arrow)
library(dplyr)

mtcars %>% 
  arrow_table() %>% 
  mutate(x = arrow_random()) %>% 
  collect()
# Error in `collect()`:
# ! Invalid: ExecuteScalarExpression cannot Execute non-scalar expression Array[double]

Reporter: Neal Richardson / @nealrichardson

Note: This issue was originally created as ARROW-17974. Please see the migration documentation for further details.

Activity

  1. asfimport commented on Oct 11, 2022

    @asfimport
    Author

    Weston Pace / @westonpace:
    Probably related are ARROW-16286 and ARROW-16290

  2. asfimport commented on Oct 12, 2022

    @asfimport
    Author

    Neal Richardson / @nealrichardson:
    If it's relevant, I tried a nullary UDF and got the same error about non-scalar expression, so the issues @westonpace suggested are probably the problem and not the random() function itself.

  3. thisisnic commented on Nov 18, 2026

    @thisisnic
    Member

    Thanks for reporting this! I'm just going through older bug issues to see if we can close them out or we need further action.

    Could not reproduce on 26.0.0. Appears to have been fixed in #39908.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions