Skip to content

Commit

Permalink
More renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
neilotoole committed Nov 19, 2023
1 parent 0ca4f4a commit e14d564
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions drivers/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ func (d *driveri) doOpen(ctx context.Context, src *source.Source) (*sql.DB, erro
}

if src.Catalog != "" && src.Catalog != dbCfg.ConnConfig.Database {
// The catalog differs from the pool in the connection string.
// OOTB, Postgres doesn't support cross-pool references. So,
// The catalog differs from the database in the connection string.
// OOTB, Postgres doesn't support cross-database references. So,
// we'll need to change the connection string to use the catalog
// as the pool. Note that we don't modify src.Location, but it's
// as the database. Note that we don't modify src.Location, but it's
// not entirely clear if that's the correct approach. Are there any
// downsides to modifying it (as long as the modified Location is not
// persisted back to config)?
Expand All @@ -187,7 +187,7 @@ func (d *driveri) doOpen(ctx context.Context, src *source.Source) (*sql.DB, erro
if err != nil {
return nil, errw(err)
}
log.Debug("Using catalog as pool in connection string",
log.Debug("Using catalog as database in connection string",
lga.Src, src,
lga.Catalog, src.Catalog,
lga.Conn, source.RedactLocation(connStr),
Expand Down
2 changes: 1 addition & 1 deletion drivers/xlsx/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (p *pool) TableMetadata(ctx context.Context, tblName string) (*source.Table
func (p *pool) Close() error {
p.log.Debug(lgm.CloseDB, lga.Handle, p.src.Handle)

// No need to explicitly invoke c.scratchDB.Close because
// No need to explicitly invoke c.scratchPool.Close because
// that's already added to c.clnup
return p.clnup.Run()
}
26 changes: 13 additions & 13 deletions drivers/xlsx/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,16 @@ func (xs *xSheet) loadSampleRows(ctx context.Context, sampleSize int) error {
return nil
}

// ingestXLSX loads the data in xfile into scratchDB.
// ingestXLSX loads the data in xfile into scratchPool.
// If includeSheetNames is non-empty, only the named sheets are ingested.
func ingestXLSX(ctx context.Context, src *source.Source, scratchDB driver.Pool,
func ingestXLSX(ctx context.Context, src *source.Source, scratchPool driver.Pool,
xfile *excelize.File, includeSheetNames []string,
) error {
log := lg.FromContext(ctx)
start := time.Now()
log.Debug("Beginning import from XLSX",
lga.Src, src,
lga.Target, scratchDB.Source())
lga.Target, scratchPool.Source())

var sheets []*xSheet
if len(includeSheetNames) > 0 {
Expand Down Expand Up @@ -132,18 +132,18 @@ func ingestXLSX(ctx context.Context, src *source.Source, scratchDB driver.Pool,
}

var db *sql.DB
if db, err = scratchDB.DB(ctx); err != nil {
if db, err = scratchPool.DB(ctx); err != nil {
return err
}

if err = scratchDB.SQLDriver().CreateTable(ctx, db, sheetTbl.def); err != nil {
if err = scratchPool.SQLDriver().CreateTable(ctx, db, sheetTbl.def); err != nil {
return err
}
}

log.Debug("Tables created (but not yet populated)",
lga.Count, len(sheetTbls),
lga.Target, scratchDB.Source(),
lga.Target, scratchPool.Source(),
lga.Elapsed, time.Since(start))

var imported, skipped int
Expand All @@ -154,7 +154,7 @@ func ingestXLSX(ctx context.Context, src *source.Source, scratchDB driver.Pool,
continue
}

if err = ingestSheetToTable(ctx, scratchDB, sheetTbls[i]); err != nil {
if err = ingestSheetToTable(ctx, scratchPool, sheetTbls[i]); err != nil {
return err
}
imported++
Expand All @@ -164,16 +164,16 @@ func ingestXLSX(ctx context.Context, src *source.Source, scratchDB driver.Pool,
lga.Count, imported,
"skipped", skipped,
lga.From, src,
lga.To, scratchDB.Source(),
lga.To, scratchPool.Source(),
lga.Elapsed, time.Since(start),
)

return nil
}

// ingestSheetToTable imports the sheet data into the appropriate table
// in scratchDB. The scratch table must already exist.
func ingestSheetToTable(ctx context.Context, scratchDB driver.Pool, sheetTbl *sheetTable) error {
// in scratchPool. The scratch table must already exist.
func ingestSheetToTable(ctx context.Context, scratchPool driver.Pool, sheetTbl *sheetTable) error {
var (
log = lg.FromContext(ctx)
startTime = time.Now()
Expand All @@ -183,7 +183,7 @@ func ingestSheetToTable(ctx context.Context, scratchDB driver.Pool, sheetTbl *sh
destColKinds = tblDef.ColKinds()
)

db, err := scratchDB.DB(ctx)
db, err := scratchPool.DB(ctx)
if err != nil {
return err
}
Expand All @@ -194,7 +194,7 @@ func ingestSheetToTable(ctx context.Context, scratchDB driver.Pool, sheetTbl *sh
}
defer lg.WarnIfCloseError(log, lgm.CloseDB, conn)

drvr := scratchDB.SQLDriver()
drvr := scratchPool.SQLDriver()

batchSize := driver.MaxBatchRows(drvr, len(destColKinds))
bi, err := driver.NewBatchInsert(ctx, drvr, conn, tblDef.Name, tblDef.ColNames(), batchSize)
Expand Down Expand Up @@ -264,7 +264,7 @@ func ingestSheetToTable(ctx context.Context, scratchDB driver.Pool, sheetTbl *sh
log.Debug("Inserted rows from sheet into table",
lga.Count, bi.Written(),
laSheet, sheet.name,
lga.Target, source.Target(scratchDB.Source(), tblDef.Name),
lga.Target, source.Target(scratchPool.Source(), tblDef.Name),
lga.Elapsed, time.Since(startTime))

return nil
Expand Down
6 changes: 3 additions & 3 deletions drivers/xlsx/xlsx.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ func (d *Driver) DriverMetadata() driver.Metadata {
func (d *Driver) Open(ctx context.Context, src *source.Source) (driver.Pool, error) {
lg.FromContext(ctx).Debug(lgm.OpenSrc, lga.Src, src)

scratchDB, err := d.scratcher.OpenScratch(ctx, src.Handle)
scratchPool, err := d.scratcher.OpenScratch(ctx, src.Handle)
if err != nil {
return nil, err
}

clnup := cleanup.New()
clnup.AddE(scratchDB.Close)
clnup.AddE(scratchPool.Close)

p := &pool{
log: d.log,
src: src,
scratchPool: scratchDB,
scratchPool: scratchPool,
files: d.files,
clnup: clnup,
}
Expand Down

0 comments on commit e14d564

Please sign in to comment.