-
Notifications
You must be signed in to change notification settings - Fork 145
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
Feature/dev check #276
Closed
Closed
Feature/dev check #276
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
50a35b2
Madpack: Add dev-check and a compact install-check.
njayaram2 d6c7834
Install-Check: Add new IC files for the lightweight testing
ArvindSridhar 93b4c91
Install-check: Consolidate multiple install check files
orhankislal 86f704f
Install-check: Fix madlib schema bug in kmeans
ArvindSridhar 4e5a30c
Update pom.xml
orhankislal File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
src/ports/postgres/modules/assoc_rules/test/assoc_rules.ic.sql_in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
/* ----------------------------------------------------------------------- *//** | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
*//* ----------------------------------------------------------------------- */ | ||
|
||
--------------------------------------------------------------------------- | ||
-- Rules: | ||
-- ------ | ||
-- 1) Any DB objects should be created w/o schema prefix, | ||
-- since this file is executed in a separate schema context. | ||
-- 2) There should be no DROP statements in this script, since | ||
-- all objects created in the default schema will be cleaned-up outside. | ||
--------------------------------------------------------------------------- | ||
|
||
--------------------------------------------------------------------------- | ||
-- Setup: | ||
--------------------------------------------------------------------------- | ||
CREATE OR REPLACE FUNCTION assoc_array_eq | ||
( | ||
arr1 TEXT[], | ||
arr2 TEXT[] | ||
) | ||
RETURNS BOOL AS $$ | ||
SELECT COUNT(*) = array_upper($1, 1) AND array_upper($1, 1) = array_upper($2, 1) | ||
FROM (SELECT unnest($1) id) t1, (SELECT unnest($2) id) t2 | ||
WHERE t1.id = t2.id; | ||
|
||
$$ LANGUAGE sql IMMUTABLE; | ||
|
||
|
||
CREATE OR REPLACE FUNCTION install_test() RETURNS VOID AS $$ | ||
declare | ||
result1 TEXT; | ||
result2 TEXT; | ||
result3 TEXT; | ||
result_maxiter TEXT; | ||
res MADLIB_SCHEMA.assoc_rules_results; | ||
output_schema TEXT; | ||
output_table TEXT; | ||
total_rules INT; | ||
total_time INTERVAL; | ||
begin | ||
DROP TABLE IF EXISTS test_data1; | ||
CREATE TABLE test_data1 ( | ||
trans_id INT | ||
, product INT | ||
); | ||
|
||
DROP TABLE IF EXISTS test_data2; | ||
CREATE TABLE test_data2 ( | ||
trans_id INT | ||
, product VARCHAR | ||
); | ||
|
||
|
||
INSERT INTO test_data1 VALUES (1,1); | ||
INSERT INTO test_data1 VALUES (1,2); | ||
INSERT INTO test_data1 VALUES (3,3); | ||
INSERT INTO test_data1 VALUES (8,4); | ||
INSERT INTO test_data1 VALUES (10,1); | ||
INSERT INTO test_data1 VALUES (10,2); | ||
INSERT INTO test_data1 VALUES (10,3); | ||
INSERT INTO test_data1 VALUES (19,2); | ||
|
||
INSERT INTO test_data2 VALUES (1, 'beer'); | ||
INSERT INTO test_data2 VALUES (1, 'diapers'); | ||
INSERT INTO test_data2 VALUES (1, 'chips'); | ||
INSERT INTO test_data2 VALUES (2, 'beer'); | ||
INSERT INTO test_data2 VALUES (2, 'diapers'); | ||
INSERT INTO test_data2 VALUES (3, 'beer'); | ||
INSERT INTO test_data2 VALUES (3, 'diapers'); | ||
INSERT INTO test_data2 VALUES (4, 'beer'); | ||
INSERT INTO test_data2 VALUES (4, 'chips'); | ||
INSERT INTO test_data2 VALUES (5, 'beer'); | ||
INSERT INTO test_data2 VALUES (6, 'beer'); | ||
INSERT INTO test_data2 VALUES (6, 'diapers'); | ||
INSERT INTO test_data2 VALUES (6, 'chips'); | ||
INSERT INTO test_data2 VALUES (7, 'beer'); | ||
INSERT INTO test_data2 VALUES (7, 'diapers'); | ||
|
||
DROP TABLE IF EXISTS test1_exp_result; | ||
CREATE TABLE test1_exp_result ( | ||
ruleid integer, | ||
pre text[], | ||
post text[], | ||
support double precision, | ||
confidence double precision, | ||
lift double precision, | ||
conviction double precision | ||
) ; | ||
|
||
DROP TABLE IF EXISTS test2_exp_result; | ||
CREATE TABLE test2_exp_result ( | ||
ruleid integer, | ||
pre text[], | ||
post text[], | ||
support double precision, | ||
confidence double precision, | ||
lift double precision, | ||
conviction double precision | ||
) ; | ||
|
||
|
||
INSERT INTO test1_exp_result VALUES (7, '{3}', '{1}', 0.20000000000000001, 0.5, 1.2499999999999998, 1.2); | ||
INSERT INTO test1_exp_result VALUES (4, '{2}', '{1}', 0.40000000000000002, 0.66666666666666674, 1.6666666666666667, 1.8000000000000003); | ||
INSERT INTO test1_exp_result VALUES (1, '{1}', '{2,3}', 0.20000000000000001, 0.5, 2.4999999999999996, 1.6000000000000001); | ||
INSERT INTO test1_exp_result VALUES (9, '{2,3}', '{1}', 0.20000000000000001, 1, 2.4999999999999996, 0); | ||
INSERT INTO test1_exp_result VALUES (6, '{1,2}', '{3}', 0.20000000000000001, 0.5, 1.2499999999999998, 1.2); | ||
INSERT INTO test1_exp_result VALUES (8, '{3}', '{2}', 0.20000000000000001, 0.5, 0.83333333333333337, 0.80000000000000004); | ||
INSERT INTO test1_exp_result VALUES (5, '{1}', '{2}', 0.40000000000000002, 1, 1.6666666666666667, 0); | ||
INSERT INTO test1_exp_result VALUES (2, '{3}', '{2,1}', 0.20000000000000001, 0.5, 1.2499999999999998, 1.2); | ||
INSERT INTO test1_exp_result VALUES (10, '{3,1}', '{2}', 0.20000000000000001, 1, 1.6666666666666667, 0); | ||
INSERT INTO test1_exp_result VALUES (3, '{1}', '{3}', 0.20000000000000001, 0.5, 1.2499999999999998, 1.2); | ||
|
||
INSERT INTO test2_exp_result VALUES (7, '{chips,diapers}', '{beer}', 0.2857142857142857, 1, 1, 0); | ||
INSERT INTO test2_exp_result VALUES (2, '{chips}', '{diapers}', 0.2857142857142857, 0.66666666666666663, 0.93333333333333324, 0.85714285714285698); | ||
INSERT INTO test2_exp_result VALUES (1, '{chips}', '{diapers,beer}', 0.2857142857142857, 0.66666666666666663, 0.93333333333333324, 0.85714285714285698); | ||
INSERT INTO test2_exp_result VALUES (6, '{diapers}', '{beer}', 0.7142857142857143, 1, 1, 0); | ||
INSERT INTO test2_exp_result VALUES (4, '{beer}', '{diapers}', 0.7142857142857143, 0.7142857142857143, 1, 1); | ||
INSERT INTO test2_exp_result VALUES (3, '{chips,beer}', '{diapers}', 0.2857142857142857, 0.66666666666666663, 0.93333333333333324, 0.85714285714285698); | ||
INSERT INTO test2_exp_result VALUES (5, '{chips}', '{beer}', 0.42857142857142855, 1, 1, 0); | ||
|
||
res = MADLIB_SCHEMA.assoc_rules (.1, .5, 'trans_id', 'product', 'test_data1','madlib_installcheck_assoc_rules', false); | ||
|
||
RETURN; | ||
|
||
end $$ language plpgsql; | ||
|
||
--------------------------------------------------------------------------- | ||
-- Test | ||
--------------------------------------------------------------------------- | ||
SELECT install_test(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* ----------------------------------------------------------------------- *//** | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
*//* ----------------------------------------------------------------------- */ | ||
|
||
--------------------------------------------------------------------------- | ||
-- Rules: | ||
-- ------ | ||
-- 1) Any DB objects should be created w/o schema prefix, | ||
-- since this file is executed in a separate schema context. | ||
-- 2) There should be no DROP statements in this script, since | ||
-- all objects created in the default schema will be cleaned-up outside. | ||
--------------------------------------------------------------------------- | ||
|
||
--------------------------------------------------------------------------- | ||
-- Setup: | ||
--------------------------------------------------------------------------- | ||
CREATE OR REPLACE FUNCTION fill_feature(pre_class INT, p FLOAT, total INT) | ||
RETURNS FLOAT AS $$ | ||
declare | ||
result FLOAT; | ||
thres INT; | ||
begin | ||
thres = total*p; | ||
|
||
IF pre_class <= thres THEN | ||
result = 1; | ||
ELSE | ||
result = 0; | ||
END IF; | ||
RETURN result; | ||
end | ||
$$ language plpgsql; | ||
|
||
-- ---------------- | ||
-- install_test_1() | ||
-- ---------------- | ||
CREATE FUNCTION install_test_1() RETURNS VOID AS $$ | ||
declare | ||
num1 INT := 10; | ||
num2 INT := 10; | ||
|
||
result1 INT; | ||
count1 INT; | ||
tempvar INT[]; | ||
|
||
begin | ||
-- prepare training data: equal priors | ||
--DROP TABLE IF EXISTS data CASCADE; | ||
CREATE TABLE data_1( class INT, attrib FLOAT[] ); | ||
INSERT INTO data_1 SELECT 1, ARRAY[fill_feature(id,0.3,num1),fill_feature(id,0.8,num1)] FROM generate_series(1,num1) as id; | ||
INSERT INTO data_1 SELECT 2, ARRAY[fill_feature(id,0.5,num2),fill_feature(id,0.5,num2)] FROM generate_series(1,num2) as id; | ||
|
||
-- prepare testing data | ||
--DROP TABLE IF EXISTS data_test CASCADE; | ||
CREATE TABLE data_test_1( id INT, attrib INT[], prob FLOAT[] ); | ||
INSERT INTO data_test_1 VALUES (1,'{0,0}','{0.4,0.6}'); | ||
INSERT INTO data_test_1 VALUES (2,'{0,1}','{0.66666,0.33333}'); | ||
INSERT INTO data_test_1 VALUES (3,'{1,0}','{0.25,0.75}'); | ||
INSERT INTO data_test_1 VALUES (4,'{1,1}','{0.5,0.5}'); | ||
|
||
-- prepare true results for testing data | ||
--DROP TABLE IF EXISTS data_results; | ||
CREATE TABLE data_results_1 AS | ||
SELECT | ||
id, | ||
unnest('{1,2}'::INT[]) as class, | ||
unnest(prob) as prob | ||
FROM data_test_1; | ||
|
||
-- Process training | ||
--DROP TABLE IF EXISTS probs CASCADE; | ||
--DROP TABLE IF EXISTS priors CASCADE; | ||
PERFORM MADLIB_SCHEMA.create_nb_prepared_data_tables('data_1','class','attrib',2,'probs','priors'); | ||
-- Classify | ||
--DROP VIEW IF EXISTS results; | ||
PERFORM MADLIB_SCHEMA.create_nb_classify_view('probs','priors','data_test_1','id','attrib',2,'results_1'); | ||
-- Compute posteriors | ||
--DROP VIEW IF EXISTS probs_view; | ||
PERFORM MADLIB_SCHEMA.create_nb_probs_view('probs','priors','data_test_1','id','attrib',2,'probs_view_1'); | ||
|
||
|
||
end | ||
$$ language plpgsql; | ||
|
||
--------------------------------------------------------------------------- | ||
-- Test: | ||
--------------------------------------------------------------------------- | ||
SELECT install_test_1(); |
65 changes: 65 additions & 0 deletions
65
src/ports/postgres/modules/conjugate_gradient/test/conj_grad.ic.sql_in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* ----------------------------------------------------------------------- *//** | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
*//* ----------------------------------------------------------------------- */ | ||
|
||
--------------------------------------------------------------------------- | ||
-- Rules: | ||
-- ------ | ||
-- 1) Any DB objects should be created w/o schema prefix, | ||
-- since this file is executed in a separate schema context. | ||
-- 2) There should be no DROP statements in this script, since | ||
-- all objects created in the default schema will be cleaned-up outside. | ||
--------------------------------------------------------------------------- | ||
|
||
--------------------------------------------------------------------------- | ||
-- Setup: | ||
--------------------------------------------------------------------------- | ||
CREATE FUNCTION install_test() RETURNS VOID AS $$ | ||
declare | ||
result float; | ||
x FLOAT[]; | ||
|
||
begin | ||
CREATE TABLE A( | ||
row INT, | ||
val FLOAT[] | ||
); | ||
|
||
INSERT INTO A VALUES(1, ARRAY[1.0175001, 0.45604107, 0.32282152, 0.25168270, 0.20694042, 0.17602822, 0.15331823, 0.13589278, 0.12208089, 0.11085359]); | ||
INSERT INTO A VALUES(2, ARRAY[0.4560411, 0.48234387, 0.21190993, 0.17177051, 0.14528005, 0.12627935, 0.11189286, 0.10057578, 0.09141562, 0.08383503]); | ||
INSERT INTO A VALUES(3, ARRAY[0.3228215, 0.21190993, 0.36372483, 0.13511499, 0.11570299, 0.10149569, 0.09057135, 0.08187212, 0.07476054, 0.06882649]); | ||
INSERT INTO A VALUES(4, ARRAY[0.2516827, 0.17177051, 0.13511499, 0.31270305, 0.09720943, 0.08572070, 0.07680054, 0.06964365, 0.06375766, 0.05882206]); | ||
INSERT INTO A VALUES(5, ARRAY[0.2069404, 0.14528005, 0.11570299, 0.09720943, 0.28424848, 0.07454783, 0.06696472, 0.06084900, 0.05579869, 0.05154975]); | ||
INSERT INTO A VALUES(6, ARRAY[0.1760282, 0.12627935, 0.10149569, 0.08572070, 0.07454783, 0.26612646, 0.05951006, 0.05415360, 0.04971703, 0.04597544]); | ||
INSERT INTO A VALUES(7, ARRAY[0.1533182, 0.11189286, 0.09057135, 0.07680054, 0.06696472, 0.05951006, 0.25363014, 0.04885589, 0.04489247, 0.04154376]); | ||
INSERT INTO A VALUES(8, ARRAY[0.1358928, 0.10057578, 0.08187212, 0.06964365, 0.06084900, 0.05415360, 0.04885589, 0.24454426, 0.04095839, 0.03792426]); | ||
INSERT INTO A VALUES(9, ARRAY[0.1220809, 0.09141562, 0.07476054, 0.06375766, 0.05579869, 0.04971703, 0.04489247, 0.04095839, 0.23768165, 0.03490583]); | ||
INSERT INTO A VALUES(10,ARRAY[0.1108536, 0.08383503, 0.06882649, 0.05882206, 0.05154975, 0.04597544, 0.04154376, 0.03792426, 0.03490583, 0.23234632]); | ||
|
||
SELECT INTO x MADLIB_SCHEMA.conjugate_gradient('A', 'val', 'row', ARRAY(SELECT random() FROM generate_series(1,10)), .000001,2); | ||
result = x[1]*x[1]; | ||
RETURN; | ||
end | ||
$$ language plpgsql; | ||
|
||
--------------------------------------------------------------------------- | ||
-- Test | ||
--------------------------------------------------------------------------- | ||
SELECT install_test(); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe if you use
*[!ic].sql_in
in the dev-check glob expression, it will exclude the ic files. You won't need these lines if that works.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great, will try it out.