( nodeId: string, textValue: string, inputData: DBTablesNodeData, executionContext?: FlowExecutionContext, )
| 759 | } |
| 760 | |
| 761 | async function executeColumnSelectionNode( |
| 762 | nodeId: string, |
| 763 | textValue: string, |
| 764 | inputData: DBTablesNodeData, |
| 765 | executionContext?: FlowExecutionContext, |
| 766 | ): Promise<NodeExecutionResult> { |
| 767 | console.log(`ColumnSelection Node ${nodeId}: Processing "${textValue}" with input:`, inputData); |
| 768 | |
| 769 | if (!inputData || inputData.type !== "TableSelection") { |
| 770 | return { success: false, error: "Invalid input: Expected TableSelection data" }; |
| 771 | } |
| 772 | |
| 773 | const selectedColumns = textValue |
| 774 | .split("\n") |
| 775 | .filter((line) => line.trim()) |
| 776 | .map((col) => col.trim()); |
| 777 | const selectedColumnsSet = new Set(selectedColumns); |
| 778 | const columnData = [] as DBColumnSelectionTableValues[]; |
| 779 | |
| 780 | for (const tableData of inputData.tables) { |
| 781 | if ( |
| 782 | tableData.table.tableSchema && |
| 783 | tableData.table.schemaFields && |
| 784 | tableData.table.schemaFields.length != 0 |
| 785 | ) { |
| 786 | const rows = getRowsForPackedFile(tableData.table, executionContext); |
| 787 | const cellData = [] as { col: string; data: string }[]; |
| 788 | for (const row of rows) { |
| 789 | for (const cell of row) { |
| 790 | if (selectedColumnsSet.has(cell.name)) { |
| 791 | cellData.push({ col: cell.name, data: cell.resolvedKeyValue }); |
| 792 | } |
| 793 | } |
| 794 | } |
| 795 | columnData.push({ |
| 796 | tableName: tableData.name, |
| 797 | fileName: tableData.fileName, |
| 798 | sourcePack: tableData.sourceFile, |
| 799 | sourceTable: tableData.table, |
| 800 | selectedColumns: selectedColumns, |
| 801 | data: cellData, |
| 802 | } as DBColumnSelectionTableValues); |
| 803 | } |
| 804 | } |
| 805 | |
| 806 | return { |
| 807 | success: true, |
| 808 | data: { |
| 809 | type: "ColumnSelection", |
| 810 | columns: columnData, |
| 811 | sourceTables: inputData.tables, |
| 812 | selectedColumnCount: columnData.reduce((sum, table) => sum + table.selectedColumns.length, 0), |
| 813 | } as DBColumnSelectionNodeData, |
| 814 | }; |
| 815 | } |
| 816 | |
| 817 | async function executeGroupByColumnsNode( |
| 818 | nodeId: string, |
no test coverage detected