This is an automated email from the ASF dual-hosted git repository.
alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 4417a9404f Minor: move `Column` related tests and rename `column.rs`
(#11573)
4417a9404f is described below
commit 4417a9404f99eeb662d887cbb12de3445eb9cd2a
Author: Jonah Gao <[email protected]>
AuthorDate: Mon Jul 22 22:23:26 2024 +0800
Minor: move `Column` related tests and rename `column.rs` (#11573)
* Minor: move `Column` related tests
* Rename column.rs to unknown_column.rs
---
.../physical-expr-common/src/expressions/column.rs | 46 +++++++++++++++++++++
datafusion/physical-expr/src/expressions/mod.rs | 4 +-
.../expressions/{column.rs => unknown_column.rs} | 48 +---------------------
3 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/datafusion/physical-expr-common/src/expressions/column.rs
b/datafusion/physical-expr-common/src/expressions/column.rs
index d972d35b9e..5397599ea2 100644
--- a/datafusion/physical-expr-common/src/expressions/column.rs
+++ b/datafusion/physical-expr-common/src/expressions/column.rs
@@ -135,3 +135,49 @@ impl Column {
pub fn col(name: &str, schema: &Schema) -> Result<Arc<dyn PhysicalExpr>> {
Ok(Arc::new(Column::new_with_schema(name, schema)?))
}
+
+#[cfg(test)]
+mod test {
+ use super::Column;
+ use crate::physical_expr::PhysicalExpr;
+
+ use arrow::array::StringArray;
+ use arrow::datatypes::{DataType, Field, Schema};
+ use arrow::record_batch::RecordBatch;
+ use datafusion_common::Result;
+
+ use std::sync::Arc;
+
+ #[test]
+ fn out_of_bounds_data_type() {
+ let schema = Schema::new(vec![Field::new("foo", DataType::Utf8,
true)]);
+ let col = Column::new("id", 9);
+ let error =
col.data_type(&schema).expect_err("error").strip_backtrace();
+ assert!("Internal error: PhysicalExpr Column references column 'id' at
index 9 (zero-based) \
+ but input schema only has 1 columns: [\"foo\"].\nThis was likely
caused by a bug in \
+ DataFusion's code and we would welcome that you file an bug report
in our issue tracker".starts_with(&error))
+ }
+
+ #[test]
+ fn out_of_bounds_nullable() {
+ let schema = Schema::new(vec![Field::new("foo", DataType::Utf8,
true)]);
+ let col = Column::new("id", 9);
+ let error =
col.nullable(&schema).expect_err("error").strip_backtrace();
+ assert!("Internal error: PhysicalExpr Column references column 'id' at
index 9 (zero-based) \
+ but input schema only has 1 columns: [\"foo\"].\nThis was likely
caused by a bug in \
+ DataFusion's code and we would welcome that you file an bug report
in our issue tracker".starts_with(&error))
+ }
+
+ #[test]
+ fn out_of_bounds_evaluate() -> Result<()> {
+ let schema = Schema::new(vec![Field::new("foo", DataType::Utf8,
true)]);
+ let data: StringArray = vec!["data"].into();
+ let batch = RecordBatch::try_new(Arc::new(schema),
vec![Arc::new(data)])?;
+ let col = Column::new("id", 9);
+ let error = col.evaluate(&batch).expect_err("error").strip_backtrace();
+ assert!("Internal error: PhysicalExpr Column references column 'id' at
index 9 (zero-based) \
+ but input schema only has 1 columns: [\"foo\"].\nThis was likely
caused by a bug in \
+ DataFusion's code and we would welcome that you file an bug report
in our issue tracker".starts_with(&error));
+ Ok(())
+ }
+}
diff --git a/datafusion/physical-expr/src/expressions/mod.rs
b/datafusion/physical-expr/src/expressions/mod.rs
index fa80bc9873..5a2bcb63b1 100644
--- a/datafusion/physical-expr/src/expressions/mod.rs
+++ b/datafusion/physical-expr/src/expressions/mod.rs
@@ -20,7 +20,6 @@
#[macro_use]
mod binary;
mod case;
-mod column;
mod in_list;
mod is_not_null;
mod is_null;
@@ -29,6 +28,7 @@ mod negative;
mod no_op;
mod not;
mod try_cast;
+mod unknown_column;
/// Module with some convenient methods used in expression building
pub mod helpers {
@@ -48,7 +48,6 @@ pub use crate::PhysicalSortExpr;
pub use binary::{binary, BinaryExpr};
pub use case::{case, CaseExpr};
-pub use column::UnKnownColumn;
pub use datafusion_expr::utils::format_state_name;
pub use datafusion_physical_expr_common::expressions::column::{col, Column};
pub use datafusion_physical_expr_common::expressions::literal::{lit, Literal};
@@ -61,3 +60,4 @@ pub use negative::{negative, NegativeExpr};
pub use no_op::NoOp;
pub use not::{not, NotExpr};
pub use try_cast::{try_cast, TryCastExpr};
+pub use unknown_column::UnKnownColumn;
diff --git a/datafusion/physical-expr/src/expressions/column.rs
b/datafusion/physical-expr/src/expressions/unknown_column.rs
similarity index 56%
rename from datafusion/physical-expr/src/expressions/column.rs
rename to datafusion/physical-expr/src/expressions/unknown_column.rs
index ab43201ceb..cb7221e7fa 100644
--- a/datafusion/physical-expr/src/expressions/column.rs
+++ b/datafusion/physical-expr/src/expressions/unknown_column.rs
@@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.
-//! Column expression
+//! UnKnownColumn expression
use std::any::Any;
use std::hash::{Hash, Hasher};
@@ -100,49 +100,3 @@ impl PartialEq<dyn Any> for UnKnownColumn {
false
}
}
-
-#[cfg(test)]
-mod test {
- use crate::expressions::Column;
- use crate::PhysicalExpr;
-
- use arrow::array::StringArray;
- use arrow::datatypes::{DataType, Field, Schema};
- use arrow::record_batch::RecordBatch;
- use datafusion_common::Result;
-
- use std::sync::Arc;
-
- #[test]
- fn out_of_bounds_data_type() {
- let schema = Schema::new(vec![Field::new("foo", DataType::Utf8,
true)]);
- let col = Column::new("id", 9);
- let error =
col.data_type(&schema).expect_err("error").strip_backtrace();
- assert!("Internal error: PhysicalExpr Column references column 'id' at
index 9 (zero-based) \
- but input schema only has 1 columns: [\"foo\"].\nThis was likely
caused by a bug in \
- DataFusion's code and we would welcome that you file an bug report
in our issue tracker".starts_with(&error))
- }
-
- #[test]
- fn out_of_bounds_nullable() {
- let schema = Schema::new(vec![Field::new("foo", DataType::Utf8,
true)]);
- let col = Column::new("id", 9);
- let error =
col.nullable(&schema).expect_err("error").strip_backtrace();
- assert!("Internal error: PhysicalExpr Column references column 'id' at
index 9 (zero-based) \
- but input schema only has 1 columns: [\"foo\"].\nThis was likely
caused by a bug in \
- DataFusion's code and we would welcome that you file an bug report
in our issue tracker".starts_with(&error))
- }
-
- #[test]
- fn out_of_bounds_evaluate() -> Result<()> {
- let schema = Schema::new(vec![Field::new("foo", DataType::Utf8,
true)]);
- let data: StringArray = vec!["data"].into();
- let batch = RecordBatch::try_new(Arc::new(schema),
vec![Arc::new(data)])?;
- let col = Column::new("id", 9);
- let error = col.evaluate(&batch).expect_err("error").strip_backtrace();
- assert!("Internal error: PhysicalExpr Column references column 'id' at
index 9 (zero-based) \
- but input schema only has 1 columns: [\"foo\"].\nThis was likely
caused by a bug in \
- DataFusion's code and we would welcome that you file an bug report
in our issue tracker".starts_with(&error));
- Ok(())
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]