martin-g commented on code in PR #19459:
URL: https://github.com/apache/datafusion/pull/19459#discussion_r2641196440
##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -1360,6 +1363,130 @@ mod tests {
Ok(())
}
+ #[test]
+ fn test_coercible_nulls() -> Result<()> {
+ fn null_input(coercion: Coercion) -> Result<Vec<DataType>> {
+ data_types(
+ "nirei",
+ &[DataType::Null],
+ &Signature::coercible(vec![coercion], Volatility::Immutable),
+ )
+ }
+
+ // Casts Null to Int64 if we use TypeSignatureClass::Native
+ let output = null_input(Coercion::new_exact(TypeSignatureClass::Native(
+ logical_int64(),
+ )))?;
+ assert_eq!(vec![DataType::Int64], output);
+
+ let output = null_input(Coercion::new_implicit(
+ TypeSignatureClass::Native(logical_int64()),
+ vec![],
+ NativeType::Int64,
+ ))?;
+ assert_eq!(vec![DataType::Int64], output);
+
+ // Null gets passed through if we use TypeSignatureClass apart from
Native
+ let output =
null_input(Coercion::new_exact(TypeSignatureClass::Integer))?;
+ assert_eq!(vec![DataType::Null], output);
+
+ let output = null_input(Coercion::new_implicit(
+ TypeSignatureClass::Integer,
+ vec![],
+ NativeType::Int64,
+ ))?;
+ assert_eq!(vec![DataType::Null], output);
+
+ Ok(())
+ }
+
+ #[test]
+ fn test_coercible_dictionary() -> Result<()> {
+ let dictionary =
+ DataType::Dictionary(Box::new(DataType::Int8),
Box::new(DataType::Int64));
+ fn dictionary_input(coercion: Coercion) -> Result<Vec<DataType>> {
+ data_types(
+ "nirei",
Review Comment:
```suggestion
"ignored",
```
##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -1360,6 +1363,130 @@ mod tests {
Ok(())
}
+ #[test]
+ fn test_coercible_nulls() -> Result<()> {
+ fn null_input(coercion: Coercion) -> Result<Vec<DataType>> {
+ data_types(
+ "nirei",
+ &[DataType::Null],
+ &Signature::coercible(vec![coercion], Volatility::Immutable),
+ )
+ }
+
+ // Casts Null to Int64 if we use TypeSignatureClass::Native
+ let output = null_input(Coercion::new_exact(TypeSignatureClass::Native(
+ logical_int64(),
+ )))?;
+ assert_eq!(vec![DataType::Int64], output);
+
+ let output = null_input(Coercion::new_implicit(
+ TypeSignatureClass::Native(logical_int64()),
+ vec![],
+ NativeType::Int64,
+ ))?;
+ assert_eq!(vec![DataType::Int64], output);
+
+ // Null gets passed through if we use TypeSignatureClass apart from
Native
+ let output =
null_input(Coercion::new_exact(TypeSignatureClass::Integer))?;
+ assert_eq!(vec![DataType::Null], output);
+
+ let output = null_input(Coercion::new_implicit(
+ TypeSignatureClass::Integer,
+ vec![],
+ NativeType::Int64,
+ ))?;
+ assert_eq!(vec![DataType::Null], output);
+
+ Ok(())
+ }
+
+ #[test]
+ fn test_coercible_dictionary() -> Result<()> {
+ let dictionary =
+ DataType::Dictionary(Box::new(DataType::Int8),
Box::new(DataType::Int64));
+ fn dictionary_input(coercion: Coercion) -> Result<Vec<DataType>> {
+ data_types(
+ "nirei",
+ &[DataType::Dictionary(
+ Box::new(DataType::Int8),
+ Box::new(DataType::Int64),
+ )],
+ &Signature::coercible(vec![coercion], Volatility::Immutable),
+ )
+ }
+
+ // Casts Dictionary to Int64 if we use TypeSignatureClass::Native
+ let output =
dictionary_input(Coercion::new_exact(TypeSignatureClass::Native(
+ logical_int64(),
+ )))?;
+ assert_eq!(vec![DataType::Int64], output);
+
+ let output = dictionary_input(Coercion::new_implicit(
+ TypeSignatureClass::Native(logical_int64()),
+ vec![],
+ NativeType::Int64,
+ ))?;
+ assert_eq!(vec![DataType::Int64], output);
+
+ // Dictionary gets passed through if we use TypeSignatureClass apart
from Native
+ let output =
dictionary_input(Coercion::new_exact(TypeSignatureClass::Integer))?;
+ assert_eq!(vec![dictionary.clone()], output);
+
+ let output = dictionary_input(Coercion::new_implicit(
+ TypeSignatureClass::Integer,
+ vec![],
+ NativeType::Int64,
+ ))?;
+ assert_eq!(vec![dictionary.clone()], output);
+
+ Ok(())
+ }
+
+ #[test]
+ fn test_coercible_run_end_encoded() -> Result<()> {
+ let run_end_encoded = DataType::RunEndEncoded(
+ Field::new("run_ends", DataType::Int16, false).into(),
+ Field::new("values", DataType::Int64, true).into(),
+ );
+ fn run_end_encoded_input(coercion: Coercion) -> Result<Vec<DataType>> {
+ data_types(
+ "nirei",
Review Comment:
```suggestion
"ignored",
```
##########
datafusion/expr/src/type_coercion/functions.rs:
##########
@@ -1360,6 +1363,130 @@ mod tests {
Ok(())
}
+ #[test]
+ fn test_coercible_nulls() -> Result<()> {
+ fn null_input(coercion: Coercion) -> Result<Vec<DataType>> {
+ data_types(
+ "nirei",
Review Comment:
```suggestion
"ignored",
```
what is `nirei` ?
--
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]