|
|
@@ -33,6 +33,7 @@ except Exception: # pragma: no cover - exercised in environments without deps
|
|
|
PG_PATTERN_SOURCE_SYSTEM = "pg_pattern_v2"
|
|
|
TOPIC_SCOPE = "topic"
|
|
|
TOPIC_ELEMENT_SOURCE_TABLE = "post_decode_topic_point_element"
|
|
|
+ELEMENT_TYPE_DIMENSIONS = {"实质", "形式", "意图"}
|
|
|
|
|
|
_READONLY_SQL_RE = re.compile(r"^\s*(select|with|show|explain)\b", re.IGNORECASE | re.DOTALL)
|
|
|
_BLOCKED_SQL_RE = re.compile(
|
|
|
@@ -64,6 +65,11 @@ def _assert_readonly_sql(sql: str) -> None:
|
|
|
raise RuntimeError("PG Pattern repository blocked a non-read-only SQL keyword")
|
|
|
|
|
|
|
|
|
+def _is_element_type_dimension(dimension: Any) -> bool:
|
|
|
+ """Return whether an item dimension maps to pattern_mining_element.element_type."""
|
|
|
+ return dimension in ELEMENT_TYPE_DIMENSIONS
|
|
|
+
|
|
|
+
|
|
|
@contextmanager
|
|
|
def _connect_readonly():
|
|
|
if psycopg2 is None:
|
|
|
@@ -421,7 +427,7 @@ def query_element_bindings_for_items(
|
|
|
if item.get("point_type"):
|
|
|
clauses.append("point_type = %s")
|
|
|
params.append(item["point_type"])
|
|
|
- if item.get("dimension"):
|
|
|
+ if _is_element_type_dimension(item.get("dimension")):
|
|
|
clauses.append("element_type = %s")
|
|
|
params.append(item["dimension"])
|
|
|
if item.get("element_name"):
|