Github user wangyum commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22263#discussion_r226187423
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/CachedTableSuite.scala ---
    @@ -288,6 +297,65 @@ class CachedTableSuite extends QueryTest with 
SQLTestUtils with SharedSQLContext
         }
       }
     
    +  test("SQL interface support storageLevel(DISK_ONLY)") {
    --- End diff --
    
    Thanks @dongjoon-hyun  How about:
    ```scala
    
      def assertStorageLevel(
          sqlStr: String,
          tableName: String,
          level: DataReadMethod.DataReadMethod): Unit = {
        sql(sqlStr)
        assertCached(spark.table(tableName))
        val rddId = rddIdOf(tableName)
        assert(isExpectStorageLevel(rddId, level))
      }
    
      test("SQL interface support storageLevel(DISK_ONLY)") {
        assertStorageLevel(
          "CACHE TABLE testData OPTIONS('storageLevel' 'DISK_ONLY')",
          "testData",
          Disk)
      }
    
      test("SQL interface cache SELECT ... support storageLevel(DISK_ONLY)") {
        withTempView("testCacheSelect") {
          assertStorageLevel(
            "CACHE TABLE testCacheSelect OPTIONS('storageLevel' 'DISK_ONLY') 
SELECT * FROM testData",
            "testCacheSelect",
            Disk)
        }
      }
    
      test("SQL interface support storageLevel(DISK_ONLY) with invalid 
options") {
        assertStorageLevel(
          "CACHE TABLE testData OPTIONS('storageLevel' 'DISK_ONLY', 'a' '1', 
'b' '2')",
          "testData",
          Disk)
      }
    
      test("SQL interface support storageLevel(MEMORY_ONLY)") {
        assertStorageLevel(
          "CACHE TABLE testData OPTIONS('storageLevel' 'MEMORY_ONLY')",
          "testData",
          Memory)
      }
    ```


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to