[CALCITE-7557] Linq4j.ListEnumerable.take(int) / skip(int) diverge from EnumerableDefaults on negative counts

ListEnumerable specializes take(int) and skip(int) for lists, but unlike
the adjacent BigDecimal overloads, which clamp via count.max(BigDecimal.ZERO),
the int versions pass the count straight to List.subList. A negative count
therefore threw IllegalArgumentException from take and
IndexOutOfBoundsException from skip, while the generic EnumerableDefaults
path returns an empty enumerable and the original sequence respectively.

Clamp the count to zero in both methods so that the optimized list path
agrees with the generic path. Math.max is used rather than negating the
count so that Integer.MIN_VALUE does not overflow.
2 files changed
tree: 738e14a6127beb7a847cbfbcc13dcc97d0edb8e9
  1. .github/
  2. .idea/
  3. arrow/
  4. babel/
  5. bom/
  6. buildSrc/
  7. cassandra/
  8. core/
  9. druid/
  10. elasticsearch/
  11. example/
  12. file/
  13. geode/
  14. gradle/
  15. innodb/
  16. kafka/
  17. linq4j/
  18. mongodb/
  19. pig/
  20. piglet/
  21. plus/
  22. redis/
  23. release/
  24. server/
  25. site/
  26. spark/
  27. splunk/
  28. src/
  29. testkit/
  30. ubenchmark/
  31. .asf.yaml
  32. .editorconfig
  33. .gitattributes
  34. .gitignore
  35. .mailmap
  36. .ratignore
  37. build.gradle.kts
  38. gradle.properties
  39. gradlew
  40. gradlew.bat
  41. Jenkinsfile
  42. LICENSE
  43. NOTICE
  44. README
  45. README.md
  46. SECURITY.md
  47. settings.gradle.kts
  48. sqlline
  49. sqlline.bat
  50. sqlsh
  51. sqlsh.bat
README.md

Maven Central CI Status

Apache Calcite

Apache Calcite is a dynamic data management framework.

It contains many of the pieces that comprise a typical database management system but omits the storage primitives. It provides an industry standard SQL parser and validator, a customisable optimizer with pluggable rules and cost functions, logical and physical algebraic operators, various transformation algorithms from SQL to algebra (and the opposite), and many adapters for executing SQL queries over Cassandra, Druid, Elasticsearch, MongoDB, Kafka, and others, with minimal configuration.

For more details, see the home page.

The project uses JIRA for issue tracking. For further information, please see the JIRA accounts guide.