diff --git a/runtime/reconcilers/model.go b/runtime/reconcilers/model.go index 87e93313c6c..7b6a2f21be9 100644 --- a/runtime/reconcilers/model.go +++ b/runtime/reconcilers/model.go @@ -221,7 +221,11 @@ func (r *ModelReconciler) Reconcile(ctx context.Context, n *runtimev1.ResourceNa createErr := r.createModel(ctx, self, stagingTableName, !materialize) if createErr != nil { createErr = fmt.Errorf("failed to create model: %w", createErr) + } else if !r.C.Runtime.AllowHostAccess() { + // temporarily for debugging + logTableNameAndType(ctx, r.C, connector, stagingTableName) } + if createErr == nil && stage { // Rename the staging table to main view/table err = olapForceRenameTable(ctx, r.C, connector, stagingTableName, !materialize, tableName) diff --git a/runtime/reconcilers/source.go b/runtime/reconcilers/source.go index 442e094d7bc..a78db2e5272 100644 --- a/runtime/reconcilers/source.go +++ b/runtime/reconcilers/source.go @@ -179,7 +179,11 @@ func (r *SourceReconciler) Reconcile(ctx context.Context, n *runtimev1.ResourceN ingestErr := r.ingestSource(ctx, src.Spec, stagingTableName) if ingestErr != nil { ingestErr = fmt.Errorf("failed to ingest source: %w", ingestErr) + } else if !r.C.Runtime.AllowHostAccess() { + // temporarily for debugging + logTableNameAndType(ctx, r.C, connector, stagingTableName) } + if ingestErr == nil && src.Spec.StageChanges { // Rename staging table to main table err = olapForceRenameTable(ctx, r.C, connector, stagingTableName, false, tableName) diff --git a/runtime/reconcilers/util.go b/runtime/reconcilers/util.go index d9105d8c334..a0c34ff6a39 100644 --- a/runtime/reconcilers/util.go +++ b/runtime/reconcilers/util.go @@ -11,6 +11,7 @@ import ( "github.com/rilldata/rill/runtime" "github.com/rilldata/rill/runtime/drivers" "github.com/robfig/cron/v3" + "golang.org/x/exp/slog" ) // checkRefs checks that all refs exist, are idle, and have no errors. @@ -154,3 +155,32 @@ func safeSQLName(name string) string { } return fmt.Sprintf("\"%s\"", strings.ReplaceAll(name, "\"", "\"\"")) } + +func logTableNameAndType(ctx context.Context, c *runtime.Controller, connector, name string) { + olap, release, err := c.AcquireOLAP(ctx, connector) + if err != nil { + c.Logger.Error("LogTableNameAndType: failed to acquire OLAP", slog.Any("err", err)) + return + } + defer release() + + res, err := olap.Execute(context.Background(), &drivers.Statement{Query: "SELECT column_name, data_type FROM information_schema.columns WHERE table_name=? ORDER BY column_name ASC", Args: []any{name}}) + if err != nil { + c.Logger.Error("LogTableNameAndType: failed information_schema.columns", slog.Any("err", err)) + return + } + defer res.Close() + + colTyp := make([]string, 0) + var col, typ string + for res.Next() { + err = res.Scan(&col, &typ) + if err != nil { + c.Logger.Error("LogTableNameAndType: failed scan", slog.Any("err", err)) + return + } + colTyp = append(colTyp, fmt.Sprintf("%s:%s", col, typ)) + } + + c.Logger.Info("LogTableNameAndType: ", slog.String("name", name), slog.String("schema", strings.Join(colTyp, ", "))) +}