| 300 | |
| 301 | |
| 302 | def count_component1(sql): |
| 303 | count = 0 |
| 304 | if len(sql['where']) > 0: |
| 305 | count += 1 |
| 306 | if len(sql['groupBy']) > 0: |
| 307 | count += 1 |
| 308 | if len(sql['orderBy']) > 0: |
| 309 | count += 1 |
| 310 | if sql['limit'] is not None: |
| 311 | count += 1 |
| 312 | if len(sql['from']['table_units']) > 0: # JOIN |
| 313 | count += len(sql['from']['table_units']) - 1 |
| 314 | |
| 315 | ao = sql['from']['conds'][1::2] + sql['where'][1::2] + sql['having'][1::2] |
| 316 | count += len([token for token in ao if token == 'or']) |
| 317 | cond_units = sql['from']['conds'][::2] + sql['where'][::2] + sql['having'][::2] |
| 318 | count += len([cond_unit for cond_unit in cond_units if cond_unit[1] == WHERE_OPS.index('like')]) |
| 319 | |
| 320 | return count |
| 321 | |
| 322 | |
| 323 | def count_component2(sql): |