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

Column lineage should return empty array for asset and column upstream #313

Merged
merged 12 commits into from
Dec 12, 2024
14 changes: 9 additions & 5 deletions integration-tests/happy-path/expectations/asset.py.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"upstreams": [
{
"type": "asset",
"value": "chess_playground.player_summary"
"value": "chess_playground.player_summary",
"columns": []
}
],
"image": "python:3.11",
Expand Down Expand Up @@ -64,7 +65,8 @@
"upstreams": [
{
"type": "asset",
"value": "chess_playground.player_summary"
"value": "chess_playground.player_summary",
"columns": []
}
],
"image": "python:3.11",
Expand Down Expand Up @@ -181,11 +183,13 @@
"upstreams": [
{
"type": "asset",
"value": "chess_playground.games"
"value": "chess_playground.games",
"columns": []
},
{
"type": "asset",
"value": "chess_playground.profiles"
"value": "chess_playground.profiles",
"columns": []
}
],
"image": "",
Expand Down Expand Up @@ -241,4 +245,4 @@
"repo": {
"path": "/integration-tests"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"upstreams": [
{
"type": "asset",
"value": "chess_playground.player_summary"
"value": "chess_playground.player_summary",
"columns": []
}
],
"image": "python:3.11",
Expand Down Expand Up @@ -175,11 +176,13 @@
"upstreams": [
{
"type": "asset",
"value": "chess_playground.games"
"value": "chess_playground.games",
"columns": []
},
{
"type": "asset",
"value": "chess_playground.profiles"
"value": "chess_playground.profiles",
"columns": []
}
],
"image": "",
Expand All @@ -188,7 +191,7 @@
"executable_file": {
"name": "player_summary.sql",
"path": "/integration-tests/happy-path/assets/player_summary.sql",
"content": "WITH game_results AS (\n SELECT\n CASE\n WHEN g.white-\u003e\u003e'result' = 'win' THEN g.white-\u003e\u003e'@id'\n WHEN g.black-\u003e\u003e'result' = 'win' THEN g.black-\u003e\u003e'@id'\n ELSE NULL\n END AS winner_aid,\n g.white-\u003e\u003e'@id' AS white_aid,\n g.black-\u003e\u003e'@id' AS black_aid\nFROM chess_playground.games g\n)\n\nSELECT\n p.username,\n p.aid,\n COUNT(*) AS total_games,\n COUNT(CASE WHEN g.white_aid = p.aid AND g.winner_aid = p.aid THEN 1 END) AS white_wins,\n COUNT(CASE WHEN g.black_aid = p.aid AND g.winner_aid = p.aid THEN 1 END) AS black_wins,\n COUNT(CASE WHEN g.white_aid = p.aid THEN 1 END) AS white_games,\n COUNT(CASE WHEN g.black_aid = p.aid THEN 1 END) AS black_games,\n ROUND(COUNT(CASE WHEN g.white_aid = p.aid AND g.winner_aid = p.aid THEN 1 END) * 100.0 / NULLIF(COUNT(CASE WHEN g.white_aid = p.aid THEN 1 END), 0), 2) AS white_win_rate,\n ROUND(COUNT(CASE WHEN g.black_aid = p.aid AND g.winner_aid = p.aid THEN 1 END) * 100.0 / NULLIF(COUNT(CASE WHEN g.black_aid = p.aid THEN 1 END), 0), 2) AS black_win_rate\nFROM chess_playground.profiles p\nLEFT JOIN game_results g\n ON p.aid IN (g.white_aid, g.black_aid)\nGROUP BY p.username, p.aid\nORDER BY total_games DESC"
"content": "WITH game_results AS (\n SELECT\n CASE\n WHEN g.white->>'result' = 'win' THEN g.white->>'@id'\n WHEN g.black->>'result' = 'win' THEN g.black->>'@id'\n ELSE NULL\n END AS winner_aid,\n g.white->>'@id' AS white_aid,\n g.black->>'@id' AS black_aid\nFROM chess_playground.games g\n)\n\nSELECT\n p.username,\n p.aid,\n COUNT(*) AS total_games,\n COUNT(CASE WHEN g.white_aid = p.aid AND g.winner_aid = p.aid THEN 1 END) AS white_wins,\n COUNT(CASE WHEN g.black_aid = p.aid AND g.winner_aid = p.aid THEN 1 END) AS black_wins,\n COUNT(CASE WHEN g.white_aid = p.aid THEN 1 END) AS white_games,\n COUNT(CASE WHEN g.black_aid = p.aid THEN 1 END) AS black_games,\n ROUND(COUNT(CASE WHEN g.white_aid = p.aid AND g.winner_aid = p.aid THEN 1 END) * 100.0 / NULLIF(COUNT(CASE WHEN g.white_aid = p.aid THEN 1 END), 0), 2) AS white_win_rate,\n ROUND(COUNT(CASE WHEN g.black_aid = p.aid AND g.winner_aid = p.aid THEN 1 END) * 100.0 / NULLIF(COUNT(CASE WHEN g.black_aid = p.aid THEN 1 END), 0), 2) AS black_win_rate\nFROM chess_playground.profiles p\nLEFT JOIN game_results g\n ON p.aid IN (g.white_aid, g.black_aid)\nGROUP BY p.username, p.aid\nORDER BY total_games DESC"
},
"definition_file": {
"name": "player_summary.sql",
Expand Down Expand Up @@ -235,4 +238,4 @@
"repo": {
"path": "/integration-tests"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"upstreams": [
{
"type": "asset",
"value": "chess_playground.player_summary"
"value": "chess_playground.player_summary",
"columns": []
}
],
"image": "python:3.11",
Expand Down Expand Up @@ -175,11 +176,13 @@
"upstreams": [
{
"type": "asset",
"value": "chess_playground.games"
"value": "chess_playground.games",
"columns": []
},
{
"type": "asset",
"value": "chess_playground.profiles"
"value": "chess_playground.profiles",
"columns": []
}
],
"image": "",
Expand Down Expand Up @@ -235,4 +238,4 @@
"repo": {
"path": "/integration-tests"
}
}
}
9 changes: 6 additions & 3 deletions integration-tests/happy-path/expectations/pipeline.yml.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"upstreams": [
{
"type": "asset",
"value": "chess_playground.player_summary"
"value": "chess_playground.player_summary",
"columns": []
}
],
"image": "python:3.11",
Expand Down Expand Up @@ -139,11 +140,13 @@
"upstreams": [
{
"type": "asset",
"value": "chess_playground.games"
"value": "chess_playground.games",
"columns": []
},
{
"type": "asset",
"value": "chess_playground.profiles"
"value": "chess_playground.profiles",
"columns": []
}
],
"image": "",
Expand Down
17 changes: 11 additions & 6 deletions integration-tests/happy-path/expectations/player_summary.sql.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
"upstreams": [
{
"type": "asset",
"value": "chess_playground.games"
"value": "chess_playground.games",
"columns": []
},
{
"type": "asset",
"value": "chess_playground.profiles"
"value": "chess_playground.profiles",
"columns": []
}
],
"image": "",
Expand Down Expand Up @@ -86,7 +88,8 @@
"upstreams": [
{
"type": "asset",
"value": "chess_playground.player_summary"
"value": "chess_playground.player_summary",
"columns": []
}
],
"image": "python:3.11",
Expand Down Expand Up @@ -203,11 +206,13 @@
"upstreams": [
{
"type": "asset",
"value": "chess_playground.games"
"value": "chess_playground.games",
"columns": []
},
{
"type": "asset",
"value": "chess_playground.profiles"
"value": "chess_playground.profiles",
"columns": []
}
],
"image": "",
Expand Down Expand Up @@ -263,4 +268,4 @@
"repo": {
"path": "/integration-tests"
}
}
}
2 changes: 1 addition & 1 deletion pkg/pipeline/lineage.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (p *LineageExtractor) processLineageColumns(foundPipeline *Pipeline, asset
return errors.New("asset cannot be nil")
}

