I have a requirement where in a SQL query has to be parsed and has to be traversed, and while traversing the parsed query, I have to check if some rule has met, if so need to execute some logic. There are many SQL Parsers available like ANTLR, General SQL Parser etc, which are really helpful in parsing and traversing through the query.
However, the difficulty is with the rule execution while traversing through the query. The rule could be something like, "If the query has a subquery and the subquery contains Table A joined with Table B, add/remove something in the outer query".
Execution of action on meeting a rule (add/remove something in the outer query) is secondary, we first need to be able to efficiently execute the rule checking itself.
Are there any proven patterns, or rule engines which are helpful in defining and execution of rules like above, on a SQL Query?
If the rule cannot really be expressed in a compact representation which can be persisted somewhere, and if it has to be completely programmatic, are there any proven patterns, data structures which are helpful?
I was also thinking about how database Syntax and Semantic checkers, rule based optimizers, which might have the similar functionality/requirement are implemented?
I am trying to gain some perspective.
Any information would be helpful.
Thanks & Regards,
Swathi Desai
Aucun commentaire:
Enregistrer un commentaire