You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@livy.apache.org by GitBox <gi...@apache.org> on 2019/09/05 08:16:50 UTC

[GitHub] [incubator-livy] mgaido91 commented on a change in pull request #209: [LIVY-640] Add tests for ThriftServer

mgaido91 commented on a change in pull request #209: [LIVY-640] Add tests for ThriftServer
URL: https://github.com/apache/incubator-livy/pull/209#discussion_r321128060
 
 

 ##########
 File path: thriftserver/server/src/test/scala/org/apache/livy/thriftserver/ThriftServerSuites.scala
 ##########
 @@ -260,6 +277,104 @@ class BinaryThriftServerSuite extends ThriftServerBaseTest with CommonThriftTest
   override def mode: ServerMode.Value = ServerMode.binary
   override def port: Int = 20000
 
+  test("test multiple session") {
+    var defaultV1: String = null
+    var defaultV2: String = null
+    var data: ArrayBuffer[Int] = null
+    try {
+      // create table
+      withJdbcStatement { statement =>
+        val queries = Seq(
+          "CREATE TABLE test_map(key INT, value STRING) USING json",
+          "CACHE TABLE test_table AS SELECT key FROM test_map ORDER BY key DESC")
+
+        queries.foreach(statement.execute)
+
+        val plan = statement.executeQuery("explain select * from test_table")
+        plan.next()
+        plan.next()
+        assert(plan.getString(1).contains("InMemoryTableScan"))
+
+        val rs1 = statement.executeQuery("SELECT key FROM test_table ORDER BY KEY DESC")
+        val buf1 = new collection.mutable.ArrayBuffer[Int]()
+        while (rs1.next()) {
+          buf1 += rs1.getInt(1)
+        }
+        rs1.close()
+
+        val rs2 = statement.executeQuery("SELECT key FROM test_map ORDER BY KEY DESC")
+        val buf2 = new collection.mutable.ArrayBuffer[Int]()
+        while (rs2.next()) {
+          buf2 += rs2.getInt(1)
+        }
+        rs2.close()
+
+        assert(buf1 === buf2)
+
+        data = buf1
+      }
+
+      // first session, we get the default value of the session status
+      withJdbcStatement { statement =>
+        val rs1 = statement.executeQuery(s"SET spark.sql.shuffle.partitions")
+        rs1.next()
+        assert("spark.sql.shuffle.partitions" ===  rs1.getString(1))
+        defaultV1 = rs1.getString(2)
+        rs1.close()
+
+        val rs2 = statement.executeQuery("SET hive.cli.print.header")
+        rs2.next()
+
+        assert("hive.cli.print.header" === rs2.getString(1))
+        defaultV2 = rs2.getString(2)
+        rs2.close()
+      }
+
+      // second session, we update the session status
+      withJdbcStatement { statement =>
+        val queries = Seq(
+          "SET spark.sql.shuffle.partitions=291",
+          "SET hive.cli.print.header=true"
+        )
+
+        queries.map(statement.execute)
+        val rs1 = statement.executeQuery(s"SET spark.sql.shuffle.partitions")
 
 Review comment:
   ```suggestion
           val rs1 = statement.executeQuery("SET spark.sql.shuffle.partitions")
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services