upstreams := []Upstream{}
upstreams := make([]Upstream, 0)
for _, up := range asset.Upstreams {
upstream := up
lineage.NonSelectedColumns = append(lineage.NonSelectedColumns, lineage.Columns...)
Expand Down
2 changes: 1 addition & 1 deletion pkg/pipeline/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ type Upstream struct {
Type string `json:"type" yaml:"type" mapstructure:"type"`
Value string `json:"value" yaml:"value" mapstructure:"value"`
Metadata EmptyStringMap `json:"metadata,omitempty" yaml:"metadata,omitempty" mapstructure:"metadata"`
Columns []DependsColumn `json:"columns,omitempty" yaml:"columns,omitempty" mapstructure:"columns"`
Columns []DependsColumn `json:"columns" yaml:"columns,omitempty" mapstructure:"columns"`
}

func (u Upstream) MarshalYAML() (interface{}, error) {
Expand Down
39 changes: 26 additions & 13 deletions pkg/pipeline/testdata/pipeline/first-pipeline_unix.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
"upstreams": [
{
"type": "asset",
"value": "gcs-to-bq"
"value": "gcs-to-bq",
"columns": []
}
]
},
Expand Down Expand Up @@ -129,27 +130,33 @@
"upstreams": [
{
"type": "asset",
"value": "task1"
"value": "task1",
"columns": []
},
{
"type": "asset",
"value": "task2"
"value": "task2",
"columns": []
},
{
"type": "asset",
"value": "task3"
"value": "task3",
"columns": []
},
{
"type": "asset",
"value": "task4"
"value": "task4",
"columns": []
},
{
"type": "asset",
"value": "task5"
"value": "task5",
"columns": []
},
{
"type": "asset",
"value": "task3"
"value": "task3",
"columns": []
}
]
},
Expand Down Expand Up @@ -188,27 +195,33 @@
"upstreams": [
{
"type": "asset",
"value": "task1"
"value": "task1",
"columns": []
},
{
"type": "asset",
"value": "task2"
"value": "task2",
"columns": []
},
{
"type": "asset",
"value": "task3"
"value": "task3",
"columns": []
},
{
"type": "asset",
"value": "task4"
"value": "task4",
"columns": []
},
{
"type": "asset",
"value": "task5"
"value": "task5",
"columns": []
},
{
"type": "asset",
"value": "task3"
"value": "task3",
"columns": []
}
]
}
Expand Down
39 changes: 26 additions & 13 deletions pkg/pipeline/testdata/pipeline/first-pipeline_windows.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"upstreams": [
{
"type": "asset",
"value": "gcs-to-bq"
"value": "gcs-to-bq",
"columns": []
}
],
"materialization": null,
Expand Down Expand Up @@ -121,27 +122,33 @@
"upstreams": [
{
"type": "asset",
"value": "task1"
"value": "task1",
"columns": []
},
{
"type": "asset",
"value": "task2"
"value": "task2",
"columns": []
},
{
"type": "asset",
"value": "task3"
"value": "task3",
"columns": []
},
{
"type": "asset",
"value": "task4"
"value": "task4",
"columns": []
},
{
"type": "asset",
"value": "task5"
"value": "task5",
"columns": []
},
{
"type": "asset",
"value": "task3"
"value": "task3",
"columns": []
}
],
"materialization": null,
Expand Down Expand Up @@ -180,27 +187,33 @@
"upstreams": [
{
"type": "asset",
"value": "task1"
"value": "task1",
"columns": []
},
{
"type": "asset",
"value": "task2"
"value": "task2",
"columns": []
},
{
"type": "asset",
"value": "task3"
"value": "task3",
"columns": []
},
{
"type": "asset",
"value": "task4"
"value": "task4",
"columns": []
},
{
"type": "asset",
"value": "task5"
"value": "task5",
"columns": []
},
{
"type": "asset",
"value": "task3"
"value": "task3",
"columns": []
}
],
"materialization": null,
Expand Down
Loading
Loading