sql_optimizer.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. sql_optimizer_tests = [
  2. (
  3. "select * from person where (age < 18) or (age > 60 and age < 35);",
  4. {
  5. "select_cols": [
  6. {
  7. "target": {
  8. "type": "select_all_column",
  9. "value": "select_all_column",
  10. },
  11. "type": "select_all_column",
  12. }
  13. ],
  14. "table_names": ["person"],
  15. "type": "select_stmt",
  16. "where": {
  17. "left": {"type": "identifier", "value": "age"},
  18. "op_type": "bin_cmp_op",
  19. "right": {"type": "int", "value": 18},
  20. "type": "小于",
  21. },
  22. },
  23. ),
  24. (
  25. "select * from person where (age < 18) and age < 5 and age < 35;",
  26. {
  27. "select_cols": [
  28. {
  29. "target": {
  30. "type": "select_all_column",
  31. "value": "select_all_column",
  32. },
  33. "type": "select_all_column",
  34. }
  35. ],
  36. "table_names": ["person"],
  37. "type": "select_stmt",
  38. "where": {
  39. "left": {"type": "identifier", "value": "age"},
  40. "op_type": "bin_cmp_op",
  41. "right": {"type": "int", "value": 5},
  42. "type": "小于",
  43. },
  44. },
  45. ),
  46. (
  47. "select * from person where age < 18 and (age > 5 and age > 35);",
  48. {
  49. "select_cols": [
  50. {
  51. "target": {
  52. "type": "select_all_column",
  53. "value": "select_all_column",
  54. },
  55. "type": "select_all_column",
  56. }
  57. ],
  58. "table_names": ["person"],
  59. "type": "select_stmt",
  60. "where": {"type": "bool", "value": False},
  61. },
  62. ),
  63. ]