SteNicholas commented on a change in pull request #1921: URL: https://github.com/apache/incubator-kyuubi/pull/1921#discussion_r809616921
########## File path: externals/kyuubi-spark-sql-engine/src/test/scala/org/apache/kyuubi/engine/spark/operation/PlanOnlyStatementSuite.scala ########## @@ -0,0 +1,54 @@ +/* + * 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.operation + +import java.sql.SQLException + +import org.apache.kyuubi.engine.spark.WithSparkSQLEngine +import org.apache.kyuubi.operation.HiveJDBCTestHelper + +class PlanOnlyStatementSuite extends WithSparkSQLEngine with HiveJDBCTestHelper { + override protected def jdbcUrl: String = getJdbcUrl + override def withKyuubiConf: Map[String, String] = Map.empty + + test("Plan only operations - skip use statement") { + val createDatabaseStatement = "create database test_database" + val createTableStatement = "create table test_database.t(a int) using parquet" + val selectStatement = "select * from t" + val useStatement = "use test_database" + withJdbcStatement("t") { statement => + statement.executeQuery(createDatabaseStatement) Review comment: Why not use `statement#execute`? ########## File path: externals/kyuubi-spark-sql-engine/src/test/scala/org/apache/kyuubi/engine/spark/operation/PlanOnlyStatementSuite.scala ########## @@ -0,0 +1,54 @@ +/* + * 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.operation + +import java.sql.SQLException + +import org.apache.kyuubi.engine.spark.WithSparkSQLEngine +import org.apache.kyuubi.operation.HiveJDBCTestHelper + +class PlanOnlyStatementSuite extends WithSparkSQLEngine with HiveJDBCTestHelper { + override protected def jdbcUrl: String = getJdbcUrl + override def withKyuubiConf: Map[String, String] = Map.empty + + test("Plan only operations - skip use statement") { + val createDatabaseStatement = "create database test_database" Review comment: IMO, this doesn't need to create variable. ########## File path: externals/kyuubi-spark-sql-engine/src/test/scala/org/apache/kyuubi/engine/spark/operation/PlanOnlyStatementSuite.scala ########## @@ -0,0 +1,54 @@ +/* + * 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.operation + +import java.sql.SQLException + +import org.apache.kyuubi.engine.spark.WithSparkSQLEngine +import org.apache.kyuubi.operation.HiveJDBCTestHelper + +class PlanOnlyStatementSuite extends WithSparkSQLEngine with HiveJDBCTestHelper { + override protected def jdbcUrl: String = getJdbcUrl + override def withKyuubiConf: Map[String, String] = Map.empty + + test("Plan only operations - skip use statement") { + val createDatabaseStatement = "create database test_database" + val createTableStatement = "create table test_database.t(a int) using parquet" + val selectStatement = "select * from t" + val useStatement = "use test_database" + withJdbcStatement("t") { statement => + statement.executeQuery(createDatabaseStatement) + statement.executeQuery(createTableStatement) + + statement.execute("SET kyuubi.operation.plan.only.mode=parse") + val set0 = statement.executeQuery(selectStatement) + assert(set0.next()) + assert(set0.getString("plan") contains "UnresolvedRelation") + + statement.execute("SET kyuubi.operation.plan.only.mode=optimize") + val e0 = intercept[SQLException](statement.executeQuery(selectStatement)) + assert(e0.getMessage.contains("Table or view not found")) + + // execute UseStatement with plan-only mode to switch current database to 'test_database' Review comment: ```suggestion // execute SetNamespaceCommand with plan-only mode to switch current database to 'test_database' ``` ########## File path: externals/kyuubi-spark-sql-engine/src/test/scala/org/apache/kyuubi/engine/spark/operation/PlanOnlyStatementSuite.scala ########## @@ -0,0 +1,54 @@ +/* + * 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.operation + +import java.sql.SQLException + +import org.apache.kyuubi.engine.spark.WithSparkSQLEngine +import org.apache.kyuubi.operation.HiveJDBCTestHelper + +class PlanOnlyStatementSuite extends WithSparkSQLEngine with HiveJDBCTestHelper { Review comment: Why not add this test case in `org.apache.kyuubi.operation. PlanOnlyStatementSuite`? cc @yaooqinn ########## File path: externals/kyuubi-spark-sql-engine/src/test/scala/org/apache/kyuubi/engine/spark/operation/PlanOnlyStatementSuite.scala ########## @@ -0,0 +1,54 @@ +/* + * 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.operation + +import java.sql.SQLException + +import org.apache.kyuubi.engine.spark.WithSparkSQLEngine +import org.apache.kyuubi.operation.HiveJDBCTestHelper + +class PlanOnlyStatementSuite extends WithSparkSQLEngine with HiveJDBCTestHelper { + override protected def jdbcUrl: String = getJdbcUrl + override def withKyuubiConf: Map[String, String] = Map.empty + + test("Plan only operations - skip use statement") { Review comment: ```suggestion test("Plan only operation with set namespace command") { ``` -- 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]
