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

database_observability: fix fetch table columns spec #2703

Merged
merged 2 commits into from
Feb 12, 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
Original file line number Diff line number Diff line change
Expand Up @@ -320,36 +320,36 @@ func (c *SchemaTable) fetchTableDefinitions(ctx context.Context, fullyQualifiedT
row := c.dbConnection.QueryRowContext(ctx, showCreateTable+" "+fullyQualifiedTable)
if err := row.Err(); err != nil {
level.Error(c.logger).Log("msg", "failed to show create table", "schema", table.schema, "table", table.tableName, "err", err)
return nil, row.Err()
return table, err
}

var tableName, createStmt, characterSetClient, collationConnection string
switch table.tableType {
case "BASE TABLE":
if err := row.Scan(&tableName, &createStmt); err != nil {
level.Error(c.logger).Log("msg", "failed to scan create table", "schema", table.schema, "table", table.tableName, "err", err)
return nil, err
return table, err
}
case "VIEW":
if err := row.Scan(&tableName, &createStmt, &characterSetClient, &collationConnection); err != nil {
level.Error(c.logger).Log("msg", "failed to scan create view", "schema", table.schema, "table", table.tableName, "err", err)
return nil, err
return table, err
}
default:
level.Error(c.logger).Log("msg", "unknown table type", append(logKVs, "table_type", table.tableType))
level.Error(c.logger).Log("msg", "unknown table type", "schema", table.schema, "table", table.tableName, "table_type", table.tableType)
return nil, fmt.Errorf("unknown table type: %s", table.tableType)
}
table.b64CreateStmt = base64.StdEncoding.EncodeToString([]byte(createStmt))

spec, err := c.fetchColumnsDefinitions(ctx, table.schema, table.tableName)
if err != nil {
level.Error(c.logger).Log("msg", "failed to analyze table spec", "schema", table.schema, "table", table.tableName, "err", err)
return nil, err
return table, err
}
jsonSpec, err := json.Marshal(spec)
if err != nil {
level.Error(c.logger).Log("msg", "failed to marshal table spec", "schema", table.schema, "table", table.tableName, "err", err)
return nil, err
return table, err
}
table.b64TableSpec = base64.StdEncoding.EncodeToString(jsonSpec)

Expand Down
Loading