|
| 1 | +-- Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +-- or more contributor license agreements. See the NOTICE file |
| 3 | +-- distributed with this work for additional information |
| 4 | +-- regarding copyright ownership. The ASF licenses this file |
| 5 | +-- to you under the Apache License, Version 2.0 (the |
| 6 | +-- "License"); you may not use this file except in compliance |
| 7 | +-- with the License. You may obtain a copy of the License at |
| 8 | +-- |
| 9 | +-- http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +-- |
| 11 | +-- Unless required by applicable law or agreed to in writing, |
| 12 | +-- software distributed under the License is distributed on an |
| 13 | +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +-- KIND, either express or implied. See the License for the |
| 15 | +-- specific language governing permissions and limitations |
| 16 | +-- under the License. |
| 17 | + |
| 18 | +-- Config: spark.sql.ansi.enabled=false |
| 19 | + |
| 20 | +-- Two identical nondeterministic dispatched subtrees in one projection must each keep their own |
| 21 | +-- state, as they do in Spark. round over a double goes through the codegen dispatcher, so a and b |
| 22 | +-- below are two copies of the same dispatched round(rand(1), 2). With ANSI off, Round carries no |
| 23 | +-- query context, so both copies serialize to the same bytes; if they shared one kernel, b would |
| 24 | +-- continue a's random sequence instead of restarting it. |
| 25 | + |
| 26 | +-- One partition writes one file, so all 8 rows draw from a single seeded generator per column. |
| 27 | +statement |
| 28 | +CREATE TABLE test_round_rand(id bigint) USING parquet |
| 29 | + |
| 30 | +statement |
| 31 | +INSERT INTO test_round_rand SELECT id FROM range(0, 8, 1, 1) |
| 32 | + |
| 33 | +query expect_dispatch(round, rand) |
| 34 | +SELECT id, round(rand(1), 2) AS a, round(rand(1), 2) AS b FROM test_round_rand |
0 commit comments