Skip to content

Commit

Permalink
Merge pull request #77 from Matts966/hotfix/ignore-resources-in-check
Browse files Browse the repository at this point in the history
Make AlphaCheck ignore tables and functions
  • Loading branch information
Matts966 authored Jan 19, 2022
2 parents e80ff48 + 584b5c3 commit c72b8f2
Show file tree
Hide file tree
Showing 122 changed files with 629 additions and 6 deletions.
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ with_functions:
--external_required_tables_output_path $$sample_path/with_functions/external_tables.txt \
> $$sample_path/with_functions/alphadag_stdout.txt 2> $$sample_path/with_functions/alphadag_stderr.txt; \
dot -Tpng $$sample_path/with_functions/dag.dot -o $$sample_path/with_functions/dag.png; \
alphacheck $$sample_path/with_functions/dag.dot \
--json_schema_path ./samples/sample-schema.json \
> $$sample_path/with_functions/alphacheck_stdout.txt 2> $$sample_path/with_functions/alphacheck_stderr.txt || echo alphacheck --with_functions $$sample_path failed; \
done;

.PHONY: with_tables
Expand All @@ -44,6 +47,9 @@ with_tables:
--external_required_tables_output_path $$sample_path/with_tables/external_tables.txt \
> $$sample_path/with_tables/alphadag_stdout.txt 2> $$sample_path/with_tables/alphadag_stderr.txt; \
dot -Tpng $$sample_path/with_tables/dag.dot -o $$sample_path/with_tables/dag.png; \
alphacheck $$sample_path/with_tables/dag.dot \
--json_schema_path ./samples/sample-schema.json \
> $$sample_path/with_tables/alphacheck_stdout.txt 2> $$sample_path/with_tables/alphacheck_stderr.txt || echo alphacheck --with_tables $$sample_path failed; \
done;

.PHONY: with_all
Expand All @@ -54,6 +60,9 @@ with_all:
--external_required_tables_output_path $$sample_path/with_all/external_tables.txt \
> $$sample_path/with_all/alphadag_stdout.txt 2> $$sample_path/with_all/alphadag_stderr.txt; \
dot -Tpng $$sample_path/with_all/dag.dot -o $$sample_path/with_all/dag.png; \
alphacheck $$sample_path/with_all/dag.dot \
--json_schema_path ./samples/sample-schema.json \
> $$sample_path/with_all/alphacheck_stdout.txt 2> $$sample_path/with_all/alphacheck_stderr.txt || echo alphacheck with all resources $$sample_path failed; \
done;

.PHONY: side_effect_first
Expand All @@ -64,15 +73,22 @@ side_effect_first:
--external_required_tables_output_path $$sample_path/side_effect_first/external_tables.txt \
> $$sample_path/side_effect_first/alphadag_stdout.txt 2> $$sample_path/side_effect_first/alphadag_stderr.txt; \
dot -Tpng $$sample_path/side_effect_first/dag.dot -o $$sample_path/side_effect_first/dag.png; \
alphacheck $$sample_path/side_effect_first/dag.dot \
--json_schema_path ./samples/sample-schema.json \
> $$sample_path/side_effect_first/alphacheck_stdout.txt 2> $$sample_path/side_effect_first/alphacheck_stderr.txt || echo alphacheck --side_effect_first $$sample_path failed; \
done;

.PHONY: side_effect_first_with_tables
side_effect_first_with_tables:
find samples -mindepth 1 -maxdepth 1 -type d | while read sample_path; do \
mkdir -p $$sample_path/side_effect_first_with_tables; \
alphadag --side_effect_first --with_tables $$sample_path --output_path $$sample_path/side_effect_first_with_tables/dag.dot \
--external_required_tables_output_path $$sample_path/side_effect_first_with_tables/external_tables.txt \
> $$sample_path/side_effect_first_with_tables/alphadag_stdout.txt 2> $$sample_path/side_effect_first_with_tables/alphadag_stderr.txt; \
dot -Tpng $$sample_path/side_effect_first_with_tables/dag.dot -o $$sample_path/side_effect_first_with_tables/dag.png; \
alphacheck $$sample_path/side_effect_first_with_tables/dag.dot \
--json_schema_path ./samples/sample-schema.json \
> $$sample_path/side_effect_first_with_tables/alphacheck_stdout.txt 2> $$sample_path/side_effect_first_with_tables/alphacheck_stderr.txt || echo alphacheck --side_effect_first --with_tables $$sample_path failed; \
done;

