001package gudusoft.gsqlparser.dlineage.dataflow.model; 002 003import java.util.*; 004 005/** 006 * Captures the output row structure and per-column upstream lineage of a pipelined table function. 007 * This is the single source of truth for all stitching operations. 008 */ 009public class PipelinedFunctionSignature { 010 private String functionKey; 011 private String nakedKey; 012 private String procedureKey; 013 private String rowTypeKey; 014 private String collectionTypeKey; 015 private int argCount; 016 private boolean pipelined; 017 private boolean resolved; 018 private ResolutionStatus status; 019 private List<String> outputColumns; 020 private Map<String, List<PipelinedSourceRef>> lineageByOutputColumn; 021 022 public enum ResolutionStatus { 023 OK, AMBIGUOUS, UNRESOLVED, SKIPPED 024 } 025 026 public PipelinedFunctionSignature() { 027 this.outputColumns = new ArrayList<>(); 028 this.lineageByOutputColumn = new LinkedHashMap<>(); 029 this.status = ResolutionStatus.UNRESOLVED; 030 this.resolved = false; 031 this.pipelined = true; 032 } 033 034 public String getFunctionKey() { 035 return functionKey; 036 } 037 038 public void setFunctionKey(String functionKey) { 039 this.functionKey = functionKey; 040 } 041 042 public String getNakedKey() { 043 return nakedKey; 044 } 045 046 public void setNakedKey(String nakedKey) { 047 this.nakedKey = nakedKey; 048 } 049 050 public String getProcedureKey() { 051 return procedureKey; 052 } 053 054 public void setProcedureKey(String procedureKey) { 055 this.procedureKey = procedureKey; 056 } 057 058 public String getRowTypeKey() { 059 return rowTypeKey; 060 } 061 062 public void setRowTypeKey(String rowTypeKey) { 063 this.rowTypeKey = rowTypeKey; 064 } 065 066 public String getCollectionTypeKey() { 067 return collectionTypeKey; 068 } 069 070 public void setCollectionTypeKey(String collectionTypeKey) { 071 this.collectionTypeKey = collectionTypeKey; 072 } 073 074 public int getArgCount() { 075 return argCount; 076 } 077 078 public void setArgCount(int argCount) { 079 this.argCount = argCount; 080 } 081 082 public boolean isPipelined() { 083 return pipelined; 084 } 085 086 public void setPipelined(boolean pipelined) { 087 this.pipelined = pipelined; 088 } 089 090 public boolean isResolved() { 091 return resolved; 092 } 093 094 public void setResolved(boolean resolved) { 095 this.resolved = resolved; 096 } 097 098 public ResolutionStatus getStatus() { 099 return status; 100 } 101 102 public void setStatus(ResolutionStatus status) { 103 this.status = status; 104 } 105 106 public List<String> getOutputColumns() { 107 return outputColumns; 108 } 109 110 public void setOutputColumns(List<String> outputColumns) { 111 this.outputColumns = outputColumns; 112 } 113 114 public Map<String, List<PipelinedSourceRef>> getLineageByOutputColumn() { 115 return lineageByOutputColumn; 116 } 117 118 public void addSourceRef(String outputColumnNormalized, PipelinedSourceRef ref) { 119 lineageByOutputColumn.computeIfAbsent(outputColumnNormalized, k -> new ArrayList<>()).add(ref); 120 } 121 122 @Override 123 public String toString() { 124 return "PipelinedFunctionSignature{" + functionKey + ", cols=" + outputColumns.size() 125 + ", resolved=" + resolved + ", status=" + status + "}"; 126 } 127}