convert SQL Where clause to DNF

Sep 7, 2011 at 4:57 PM

Hi All, 

Is it possible to convert expression like WHERE clause in SQL or entire expression in FullTextSearchQueryConverter grammar to DNF? 

I.e. where f=a AND (f1 like '%tion' OR f2 != 55)  OR f3 is not null

convert to 

where f=a AND f1 like '%tion' OR f=a AND f2 != 55  OR f3 is not null

Probably it is possible somehow to do using AST during the parsing stage? AND and OR have different priorities.


Sep 8, 2011 at 1:02 AM

DNF I guess is disjunctive normal form? yes, it's possible and I don't think it's difficult. You don't even need AST I guess, you can do it directly with ParseTree - just iterate/visit nodes and generate a new tree or text. Similar to search grammar conversion, walking the tree.