Add literal contains filters across source queries and analysis context

This commit is contained in:
2026-11-13 21:23:12 +08:00
parent 7cae4cfbdf
commit 3c022e8614
20 changed files with 194 additions and 41 deletions
+6 -4
View File
@@ -3,7 +3,7 @@ import copy
DEPARTMENT_ALIASES = {'汽车交通':'新能源汽车磁钢'}
SOURCE_STAGES = {'black', 'bright'}
COLUMN_OPERATORS = {'in', 'not_in', 'is_empty', 'not_empty'}
COLUMN_OPERATORS = {'in', 'not_in', 'contains', 'is_empty', 'not_empty'}
def source_field_labels(source_fields):
@@ -35,11 +35,13 @@ def parse_column_filters(value):
raise ValueError(f'{name}.stages必须是非空black/bright数组。')
if operator not in COLUMN_OPERATORS:raise ValueError(f'{name}.operator不在当前字段支持目录中。')
clean={'field':key,'stages':list(stages),'operator':operator}
if operator in ('in','not_in'):
if operator in ('in','not_in','contains'):
values=rule.get('values')
if (not isinstance(values,list) or not 1<=len(values)<=50
or any(not isinstance(item,str) or item=='' or len(item)>256 for item in values)):
raise ValueError(f'{name}.values必须是1到50个不超过256字符的完整文本值。')
or any(not isinstance(item,str) or item==''
or operator=='contains' and not item.strip()
or len(item)>256 for item in values)):
raise ValueError(f'{name}.values必须是1到50个不超过256字符的文本值或包含关键字。')
clean['values']=list(dict.fromkeys(values))
elif 'values' in rule:raise ValueError(f'{name}的空值操作不接受values。')
result.append(clean)