.PHONY: test
Expand Down
19 changes: 13 additions & 6 deletions alphasql/alphacheck.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,19 @@ struct cycle_detector : public boost::dfs_visitor<> {
bool &_has_cycle;
};

struct DotVertex {
std::string name;
std::string type;
};

bool GetExecutionPlan(const std::string dot_path,
std::vector<std::string> &execution_plan) {
using namespace boost;
typedef adjacency_list<vecS, vecS, directedS,
property<vertex_name_t, std::string>>
Graph;
typedef adjacency_list<vecS, vecS, directedS, DotVertex> Graph;
Graph g;
dynamic_properties dp(ignore_other_properties);
dp.property("label", get(vertex_name, g));
dp.property("label", get(&DotVertex::name, g));
dp.property("type", get(&DotVertex::type, g));
std::filesystem::path file_path(dot_path);
std::ifstream file(file_path, std::ios::in);
if (!boost::read_graphviz(file, g, dp)) {
Expand All @@ -374,9 +378,12 @@ bool GetExecutionPlan(const std::string dot_path,

std::list<int> result;
topological_sort(g, std::front_inserter(result));
property_map<Graph, vertex_name_t>::type names = get(vertex_name, g);
property_map<Graph, std::string DotVertex::*>::type names = get(&DotVertex::name, g);
property_map<Graph, std::string DotVertex::*>::type types = get(&DotVertex::type, g);
for (int i : result) {
execution_plan.push_back(names[i]);
if (types[i] == "query") {
execution_plan.push_back(names[i]);
}
}
return true;
}
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Analyzing "samples/create-temp-table-test/temp_table.sql"
DDL analyzed, adding table to catalog...
Removing temporary table tmp
SUCCESS: analysis finished!
Analyzing "samples/create-temp-table-test/reference.sql"
DDL analyzed, adding table to catalog...
Removing temporary table tmp
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Analyzing "samples/create-temp-table-test/temp_table.sql"
DDL analyzed, adding table to catalog...
Removing temporary table tmp
SUCCESS: analysis finished!
Analyzing "samples/create-temp-table-test/reference.sql"
DDL analyzed, adding table to catalog...
Removing temporary table tmp
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
9 changes: 9 additions & 0 deletions samples/create-temp-table-test/with_all/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Analyzing "samples/create-temp-table-test/temp_table.sql"
DDL analyzed, adding table to catalog...
Removing temporary table tmp
SUCCESS: analysis finished!
Analyzing "samples/create-temp-table-test/reference.sql"
DDL analyzed, adding table to catalog...
Removing temporary table tmp
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Analyzing "samples/create-temp-table-test/temp_table.sql"
DDL analyzed, adding table to catalog...
Removing temporary table tmp
SUCCESS: analysis finished!
Analyzing "samples/create-temp-table-test/reference.sql"
DDL analyzed, adding table to catalog...
Removing temporary table tmp
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Analyzing "samples/create-temp-table-test/temp_table.sql"
DDL analyzed, adding table to catalog...
Removing temporary table tmp
SUCCESS: analysis finished!
Analyzing "samples/create-temp-table-test/reference.sql"
DDL analyzed, adding table to catalog...
Removing temporary table tmp
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
7 changes: 7 additions & 0 deletions samples/drop-test/side_effect_first/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Analyzing "samples/drop-test/create-and-drop.sql"
DDL analyzed, adding table to catalog...
Drop Statement analyzed, dropping table from catalog...
DDL analyzed, adding table to catalog...
Drop Statement analyzed, dropping table from catalog...
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Analyzing "samples/drop-test/create-and-drop.sql"
DDL analyzed, adding table to catalog...
Drop Statement analyzed, dropping table from catalog...
DDL analyzed, adding table to catalog...
Drop Statement analyzed, dropping table from catalog...
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
7 changes: 7 additions & 0 deletions samples/drop-test/with_all/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Analyzing "samples/drop-test/create-and-drop.sql"
DDL analyzed, adding table to catalog...
Drop Statement analyzed, dropping table from catalog...
DDL analyzed, adding table to catalog...
Drop Statement analyzed, dropping table from catalog...
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
7 changes: 7 additions & 0 deletions samples/drop-test/with_functions/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Analyzing "samples/drop-test/create-and-drop.sql"
DDL analyzed, adding table to catalog...
Drop Statement analyzed, dropping table from catalog...
DDL analyzed, adding table to catalog...
Drop Statement analyzed, dropping table from catalog...
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
7 changes: 7 additions & 0 deletions samples/drop-test/with_tables/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Analyzing "samples/drop-test/create-and-drop.sql"
DDL analyzed, adding table to catalog...
Drop Statement analyzed, dropping table from catalog...
DDL analyzed, adding table to catalog...
Drop Statement analyzed, dropping table from catalog...
SUCCESS: analysis finished!
Successfully finished type check!
1 change: 1 addition & 0 deletions samples/ml/side_effect_first/alphacheck_stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ERROR: INVALID_ARGUMENT: Table not found: datawarehouse2 [at samples/ml/create_input.sql:5:3]
5 changes: 5 additions & 0 deletions samples/ml/side_effect_first/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Analyzing "samples/ml/create_input.sql"
catalog:
dataset.main
tablename1
tablename2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ERROR: INVALID_ARGUMENT: Table not found: datawarehouse2 [at samples/ml/create_input.sql:5:3]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Analyzing "samples/ml/create_input.sql"
catalog:
dataset.main
tablename1
tablename2
1 change: 1 addition & 0 deletions samples/ml/with_all/alphacheck_stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ERROR: INVALID_ARGUMENT: Table not found: datawarehouse2 [at samples/ml/create_input.sql:5:3]
5 changes: 5 additions & 0 deletions samples/ml/with_all/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Analyzing "samples/ml/create_input.sql"
catalog:
dataset.main
tablename1
tablename2
1 change: 1 addition & 0 deletions samples/ml/with_functions/alphacheck_stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ERROR: INVALID_ARGUMENT: Table not found: datawarehouse2 [at samples/ml/create_input.sql:5:3]
5 changes: 5 additions & 0 deletions samples/ml/with_functions/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Analyzing "samples/ml/create_input.sql"
catalog:
dataset.main
tablename1
tablename2
1 change: 1 addition & 0 deletions samples/ml/with_tables/alphacheck_stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ERROR: INVALID_ARGUMENT: Table not found: datawarehouse2 [at samples/ml/create_input.sql:5:3]
5 changes: 5 additions & 0 deletions samples/ml/with_tables/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Analyzing "samples/ml/create_input.sql"
catalog:
dataset.main
tablename1
tablename2
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Analyzing "samples/mutasions-and-query/mutation3.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/query1.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/mutation2.sql"
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/query3.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/mutation1.sql"
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/query2.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Analyzing "samples/mutasions-and-query/mutation3.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/query1.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/mutation2.sql"
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/query3.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/mutation1.sql"
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/query2.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
17 changes: 17 additions & 0 deletions samples/mutasions-and-query/with_all/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Analyzing "samples/mutasions-and-query/mutation3.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/query1.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/query3.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/query2.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/mutation2.sql"
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/mutation1.sql"
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
17 changes: 17 additions & 0 deletions samples/mutasions-and-query/with_functions/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Analyzing "samples/mutasions-and-query/query3.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/query2.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/mutation3.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/query1.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/mutation2.sql"
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/mutation1.sql"
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
17 changes: 17 additions & 0 deletions samples/mutasions-and-query/with_tables/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Analyzing "samples/mutasions-and-query/mutation3.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/query1.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/query3.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/query2.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/mutation2.sql"
SUCCESS: analysis finished!
Analyzing "samples/mutasions-and-query/mutation1.sql"
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Analyzing "samples/sample-any-type/dedup.sql"
Create Function Statement analyzed, adding function to catalog...
SUCCESS: analysis finished!
Analyzing "samples/sample-any-type/dedup_count.sql"
Create Function Statement analyzed, adding function to catalog...
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Analyzing "samples/sample-any-type/dedup.sql"
Create Function Statement analyzed, adding function to catalog...
SUCCESS: analysis finished!
Analyzing "samples/sample-any-type/dedup_count.sql"
Create Function Statement analyzed, adding function to catalog...
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
7 changes: 7 additions & 0 deletions samples/sample-any-type/with_all/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Analyzing "samples/sample-any-type/dedup.sql"
Create Function Statement analyzed, adding function to catalog...
SUCCESS: analysis finished!
Analyzing "samples/sample-any-type/dedup_count.sql"
Create Function Statement analyzed, adding function to catalog...
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
7 changes: 7 additions & 0 deletions samples/sample-any-type/with_functions/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Analyzing "samples/sample-any-type/dedup.sql"
Create Function Statement analyzed, adding function to catalog...
SUCCESS: analysis finished!
Analyzing "samples/sample-any-type/dedup_count.sql"
Create Function Statement analyzed, adding function to catalog...
SUCCESS: analysis finished!
Successfully finished type check!
Empty file.
7 changes: 7 additions & 0 deletions samples/sample-any-type/with_tables/alphacheck_stdout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Analyzing "samples/sample-any-type/dedup.sql"
Create Function Statement analyzed, adding function to catalog...
SUCCESS: analysis finished!
Analyzing "samples/sample-any-type/dedup_count.sql"
Create Function Statement analyzed, adding function to catalog...
SUCCESS: analysis finished!
Successfully finished type check!
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Analyzing "samples/sample-arbitrary-dependency-graph-with-drop-statement/insert_before_reference.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/sample-arbitrary-dependency-graph-with-drop-statement/insert.sql"
SUCCESS: analysis finished!
Analyzing "samples/sample-arbitrary-dependency-graph-with-drop-statement/select2.sql"
Drop Statement analyzed, dropping table from catalog...
SUCCESS: analysis finished!
Analyzing "samples/sample-arbitrary-dependency-graph-with-drop-statement/select.sql"
Drop Statement analyzed, dropping table from catalog...
SUCCESS: analysis finished!
Successfully finished type check!
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Analyzing "samples/sample-arbitrary-dependency-graph-with-drop-statement/insert_before_reference.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/sample-arbitrary-dependency-graph-with-drop-statement/insert.sql"
SUCCESS: analysis finished!
Analyzing "samples/sample-arbitrary-dependency-graph-with-drop-statement/select2.sql"
Drop Statement analyzed, dropping table from catalog...
SUCCESS: analysis finished!
Analyzing "samples/sample-arbitrary-dependency-graph-with-drop-statement/select.sql"
Drop Statement analyzed, dropping table from catalog...
SUCCESS: analysis finished!
Successfully finished type check!
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Analyzing "samples/sample-arbitrary-dependency-graph-with-drop-statement/insert_before_reference.sql"
DDL analyzed, adding table to catalog...
SUCCESS: analysis finished!
Analyzing "samples/sample-arbitrary-dependency-graph-with-drop-statement/select2.sql"
Drop Statement analyzed, dropping table from catalog...
SUCCESS: analysis finished!
Analyzing "samples/sample-arbitrary-dependency-graph-with-drop-statement/select.sql"
Drop Statement analyzed, dropping table from catalog...
SUCCESS: analysis finished!
Analyzing "samples/sample-arbitrary-dependency-graph-with-drop-statement/insert.sql"
SUCCESS: analysis finished!
Successfully finished type check!
Loading

0 comments on commit c72b8f2

Please sign in to comment.