rxdrccq commented on code in PR #27348:
URL: https://github.com/apache/datafusion/pull/27348#discussion_r4773251571
##########
datafusion/proto/tests/cases/plans/sources.rs:
##########
@@ -61,6 +61,72 @@ use std::fmt::{Display, Formatter};
use std::sync::Arc;
use std::vec;
+#[test]
+fn parquet_decode_rejects_out_of_bounds_projection_bytes() {
+ // https://github.com/apache/datafusion/issues/27327: an empty schema with
+ // legacy projection [10] and no predicate must return an error, not panic.
+ let bytes = [0x0a, 0x06, 0x0a, 0x04, 0x12, 0x00, 0x20, 0x0a];
+ let ctx = SessionContext::new();
+ let err = datafusion_proto::bytes::physical_plan_from_bytes(&bytes,
&ctx.task_ctx())
+ .unwrap_err();
+ datafusion_common::assert_contains!(
+ err.to_string(),
+ "project index 10 out of bounds, max field 0"
+ );
+}
+
+#[test]
+fn parquet_decode_validates_legacy_projection() -> Result<()> {
+ let ctx = SessionContext::new();
+ let task_ctx = ctx.task_ctx();
+ let codec = DefaultPhysicalExtensionCodec {};
+ let schema = Arc::new(Schema::new(vec![Field::new("id", DataType::Int32,
false)]));
+
+ for with_predicate in [false, true] {
+ let mut source = ParquetSource::new(Arc::clone(&schema));
+ if with_predicate {
+ source = source.with_predicate(lit(true));
Review Comment:
Done in 22c03e4e: moved the custom-predicate codec to module level, made it
record the decode schema, and added a test with `[id, label]` and projection
`[1, 0]` that asserts the decoder sees `[label, id]`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]