File tree Expand file tree Collapse file tree
client/jvm/src/test/scala/org/apache/spark/sql/connect
common/src/main/scala/org/apache/spark/sql/connect Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -151,6 +151,19 @@ class CatalogSuite extends ConnectFunSuite with RemoteSparkSession with SQLHelpe
151151 assert(spark.catalog.listTables().collect().isEmpty)
152152 }
153153
154+ test(" createTable should be eager" ) {
155+ val tableName = " eager_table"
156+ withTable(tableName) {
157+ withTempPath { dir =>
158+ val session = spark
159+ import session .implicits ._
160+ Seq ((1 , " a" )).toDF(" id" , " value" ).write.parquet(dir.getPath)
161+ spark.catalog.createTable(tableName, dir.getPath)
162+ assert(spark.catalog.tableExists(tableName))
163+ }
164+ }
165+ }
166+
154167 test(" Cache Table APIs" ) {
155168 val parquetTableName = " parquet_table"
156169 withTable(parquetTableName) {
Original file line number Diff line number Diff line change @@ -484,7 +484,7 @@ class Catalog(sparkSession: SparkSession) extends catalog.Catalog {
484484 schema : StructType ,
485485 description : String ,
486486 options : Map [String , String ]): DataFrame = {
487- sparkSession.newDataFrame { builder =>
487+ val df = sparkSession.newDataFrame { builder =>
488488 val createTableBuilder = builder.getCatalogBuilder.getCreateTableBuilder
489489 .setTableName(tableName)
490490 .setSource(source)
@@ -494,6 +494,8 @@ class Catalog(sparkSession: SparkSession) extends catalog.Catalog {
494494 createTableBuilder.putOptions(k, v)
495495 }
496496 }
497+ df.collect()
498+ df
497499 }
498500
499501 /**
You can’t perform that action at this time.
0 commit comments