nebula icon indicating copy to clipboard operation
nebula copied to clipboard

The isAlwaysPure_ attribute of the built-in rand function is inconsistent with that of the rand32 function

Open chzhoo opened this issue 9 months ago • 0 comments

Describe the bug (required)

I hope to implement a sampling query through the following statement.

go from "player101" over follow where rand() < 0.1 yield id($$)

The test found that there are only two cases in which the results are returned

  • Empty set
  • Full set

Then I found out the reason is that the isAlwaysPure_ attribute of the built-in rand function is inconsistent with that of the rand32 function. The isAlwaysPure_ attribute of the rand function is true, but the isAlwaysPure_ attribute of the rand32 function is false.

Because the isAlwaysPure_ attribute of the rand function is true, so where rand() < 0.1 will be optimized to a bool constant. At last the returned results only have the full set and the empty set.

Your Environments (required)

  • OS: Linux VM-16-4-ubuntu 5.15.0-130-generic
  • Compiler: g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
  • CPU: AMD EPYC 9754 128-Core Processor
  • Commit id 5d43e44

Expected behavior

The isAlwaysPure_ attribute of the rand function is set to false

chzhoo avatar Mar 20 '25 12:03 chzhoo