| 817 | |
| 818 | |
| 819 | def count_component1(sql): |
| 820 | count = 0 |
| 821 | if len(sql['where']) > 0: |
| 822 | count += 1 |
| 823 | if len(sql['groupBy']) > 0: |
| 824 | count += 1 |
| 825 | if len(sql['orderBy']) > 0: |
| 826 | count += 1 |
| 827 | if sql['limit'] is not None: |
| 828 | count += 1 |
| 829 | if len(sql['from']['table_units']) > 0: # JOIN |
| 830 | count += len(sql['from']['table_units']) - 1 |
| 831 | |
| 832 | ao = sql['from']['conds'][1::2] + sql['where'][1::2] + sql['having'][1::2] |
| 833 | count += len([token for token in ao if token == 'or']) |
| 834 | cond_units = sql['from']['conds'][::2] + sql['where'][::2] + sql['having'][::2] |
| 835 | count += len([cond_unit for cond_unit in cond_units if cond_unit[1] == WHERE_OPS.index('like')]) |
| 836 | |
| 837 | return count |
| 838 | |
| 839 | |
| 840 | def count_component2(sql): |