@@ -21,6 +21,7 @@ package sql_test
2121
2222import (
2323 "context"
24+ "fmt"
2425 "net/url"
2526 "os"
2627 "path/filepath"
@@ -208,37 +209,37 @@ func (s *SQLIntegrationSuite) TestCreateTable() {
208209 s .Require ().NoError (s .cat .DropTable (s .ctx , catalog .ToIdentifier (TestNamespaceIdent , "test-table" )))
209210}
210211
211- // func (s *SQLIntegrationSuite) TestCreateView() {
212- // s.ensureNamespace()
213- //
214- // // create a table first
215- // tbl, err := s.cat.CreateTable(s.ctx,
216- // catalog.ToIdentifier(TestNamespaceIdent, "test-table"),
217- // tableSchemaSimple, catalog.WithProperties(iceberg.Properties{"foobar": "baz"}),
218- // catalog.WithLocation(location))
219- // s.Require().NoError(err)
220- // s.Require().NotNil(tbl)
221- //
222- // s.Equal(location, tbl.Location())
223- // s.Equal("baz", tbl.Properties()["foobar"])
224- //
225- // exists, err := s.cat.CheckTableExists(s.ctx, catalog.ToIdentifier(TestNamespaceIdent, "test-table"))
226- // s.Require().NoError(err)
227- // s.True(exists)
228- //
229- // // Create a view
230- // viewSQL := fmt.Sprintf("SELECT * FROM %s.%s", TestNamespaceIdent, "test-table")
231- //
232- // err = s.cat.CreateView(s.ctx, catalog.ToIdentifier(TestNamespaceIdent, "test-view"), tableSchemaSimple, viewSQL, iceberg.Properties{"foobar": "baz"})
233- // s.Require().NoError(err)
234- //
235- // exists, err = s.cat.CheckViewExists(s.ctx, catalog.ToIdentifier(TestNamespaceIdent, "test-view"))
236- // s.Require().NoError(err)
237- // s.True(exists)
238- //
239- // s.Require().NoError(s.cat.DropTable(s.ctx, catalog.ToIdentifier(TestNamespaceIdent, "test-table")))
240- // s.Require().NoError(s.cat.DropView(s.ctx, catalog.ToIdentifier(TestNamespaceIdent, "test-view")))
241- // }
212+ func (s * SQLIntegrationSuite ) TestCreateView () {
213+ s .ensureNamespace ()
214+
215+ // create a table first
216+ tbl , err := s .cat .CreateTable (s .ctx ,
217+ catalog .ToIdentifier (TestNamespaceIdent , "test-table" ),
218+ tableSchemaSimple , catalog .WithProperties (iceberg.Properties {"foobar" : "baz" }),
219+ catalog .WithLocation (location ))
220+ s .Require ().NoError (err )
221+ s .Require ().NotNil (tbl )
222+
223+ s .Equal (location , tbl .Location ())
224+ s .Equal ("baz" , tbl .Properties ()["foobar" ])
225+
226+ exists , err := s .cat .CheckTableExists (s .ctx , catalog .ToIdentifier (TestNamespaceIdent , "test-table" ))
227+ s .Require ().NoError (err )
228+ s .True (exists )
229+
230+ // Create a view
231+ viewSQL := fmt .Sprintf ("SELECT * FROM %s.%s" , TestNamespaceIdent , "test-table" )
232+
233+ err = s .cat .CreateView (s .ctx , catalog .ToIdentifier (TestNamespaceIdent , "test-view" ), tableSchemaSimple , viewSQL , iceberg.Properties {"foobar" : "baz" })
234+ s .Require ().NoError (err )
235+
236+ exists , err = s .cat .CheckViewExists (s .ctx , catalog .ToIdentifier (TestNamespaceIdent , "test-view" ))
237+ s .Require ().NoError (err )
238+ s .True (exists )
239+
240+ s .Require ().NoError (s .cat .DropTable (s .ctx , catalog .ToIdentifier (TestNamespaceIdent , "test-table" )))
241+ s .Require ().NoError (s .cat .DropView (s .ctx , catalog .ToIdentifier (TestNamespaceIdent , "test-view" )))
242+ }
242243
243244func (s * SQLIntegrationSuite ) TestWriteCommitTable () {
244245 s .ensureNamespace ()
@@ -277,32 +278,35 @@ func (s *SQLIntegrationSuite) TestWriteCommitTable() {
277278 pqfile , err := url .JoinPath (location , "data" , "test_commit_table_data" , "test.parquet" )
278279 s .Require ().NoError (err )
279280
280- fw , err := tbl .FS ().(io.WriteFileIO ).Create (pqfile )
281+ fs , err := tbl .FS (s .ctx )
282+ s .Require ().NoError (err )
283+ fw , err := fs .(io.WriteFileIO ).Create (pqfile )
281284 s .Require ().NoError (err )
282285 s .Require ().NoError (pqarrow .WriteTable (table , fw , table .NumRows (),
283286 nil , pqarrow .DefaultWriterProps ()))
284287 defer func (fs io.IO , name string ) {
285- err := fs .Remove (name )
286- if err != nil {
287-
288- }
289- }(tbl .FS (), pqfile )
288+ err = fs .Remove (name )
289+ s .Require ().NoError (err )
290+ }(fs , pqfile )
290291
291292 txn := tbl .NewTransaction ()
292293 s .Require ().NoError (txn .AddFiles (s .ctx , []string {pqfile }, nil , false ))
293294 updated , err := txn .Commit (s .ctx )
294295 s .Require ().NoError (err )
295296
296297 mf := []iceberg.ManifestFile {}
297- for m , err := range updated .AllManifests () {
298+ for m , err := range updated .AllManifests (s . ctx ) {
298299 s .Require ().NoError (err )
299300 s .Require ().NotNil (m )
300301 mf = append (mf , m )
301302 }
302303
303304 s .Len (mf , 1 )
304305 s .EqualValues (1 , mf [0 ].AddedDataFiles ())
305- entries , err := mf [0 ].FetchEntries (updated .FS (), false )
306+ updatedFS , err := updated .FS (s .ctx )
307+ s .Require ().NoError (err )
308+
309+ entries , err := mf [0 ].FetchEntries (updatedFS , false )
306310 s .Require ().NoError (err )
307311
308312 s .Len (entries , 1 )
0 commit comments