Skip to content

Commit

Permalink
Pass in runner to presto/trino base (#2038)
Browse files Browse the repository at this point in the history
  • Loading branch information
whscullin authored Dec 9, 2024
1 parent 65f84f3 commit 39ec720
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions packages/malloy-db-trino/src/trino_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,33 +167,19 @@ export abstract class TrinoPrestoConnection
extends BaseConnection
implements Connection, PersistSQLResults
{
public name: string;
protected readonly dialect = new TrinoDialect();
static DEFAULT_QUERY_OPTIONS: RunSQLOptions = {
rowLimit: 10,
};

private queryOptions?: QueryOptionsReader;

//private config: TrinoConnectionConfiguration;

private client: BaseRunner;

constructor(
name: string,
queryOptions?: QueryOptionsReader,
pConfig?: TrinoConnectionConfiguration
public name: string,
private client: BaseRunner,
private queryOptions?: QueryOptionsReader
) {
super();
const config = pConfig || {};
this.name = name;
if (name === 'trino') {
this.client = new TrinoRunner(config);
} else {
this.client = new PrestoRunner(config);
}
this.queryOptions = queryOptions;
//this.config = config;
}

get dialectName(): string {
Expand Down Expand Up @@ -535,7 +521,11 @@ export class PrestoConnection extends TrinoPrestoConnection {
queryOptions?: QueryOptionsReader,
config: TrinoConnectionConfiguration = {}
) {
super('presto', queryOptions, config);
super(
typeof arg === 'string' ? arg : arg.name,
new PrestoRunner(config),
queryOptions
);
}

protected async fillStructDefForSqlBlockSchema(
Expand Down Expand Up @@ -597,7 +587,11 @@ export class TrinoConnection extends TrinoPrestoConnection {
queryOptions?: QueryOptionsReader,
config: TrinoConnectionConfiguration = {}
) {
super('trino', queryOptions, config);
super(
typeof arg === 'string' ? arg : arg.name,
new TrinoRunner(config),
queryOptions
);
}

protected async fillStructDefForSqlBlockSchema(
Expand Down

0 comments on commit 39ec720

Please sign in to comment.