|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.apache.comet |
| 21 | + |
| 22 | +import org.apache.spark.SparkException |
| 23 | +import org.apache.spark.sql.CometTestBase |
| 24 | +import org.apache.spark.sql.catalyst.expressions.PrettyAttribute |
| 25 | +import org.apache.spark.sql.comet.{CometExec, CometExecUtils} |
| 26 | +import org.apache.spark.sql.types.LongType |
| 27 | +import org.apache.spark.sql.vectorized.ColumnarBatch |
| 28 | + |
| 29 | +class CometNativeSuite extends CometTestBase { |
| 30 | + test("test handling NPE thrown by JVM") { |
| 31 | + val rdd = spark.range(0, 1).rdd.map { value => |
| 32 | + val limitOp = |
| 33 | + CometExecUtils.getLimitNativePlan(Seq(PrettyAttribute("test", LongType)), 100).get |
| 34 | + val cometIter = CometExec.getCometIterator( |
| 35 | + Seq(new Iterator[ColumnarBatch] { |
| 36 | + override def hasNext: Boolean = true |
| 37 | + override def next(): ColumnarBatch = throw new NullPointerException() |
| 38 | + }), |
| 39 | + 1, |
| 40 | + limitOp) |
| 41 | + cometIter.next() |
| 42 | + cometIter.close() |
| 43 | + value |
| 44 | + } |
| 45 | + |
| 46 | + val exception = intercept[SparkException] { |
| 47 | + rdd.collect() |
| 48 | + } |
| 49 | + assert(exception.getMessage contains "java.lang.NullPointerException") |
| 50 | + } |
| 51 | +} |
0 commit comments