tanmayrauth commented on code in PR #1430:
URL: https://github.com/apache/iceberg-go/pull/1430#discussion_r3560670658
##########
catalog/sql/sql_test.go:
##########
@@ -425,6 +426,77 @@ func (s *SqliteCatalogTestSuite)
TestCreateTableDefaultSortOrder() {
}
}
+func (s *SqliteCatalogTestSuite) TestMetricsReporterWiring() {
+ ctx := context.Background()
+
+ newCatMemory := func(extra iceberg.Properties) *sqlcat.Catalog {
+ props := iceberg.Properties{
+ "uri": ":memory:",
+ sqlcat.DriverKey: sqliteshim.ShimName,
+ sqlcat.DialectKey: string(sqlcat.SQLite),
+ "type": "sql",
+ "warehouse": "file://" + s.warehouse,
+ }
+ maps.Copy(props, extra)
+ cat, err := catalog.Load(ctx, "default", props)
+ s.Require().NoError(err)
+
+ return cat.(*sqlcat.Catalog)
+ }
+
+ createTable := func(cat *sqlcat.Catalog) (*table.Table,
table.Identifier) {
+ tblID := s.randomTableIdentifier()
+ s.Require().NoError(cat.CreateNamespace(ctx,
catalog.NamespaceFromIdent(tblID), nil))
+ tbl, err := cat.CreateTable(ctx, tblID, tableSchemaNested)
+ s.Require().NoError(err)
+
+ return tbl, tblID
+ }
+
+ s.Run("configured reporter reaches created and loaded table", func() {
+ cat := newCatMemory(iceberg.Properties{metrics.ReporterImplKey:
"logging"})
+ created, tblID := createTable(cat)
+ s.IsType(&metrics.LoggingReporter{}, created.MetricsReporter())
+
+ loaded, err := cat.LoadTable(ctx, tblID)
+ s.Require().NoError(err)
+ s.IsType(&metrics.LoggingReporter{}, loaded.MetricsReporter())
+
+ // Scans inherit the table's reporter.
+ s.IsType(&metrics.LoggingReporter{}, loaded.Scan().Reporter())
+ })
+
+ s.Run("default is the no-op reporter", func() {
+ cat := newCatMemory(nil)
+ created, _ := createTable(cat)
+ s.IsType(metrics.NopReporter{}, created.MetricsReporter())
+ })
+
+ s.Run("unknown reporter name fails table load", func() {
+ // Create with a well-configured catalog, then reopen the same
+ // on-disk DB with a bad reporter name so the failure is
isolated to
+ // LoadTable rather than the create path.
+ good := s.getCatalogSqlite()
Review Comment:
the subtest now provisions its own temp DB and builds its props from a local
base map instead of leaning on s.getCatalogSqlite() / s.catalogUri().
--
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]