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