[15/34] incubator-madlib git commit: Mulltiple: Add grouping support for SSSP and support GPDB5

2017-06-16 Thread okislal
Mulltiple: Add grouping support for SSSP and support GPDB5

JIRA: MADLIB-1081

- This commit adds grouping support for SSSP as well as its path function.
- Update chi2 test for GPDB5 alpha compatibility.
- Decouple DROP and CREATE statements for various modules.

Closes #113


Project: http://git-wip-us.apache.org/repos/asf/incubator-madlib/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-madlib/commit/8faf6226
Tree: http://git-wip-us.apache.org/repos/asf/incubator-madlib/tree/8faf6226
Diff: http://git-wip-us.apache.org/repos/asf/incubator-madlib/diff/8faf6226

Branch: refs/heads/latest_release
Commit: 8faf62263f6c5aa4281e2d3dc33e389d41784c0e
Parents: c82b9d0
Author: Orhan Kislal 
Authored: Mon Apr 17 11:17:41 2017 -0700
Committer: Orhan Kislal 
Committed: Mon Apr 17 11:17:41 2017 -0700

--
 .../elastic_net_generate_result.py_in   |   2 +-
 .../postgres/modules/graph/graph_utils.py_in|   2 +-
 src/ports/postgres/modules/graph/sssp.py_in | 716 ++-
 src/ports/postgres/modules/graph/sssp.sql_in| 132 +++-
 .../postgres/modules/graph/test/sssp.sql_in |  75 +-
 src/ports/postgres/modules/pca/pca.py_in|   6 +-
 .../modules/stats/test/chi2_test.sql_in |   2 +-
 .../validation/internal/cross_validation.py_in  |   6 +-
 8 files changed, 739 insertions(+), 202 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-madlib/blob/8faf6226/src/ports/postgres/modules/elastic_net/elastic_net_generate_result.py_in
--
diff --git 
a/src/ports/postgres/modules/elastic_net/elastic_net_generate_result.py_in 
b/src/ports/postgres/modules/elastic_net/elastic_net_generate_result.py_in
index c48beca..6246ed9 100644
--- a/src/ports/postgres/modules/elastic_net/elastic_net_generate_result.py_in
+++ b/src/ports/postgres/modules/elastic_net/elastic_net_generate_result.py_in
@@ -81,8 +81,8 @@ def _elastic_net_generate_result(optimizer, iteration_run, 
**args):
schema_madlib=args["schema_madlib"])
 
 # Create the output table
+plpy.execute("DROP TABLE IF EXISTS {tbl_result}".format(**args))
 plpy.execute("""
- DROP TABLE IF EXISTS {tbl_result};
  CREATE TABLE {tbl_result} (
  {select_grouping_info}
  familytext,

http://git-wip-us.apache.org/repos/asf/incubator-madlib/blob/8faf6226/src/ports/postgres/modules/graph/graph_utils.py_in
--
diff --git a/src/ports/postgres/modules/graph/graph_utils.py_in 
b/src/ports/postgres/modules/graph/graph_utils.py_in
index 2d83301..25f70a5 100644
--- a/src/ports/postgres/modules/graph/graph_utils.py_in
+++ b/src/ports/postgres/modules/graph/graph_utils.py_in
@@ -72,7 +72,7 @@ def validate_graph_coding(vertex_table, vertex_id, 
edge_table, edge_params,
"""Graph {func_name}: The vertex column {vertex_id} is not 
present in vertex table ({vertex_table}) """.
format(**locals()))
_assert(columns_exist_in_table(edge_table, edge_params.values()),
-   """Graph {func_name}: Not all columns from {cols} present in 
edge table ({edge_table})""".
+   """Graph {func_name}: Not all columns from {cols} are present 
in edge table ({edge_table})""".
format(cols=edge_params.values(), **locals()))
 
return None

http://git-wip-us.apache.org/repos/asf/incubator-madlib/blob/8faf6226/src/ports/postgres/modules/graph/sssp.py_in
--
diff --git a/src/ports/postgres/modules/graph/sssp.py_in 
b/src/ports/postgres/modules/graph/sssp.py_in
index 4d27761..2520830 100644
--- a/src/ports/postgres/modules/graph/sssp.py_in
+++ b/src/ports/postgres/modules/graph/sssp.py_in
@@ -33,27 +33,56 @@ from utilities.control import MinWarning
 from utilities.utilities import _assert
 from utilities.utilities import extract_keyvalue_params
 from utilities.utilities import unique_string
-from utilities.validate_args import get_cols
-from utilities.validate_args import unquote_ident
+from utilities.utilities import _string_to_array
+from utilities.utilities import split_quoted_delimited_str
 from utilities.validate_args import table_exists
 from utilities.validate_args import columns_exist_in_table
 from utilities.validate_args import table_is_empty
+from utilities.validate_args import get_cols_and_types
+from utilities.validate_args import get_expr_type
 
 m4_changequote(`')
 
+
+def _check_groups(tbl1, tbl2, grp_list):
+
+   """
+   Helper function for joining tables with groups.
+   Args:
+   @param tbl1   Name of the first table
+   @param tbl2   Name of the second table

incubator-madlib git commit: Mulltiple: Add grouping support for SSSP and support GPDB5

2017-04-17 Thread okislal
Repository: incubator-madlib
Updated Branches:
  refs/heads/master c82b9d0ad -> 8faf62263


Mulltiple: Add grouping support for SSSP and support GPDB5

JIRA: MADLIB-1081

- This commit adds grouping support for SSSP as well as its path function.
- Update chi2 test for GPDB5 alpha compatibility.
- Decouple DROP and CREATE statements for various modules.

Closes #113


Project: http://git-wip-us.apache.org/repos/asf/incubator-madlib/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-madlib/commit/8faf6226
Tree: http://git-wip-us.apache.org/repos/asf/incubator-madlib/tree/8faf6226
Diff: http://git-wip-us.apache.org/repos/asf/incubator-madlib/diff/8faf6226

Branch: refs/heads/master
Commit: 8faf62263f6c5aa4281e2d3dc33e389d41784c0e
Parents: c82b9d0
Author: Orhan Kislal 
Authored: Mon Apr 17 11:17:41 2017 -0700
Committer: Orhan Kislal 
Committed: Mon Apr 17 11:17:41 2017 -0700

--
 .../elastic_net_generate_result.py_in   |   2 +-
 .../postgres/modules/graph/graph_utils.py_in|   2 +-
 src/ports/postgres/modules/graph/sssp.py_in | 716 ++-
 src/ports/postgres/modules/graph/sssp.sql_in| 132 +++-
 .../postgres/modules/graph/test/sssp.sql_in |  75 +-
 src/ports/postgres/modules/pca/pca.py_in|   6 +-
 .../modules/stats/test/chi2_test.sql_in |   2 +-
 .../validation/internal/cross_validation.py_in  |   6 +-
 8 files changed, 739 insertions(+), 202 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/incubator-madlib/blob/8faf6226/src/ports/postgres/modules/elastic_net/elastic_net_generate_result.py_in
--
diff --git 
a/src/ports/postgres/modules/elastic_net/elastic_net_generate_result.py_in 
b/src/ports/postgres/modules/elastic_net/elastic_net_generate_result.py_in
index c48beca..6246ed9 100644
--- a/src/ports/postgres/modules/elastic_net/elastic_net_generate_result.py_in
+++ b/src/ports/postgres/modules/elastic_net/elastic_net_generate_result.py_in
@@ -81,8 +81,8 @@ def _elastic_net_generate_result(optimizer, iteration_run, 
**args):
schema_madlib=args["schema_madlib"])
 
 # Create the output table
