Skip to content
This repository was archived by the owner on Feb 17, 2026. It is now read-only.

Commit c9a4ffa

Browse files
authored
Merge pull request #31 from muroon/specify-catalog-query-execution
Specify catalog query execution
2 parents fe293f9 + e19d1e8 commit c9a4ffa

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

conn.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,22 @@ func (c *conn) dropCTASTable(ctx context.Context, table string) func() error {
178178

179179
// startQuery starts an Athena query and returns its ID.
180180
func (c *conn) startQuery(ctx context.Context, query string) (string, error) {
181+
// resolve catalog from context, fallback to connection-level catalog
182+
catalog := c.catalog
183+
if cat, ok := getCatalog(ctx); ok {
184+
catalog = cat
185+
}
186+
187+
var catalogPtr *string
188+
if catalog != "" {
189+
catalogPtr = aws.String(catalog)
190+
}
191+
181192
resp, err := c.athena.StartQueryExecution(ctx, &athena.StartQueryExecutionInput{
182193
QueryString: aws.String(query),
183194
QueryExecutionContext: &types.QueryExecutionContext{
184195
Database: aws.String(c.db),
196+
Catalog: catalogPtr,
185197
},
186198
ResultConfiguration: &types.ResultConfiguration{
187199
OutputLocation: aws.String(c.OutputLocation),

rows_gzip.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,13 @@ func (r *rowsGzipDL) downloadCompressedData(ctx context.Context, cfg aws.Config,
162162
}
163163

164164
func (r *rowsGzipDL) getTableAsync(ctx context.Context, errCh chan error) {
165+
catalog := r.catalog
166+
if catalog == "" {
167+
catalog = CATALOG_AWS_DATA_CATALOG
168+
}
169+
165170
data, err := r.athena.GetTableMetadata(ctx, &athena.GetTableMetadataInput{
166-
CatalogName: aws.String(r.catalog),
171+
CatalogName: aws.String(catalog),
167172
DatabaseName: aws.String(r.db),
168173
TableName: aws.String(r.ctasTable),
169174
})

0 commit comments

Comments
 (0)