zeroshade commented on code in PR #2651:
URL: https://github.com/apache/iceberg-go/pull/2651#discussion_r4645629742


##########
catalog/catalogtest/catalogtest.go:
##########
@@ -161,6 +162,16 @@ func RunCatalogTests(t *testing.T, cfg Config) {
        } else {
                t.Run("NamespacePropertiesNotSupported", func(t *testing.T) { 
testNamespacePropertiesNotSupported(t, cfg) })
        }
+
+       if _, ok := catalog.As[catalog.ViewCatalog](cfg.NewCatalog(t)); ok {

Review Comment:
   The REST client always implements `ViewCatalog`, so this check always picks 
it up. Against a server that doesn't advertise view endpoints, every view call 
returns `rest.ErrEndpointNotSupported`, and all seven tests fail instead of 
skipping. That includes the opt-in external conformance test that users point 
at their own servers. Since `ErrEndpointNotSupported` wraps 
`iceberg.ErrNotImplemented`, the suite could skip the view tests when the first 
view call returns `ErrNotImplemented` without depending on `rest`. 
Alternatively, the external test could get an env toggle like the 
nested-namespace one.
   
   Separately, this probe builds one extra catalog at the parent level, which 
the `NewCatalog` doc ("called once per test") doesn't account for. Its cleanup 
is tied to the parent test, so it lives for the whole suite.



##########
catalog/catalogtest/views.go:
##########
@@ -0,0 +1,232 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package catalogtest
+
+import (
+       "context"
+       "testing"
+
+       "github.com/apache/iceberg-go/catalog"
+       "github.com/apache/iceberg-go/table"
+       "github.com/apache/iceberg-go/view"
+       "github.com/stretchr/testify/assert"
+       "github.com/stretchr/testify/require"
+)
+
+// viewSQL is the SQL the conformance tests create views with.
+const viewSQL = "SELECT id, data FROM tbl"
+
+// viewDialect is the dialect of viewSQL.
+const viewDialect = "spark"
+
+// newViewVersion returns the version the conformance tests create a view in
+// namespace with.
+func newViewVersion(t *testing.T, namespace table.Identifier) *view.Version {
+       t.Helper()
+
+       version, err := view.NewVersionFromSQL(1, 0,
+               view.Representation{SQL: viewSQL, Dialect: viewDialect}, 
namespace)
+       require.NoError(t, err)
+
+       return version
+}
+
+// createView creates the conformance view at ident and drops it on cleanup.
+// It uses [TableSchema] rather than [Schema] so that catalogs that assign
+// fresh field IDs on create and catalogs that keep the given IDs agree.
+func createView(t *testing.T, views catalog.ViewCatalog, ident 
table.Identifier) *view.View {
+       t.Helper()
+       ctx := context.Background()
+
+       v, err := views.CreateView(ctx, ident, newViewVersion(t, 
ident[:len(ident)-1]), TableSchema)
+       require.NoError(t, err)
+       t.Cleanup(func() { _ = views.DropView(ctx, ident) })
+
+       return v
+}
+
+// listViews collects every view identifier the catalog reports for namespace.
+func listViews(t *testing.T, views catalog.ViewCatalog, namespace 
table.Identifier) []table.Identifier {
+       t.Helper()
+
+       var out []table.Identifier
+       for ident, err := range views.ListViews(context.Background(), 
namespace) {
+               require.NoError(t, err)
+               out = append(out, ident)
+       }
+
+       return out
+}
+
+// newViewCatalog returns a fresh catalog from cfg and its view capability.
+func newViewCatalog(t *testing.T, cfg Config) (catalog.Catalog, 
catalog.ViewCatalog) {
+       t.Helper()
+
+       cat := cfg.NewCatalog(t)
+       views, ok := catalog.As[catalog.ViewCatalog](cat)
+       require.True(t, ok, "catalog should implement catalog.ViewCatalog")

Review Comment:
   Suggestion: always register the view subtests and `t.Skip` here instead of 
`require.True`. That removes the probe catalog in RunCatalogTests, makes the 
skips visible in `-v` output, and is a natural place to also skip on 
`iceberg.ErrNotImplemented` from the first view call.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to