+plpy.execute("DROP TABLE IF EXISTS {tbl_result}".format(**args))
 plpy.execute("""
- DROP TABLE IF EXISTS {tbl_result};
  CREATE TABLE {tbl_result} (
  {select_grouping_info}
  familytext,

http://git-wip-us.apache.org/repos/asf/incubator-madlib/blob/8faf6226/src/ports/postgres/modules/graph/graph_utils.py_in
--
diff --git a/src/ports/postgres/modules/graph/graph_utils.py_in 
b/src/ports/postgres/modules/graph/graph_utils.py_in
index 2d83301..25f70a5 100644
--- a/src/ports/postgres/modules/graph/graph_utils.py_in
+++ b/src/ports/postgres/modules/graph/graph_utils.py_in
@@ -72,7 +72,7 @@ def validate_graph_coding(vertex_table, vertex_id, 
edge_table, edge_params,
"""Graph {func_name}: The vertex column {vertex_id} is not 
present in vertex table ({vertex_table}) """.
format(**locals()))
_assert(columns_exist_in_table(edge_table, edge_params.values()),
-   """Graph {func_name}: Not all columns from {cols} present in 
edge table ({edge_table})""".
+   """Graph {func_name}: Not all columns from {cols} are present 
in edge table ({edge_table})""".
format(cols=edge_params.values(), **locals()))
 
return None

http://git-wip-us.apache.org/repos/asf/incubator-madlib/blob/8faf6226/src/ports/postgres/modules/graph/sssp.py_in
--
diff --git a/src/ports/postgres/modules/graph/sssp.py_in 
b/src/ports/postgres/modules/graph/sssp.py_in
index 4d27761..2520830 100644
--- a/src/ports/postgres/modules/graph/sssp.py_in
+++ b/src/ports/postgres/modules/graph/sssp.py_in
@@ -33,27 +33,56 @@ from utilities.control import MinWarning
 from utilities.utilities import _assert
 from utilities.utilities import extract_keyvalue_params
 from utilities.utilities import unique_string
-from utilities.validate_args import get_cols
-from utilities.validate_args import unquote_ident
+from utilities.utilities import _string_to_array
+from utilities.utilities import split_quoted_delimited_str
 from utilities.validate_args import table_exists
 from utilities.validate_args import columns_exist_in_table
 from utilities.validate_args import table_is_empty
+from utilities.validate_args import get_cols_and_types
+from utilities.validate_args import get_expr_type
 
 m4_changequote(`')
 
+
+def _check_groups(tbl1, tbl2, grp_list):
+
+   """
+   Helper function for joining tables with groups.
+   Args:
+   @param tbl1