Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make schema explain shareable #2101

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions packages/malloy-db-trino/src/trino_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,17 +439,10 @@ export class PrestoConnection extends TrinoPrestoConnection {
);
}

protected async fillStructDefForSqlBlockSchema(
sql: string,
structDef: StructDef
): Promise<void> {
const explainResult = await this.runSQL(`EXPLAIN ${sql}`, {});
this.schemaFromExplain(explainResult, structDef);
}

protected schemaFromExplain(
static schemaFromExplain(
explainResult: MalloyQueryData,
structDef: StructDef
structDef: StructDef,
dialect: Dialect
) {
if (explainResult.rows.length === 0) {
throw new Error(
Expand All @@ -474,10 +467,18 @@ export class PrestoConnection extends TrinoPrestoConnection {
);
}

const schemaDesc = new TrinoPrestoSchemaParser(lines[0], this.dialect);
const schemaDesc = new TrinoPrestoSchemaParser(lines[0], dialect);
structDef.fields = schemaDesc.parseQueryPlan();
}

protected async fillStructDefForSqlBlockSchema(
sql: string,
structDef: StructDef
): Promise<void> {
const explainResult = await this.runSQL(`EXPLAIN ${sql}`, {});
PrestoConnection.schemaFromExplain(explainResult, structDef, this.dialect);
}

unpackArray(data: unknown): unknown[] {
return JSON.parse(data as string);
}
Expand Down
Loading