@@ -40,6 +40,33 @@ public actor DataFrameReader: Sendable {
40
40
self . sparkSession = sparkSession
41
41
}
42
42
43
+ /// Returns the specified table/view as a ``DataFrame``. If it's a table, it must support batch
44
+ /// reading and the returned ``DataFrame`` is the batch scan query plan of this table. If it's a
45
+ /// view, the returned ``DataFrame`` is simply the query plan of the view, which can either be a
46
+ /// batch or streaming query plan.
47
+ ///
48
+ /// - Parameter tableName: a qualified or unqualified name that designates a table or view. If a database is
49
+ /// specified, it identifies the table/view from the database. Otherwise, it first attempts to
50
+ /// find a temporary view with the given name and then match the table/view from the current
51
+ /// database. Note that, the global temporary view database is also valid here.
52
+ /// - Returns: A ``DataFrame`` instance.
53
+ public func table( _ tableName: String ) -> DataFrame {
54
+ var namedTable = NamedTable ( )
55
+ namedTable. unparsedIdentifier = tableName
56
+ namedTable. options = self . extraOptions. toStringDictionary ( )
57
+
58
+ var read = Read ( )
59
+ read. namedTable = namedTable
60
+
61
+ var relation = Relation ( )
62
+ relation. read = read
63
+
64
+ var plan = Plan ( )
65
+ plan. opType = . root( relation)
66
+
67
+ return DataFrame ( spark: sparkSession, plan: plan)
68
+ }
69
+
43
70
/// Specifies the input data source format.
44
71
/// - Parameter source: A string.
45
72
/// - Returns: A `DataFrameReader`.
0 commit comments