Github user decibel commented on a diff in the pull request:
https://github.com/apache/incubator-madlib/pull/89#discussion_r97463879
--- Diff: src/ports/postgres/modules/kmeans/kmeans.py_in ---
@@ -34,6 +37,25 @@ def kmeans_validate_src(schema_madlib, rel_source,
**kwargs):
# ----------------------------------------------------------------------
+def kmeans_validate_expr(schema_madlib, rel_source, expr_point, **kwargs):
+ if not columns_exist_in_table(rel_source, [expr_point]):
+
+ p = re.compile('[Aa][Rr][Rr][Aa][Yy]\s*\[\s*[\s*\w|,\s*]+\s*\]')
+
+ if p.match(expr_point.strip()):
+ view_name = unique_string('km_view')
+
+ plpy.execute(""" CREATE VIEW {view_name} AS
+ SELECT {expr_point} AS expr FROM {rel_source}
+ """.format(**locals()))
+ return view_name,True
+ else:
+ plpy.error(
--- End diff --
How does failure of the regex mean something doesn't exist in the database?
Maybe what you want is a `try:` block around the execute that returns this
error, and a separate error if the regex doesn't match? If that's the case, I
suggest changing the regex to `if not p.match(...): plpy.error()`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---