comphead commented on code in PR #7836: URL: https://github.com/apache/datafusion-comet/pull/7836#discussion_r4788740967
########## spark/src/test/resources/sql-tests/expressions/map/map_null_short_circuit_no_codegen.sql: ########## @@ -0,0 +1,49 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- With spark.sql.codegen.factoryMode=NO_CODEGEN, Spark runs interpreted projections and +-- aggregates, which evaluate a subexpression they eliminate only when an expression asks for it. +-- A lookup on a NULL map never asks for its key, so the ANSI cast that both lookups share does not +-- raise there, unlike with generated code (see map_null_short_circuit_cse_off.sql). +-- https://github.com/apache/datafusion-comet/issues/7814 + +-- Config: spark.sql.ansi.enabled=true +-- Config: spark.sql.subexpressionElimination.enabled=true +-- Config: spark.sql.codegen.wholeStage=false +-- Config: spark.sql.codegen.factoryMode=NO_CODEGEN + +statement +CREATE TABLE map_null_short_circuit_no_codegen(m map<int, int>, m2 map<int, int>, s string) +USING parquet + +-- `s` is malformed only where the maps are NULL +statement +INSERT INTO map_null_short_circuit_no_codegen SELECT /*+ COALESCE(1) */ * FROM VALUES + (NULL, NULL, 'bad'), + (map(1, 10, 2, 20), map(2, 5), '2'), + (map(3, 30), map(4, 6), '4') + AS v(m, m2, s) + +query expect_native(getmapvalue) Review Comment: The title says map and array keys, but only `getmapvalue` is tested. The existing `cse_off` pair has an array counterpart (`array/array_null_short_circuit_cse_off.sql`), and that file also covers the other consumers of `raising`: shuffle partitioning keys, `TakeOrderedAndProject` and a `GROUP BY` aggregate. All of them are affected by this change under `NO_CODEGEN`, so an `array_null_short_circuit_no_codegen.sql` with `array_contains`, `array_position` and `element_at` on a NULL array and a malformed `CAST(s AS INT)` would cover the claim. I did not run this. ########## spark/src/test/resources/sql-tests/expressions/map/map_null_short_circuit_no_codegen.sql: ########## @@ -0,0 +1,49 @@ +-- Licensed to the Apache Software Foundation (ASF) under one +-- or more contributor license agreements. See the NOTICE file +-- distributed with this work for additional information +-- regarding copyright ownership. The ASF licenses this file +-- to you under the Apache License, Version 2.0 (the +-- "License"); you may not use this file except in compliance +-- with the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, +-- software distributed under the License is distributed on an +-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +-- KIND, either express or implied. See the License for the +-- specific language governing permissions and limitations +-- under the License. + +-- With spark.sql.codegen.factoryMode=NO_CODEGEN, Spark runs interpreted projections and +-- aggregates, which evaluate a subexpression they eliminate only when an expression asks for it. +-- A lookup on a NULL map never asks for its key, so the ANSI cast that both lookups share does not +-- raise there, unlike with generated code (see map_null_short_circuit_cse_off.sql). +-- https://github.com/apache/datafusion-comet/issues/7814 + +-- Config: spark.sql.ansi.enabled=true +-- Config: spark.sql.subexpressionElimination.enabled=true +-- Config: spark.sql.codegen.wholeStage=false Review Comment: `wholeStage=false` is redundant here because `NO_CODEGEN` already turns whole-stage codegen off (`CollapseCodegenStages` checks it on 3.5.8, 4.0.1 and 4.1.1, and `CometHashAggregateExec` in `operators.scala` relies on the same fact). Dropping it keeps the fixture honest that the factory mode is the only thing the fix keys on. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
