adjacent_to_point.sql 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* syntax version 1 */
  2. /* postgres can not */
  3. /* yt can not */
  4. pragma warning("disable", "4510");
  5. -- [10, 11) -> [10, 10]
  6. select YQL::RangeComputeFor(
  7. Struct<x:UInt32>,
  8. ($row) -> ($row.x >= 10 and $row.x < 11),
  9. AsTuple(AsAtom("x"))
  10. );
  11. -- (10, 11] -> [11, 11]
  12. select YQL::RangeComputeFor(
  13. Struct<x:UInt32>,
  14. ($row) -> ($row.x > 10 and $row.x <= 11),
  15. AsTuple(AsAtom("x"))
  16. );
  17. -- dates
  18. select YQL::RangeComputeFor(
  19. Struct<x:Date??>,
  20. ($row) -> (($row.x > Date("2021-09-08") and $row.x <= Date("2021-09-09")) ?? false),
  21. AsTuple(AsAtom("x"))
  22. )
  23. , YQL::RangeComputeFor(
  24. Struct<x:Date32??>,
  25. ($row) -> (($row.x > Date("2021-09-08") and $row.x <= Date("2021-09-09")) ?? false),
  26. AsTuple(AsAtom("x"))
  27. )
  28. , YQL::RangeComputeFor(
  29. Struct<x:Date??>,
  30. ($row) -> (($row.x > Date32("2021-09-08") and $row.x <= Date32("2021-09-09")) ?? false),
  31. AsTuple(AsAtom("x"))
  32. )
  33. , YQL::RangeComputeFor(
  34. Struct<x:Date32??>,
  35. ($row) -> (($row.x > Date32("-1-12-31") and $row.x <= Date32("1-01-01")) ?? false),
  36. AsTuple(AsAtom("x"))
  37. );
  38. -- datetimes
  39. select YQL::RangeComputeFor(
  40. Struct<x:Datetime?>,
  41. ($row) -> (($row.x > Datetime("2021-09-09T12:00:00Z") and $row.x <= Datetime("2021-09-09T12:00:01Z")) ?? false),
  42. AsTuple(AsAtom("x"))
  43. )
  44. , YQL::RangeComputeFor(
  45. Struct<x:Datetime64?>,
  46. ($row) -> (($row.x > Datetime("2021-09-09T12:00:00Z") and $row.x <= Datetime("2021-09-09T12:00:01Z")) ?? false),
  47. AsTuple(AsAtom("x"))
  48. )
  49. , YQL::RangeComputeFor(
  50. Struct<x:Datetime?>,
  51. ($row) -> (($row.x > Datetime64("2021-09-09T12:00:00Z") and $row.x <= Datetime64("2021-09-09T12:00:01Z")) ?? false),
  52. AsTuple(AsAtom("x"))
  53. )
  54. , YQL::RangeComputeFor(
  55. Struct<x:Datetime64?>,
  56. ($row) -> (($row.x > Datetime64("-1-12-31T23:59:59Z") and $row.x <= Datetime64("1-01-01T00:00:00Z")) ?? false),
  57. AsTuple(AsAtom("x"))
  58. );
  59. -- timestamps
  60. select YQL::RangeComputeFor(
  61. Struct<x:Timestamp??>,
  62. ($row) -> (($row.x > Timestamp("2021-09-09T12:00:00.000000Z") and $row.x <= Timestamp("2021-09-09T12:00:00.000001Z")) ?? false),
  63. AsTuple(AsAtom("x"))
  64. )
  65. , YQL::RangeComputeFor(
  66. Struct<x:Timestamp64??>,
  67. ($row) -> (($row.x > Timestamp("2021-09-09T12:00:00.000000Z") and $row.x <= Timestamp("2021-09-09T12:00:00.000001Z")) ?? false),
  68. AsTuple(AsAtom("x"))
  69. )
  70. , YQL::RangeComputeFor(
  71. Struct<x:Timestamp??>,
  72. ($row) -> (($row.x > Timestamp64("2021-09-09T12:00:00.000000Z") and $row.x <= Timestamp64("2021-09-09T12:00:00.000001Z")) ?? false),
  73. AsTuple(AsAtom("x"))
  74. )
  75. , YQL::RangeComputeFor(
  76. Struct<x:Timestamp64??>,
  77. ($row) -> (($row.x > Timestamp64("-1-12-31T23:59:59.999999Z") and $row.x <= Timestamp64("1-01-01T00:00:00.000000Z")) ?? false),
  78. AsTuple(AsAtom("x"))
  79. );