bobbai00 commented on code in PR #6009:
URL: https://github.com/apache/texera/pull/6009#discussion_r3564763409
##########
frontend/src/app/workspace/component/agent/agent-interaction/agent-interaction.component.ts:
##########
@@ -192,95 +191,34 @@ export class AgentInteractionComponent implements OnInit,
OnChanges {
}
/**
- * Get column names from sample records, placing __row_index__ first
(displayed as "Row").
+ * Get visible column names from sample rows.
*/
public getSampleColumns(): string[] {
- if (!this.sampleRecords || this.sampleRecords.length === 0) return [];
- const allKeys = Object.keys(this.sampleRecords[0]);
- const rowIndexKey = allKeys.find(k => k.startsWith("_") &&
k.includes("row_index"));
- const otherKeys = allKeys.filter(k => k !== rowIndexKey);
- return rowIndexKey ? [rowIndexKey, ...otherKeys] : otherKeys;
+ if (!this.sampleTuples || this.sampleTuples.length === 0) return [];
+ return tupleColumns(this.sampleTuples[0][1]);
}
/**
* Get display name for a column header.
*/
public getColumnDisplayName(col: string): string {
- if (col.startsWith("_") && col.includes("row_index")) return "Row";
return col;
}
Review Comment:
reverted
##########
frontend/src/app/workspace/component/agent/agent-interaction/agent-interaction.component.ts:
##########
@@ -192,95 +191,34 @@ export class AgentInteractionComponent implements OnInit,
OnChanges {
}
/**
- * Get column names from sample records, placing __row_index__ first
(displayed as "Row").
+ * Get visible column names from sample rows.
*/
public getSampleColumns(): string[] {
- if (!this.sampleRecords || this.sampleRecords.length === 0) return [];
- const allKeys = Object.keys(this.sampleRecords[0]);
- const rowIndexKey = allKeys.find(k => k.startsWith("_") &&
k.includes("row_index"));
- const otherKeys = allKeys.filter(k => k !== rowIndexKey);
- return rowIndexKey ? [rowIndexKey, ...otherKeys] : otherKeys;
+ if (!this.sampleTuples || this.sampleTuples.length === 0) return [];
+ return tupleColumns(this.sampleTuples[0][1]);
}
/**
* Get display name for a column header.
*/
public getColumnDisplayName(col: string): string {
- if (col.startsWith("_") && col.includes("row_index")) return "Row";
return col;
}
- /**
- * Parse resultStatistics into displayable column stats.
- * Each entry in resultStatistics is a JSON string with { data_type,
statistics: { ... } }.
- */
- public getParsedColumnStats(): Array<{
- column: string;
- dataType: string;
- stats: Array<{ key: string; value: string }>;
- }> {
- if (!this.resultStatistics) return [];
- const sampleCols = this.getSampleColumns().filter(c => !c.startsWith("_")
|| !c.includes("row_index"));
- const columns = sampleCols.length > 0 ? sampleCols :
Object.keys(this.resultStatistics);
- const result: Array<{ column: string; dataType: string; stats: Array<{
key: string; value: string }> }> = [];
- const excludedKeys = new Set(["count", "std", "p25", "median", "p75"]);
-
- for (const colName of columns) {
- const statsJson = this.resultStatistics[colName];
- if (!statsJson) continue;
- try {
- const parsed = JSON.parse(statsJson);
- const dataType: string = parsed.data_type ?? "unknown";
- const statistics: Record<string, any> = parsed.statistics ?? {};
- const statEntries: Array<{ key: string; value: string }> = [];
-
- for (const [key, value] of Object.entries(statistics)) {
- if (value === undefined || excludedKeys.has(key)) continue;
- if (key === "top_10" && typeof value === "object") {
- const topEntries = Object.entries(value as Record<string, any>)
- .slice(0, 5)
- .map(([k, v]) => `${k}: ${v}`)
- .join(", ");
- statEntries.push({ key: "top values", value: topEntries });
- } else if (value === null || String(value) === "null") {
- statEntries.push({ key, value: "NaN" });
- } else if (typeof value !== "object") {
- const formatted =
- typeof value === "number" && !Number.isInteger(value)
- ? Number(value.toPrecision(4)).toString()
- : String(value);
- statEntries.push({ key, value: formatted });
- }
- }
- result.push({ column: colName, dataType, stats: statEntries });
- } catch {
- // skip unparseable
- }
- }
- return result;
- }
-
- public hasColumnStats(): boolean {
- return this.getParsedColumnStats().length > 0;
- }
-
- public getDisplayRows(): Array<{ record?: Record<string, any>; isEllipsis:
boolean }> {
- if (!this.sampleRecords || this.sampleRecords.length === 0) return [];
- const rowIndexKey = Object.keys(this.sampleRecords[0]).find(k =>
k.startsWith("_") && k.includes("row_index"));
- if (!rowIndexKey) {
- return this.sampleRecords.map(r => ({ record: r, isEllipsis: false }));
- }
+ public getDisplayRows(): Array<{ rowIndex?: number; row?: Record<string,
unknown>; isEllipsis: boolean }> {
Review Comment:
changed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]