diff --git a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/KyuubiSparkUtil.scala b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/KyuubiSparkUtil.scala index 6192cd0fcef..90212d4dcd2 100644 --- a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/KyuubiSparkUtil.scala +++ b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/KyuubiSparkUtil.scala @@ -124,7 +124,7 @@ object KyuubiSparkUtil extends Logging { if (SPARK_ENGINE_RUNTIME_VERSION >= "4.0") { var uriBuilder = DynMethods.builder("fromUri") .impl("jakarta.ws.rs.core.UriBuilder", classOf[URI]) - .build() + .buildStatic() .invoke[AnyRef](uri) uriBuilder = DynMethods.builder("fragment") @@ -133,13 +133,13 @@ object KyuubiSparkUtil extends Logging { .invoke[AnyRef](fragment) DynMethods.builder("build") - .impl("jakarta.ws.rs.core.UriBuilder") + .impl("jakarta.ws.rs.core.UriBuilder", classOf[Array[AnyRef]]) .build(uriBuilder) - .invoke[URI]() + .invoke[URI](Array.empty[AnyRef]) } else { var uriBuilder = DynMethods.builder("fromUri") .impl("javax.ws.rs.core.UriBuilder", classOf[URI]) - .build() + .buildStatic() .invoke[AnyRef](uri) uriBuilder = DynMethods.builder("fragment") @@ -148,9 +148,9 @@ object KyuubiSparkUtil extends Logging { .invoke[AnyRef](fragment) DynMethods.builder("build") - .impl("javax.ws.rs.core.UriBuilder") + .impl("javax.ws.rs.core.UriBuilder", classOf[Array[AnyRef]]) .build(uriBuilder) - .invoke[URI]() + .invoke[URI](Array.empty[AnyRef]) } } } diff --git a/externals/kyuubi-spark-sql-engine/src/test/scala/org/apache/kyuubi/engine/spark/KyuubiSparkUtilSuite.scala b/externals/kyuubi-spark-sql-engine/src/test/scala/org/apache/kyuubi/engine/spark/KyuubiSparkUtilSuite.scala new file mode 100644 index 00000000000..a7ee3c08f9e --- /dev/null +++ b/externals/kyuubi-spark-sql-engine/src/test/scala/org/apache/kyuubi/engine/spark/KyuubiSparkUtilSuite.scala @@ -0,0 +1,34 @@ +/* + * 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. + */ + +package org.apache.kyuubi.engine.spark + +import java.net.URI + +import org.apache.kyuubi.KyuubiFunSuite +import org.apache.kyuubi.engine.spark.KyuubiSparkUtil.buildURI +import org.apache.kyuubi.engine.spark.operation.ExecutePython.DEFAULT_SPARK_PYTHON_HOME_ARCHIVE_FRAGMENT + +class KyuubiSparkUtilSuite extends KyuubiFunSuite { + test("get build uri") { + val uri = new URI("hdfs://a/b/c.zip") + val buildedUri = buildURI(uri, DEFAULT_SPARK_PYTHON_HOME_ARCHIVE_FRAGMENT) + assert(buildedUri.getScheme == "hdfs") + assert(buildedUri.getFragment == DEFAULT_SPARK_PYTHON_HOME_ARCHIVE_FRAGMENT) + assert(buildedUri.getSchemeSpecificPart == "//a/b/c.zip") + } +}