MCPcopy Create free account
hub / github.com/apache/datafusion / test_fn_decode

Function test_fn_decode

datafusion/core/tests/dataframe/dataframe_functions.rs:1241–1267  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1239
1240#[tokio::test]
1241async fn test_fn_decode() -> Result<()> {
1242 // Note that the decode function returns binary, and the default display of
1243 // binary is "hexadecimal" and therefore the output looks like decode did
1244 // nothing. So compare to a constant.
1245 let df_schema = DFSchema::try_from(test_schema())?;
1246 let expr = decode(encode(col("a"), lit("hex")), lit("hex"))
1247 // need to cast to utf8 otherwise the default display of binary array is hex
1248 // so it looks like nothing is done
1249 .cast_to(&DataType::Utf8, &df_schema)?;
1250
1251 let batches = get_batches(expr).await?;
1252
1253 assert_snapshot!(
1254 batches_to_string(&batches),
1255 @r#"
1256 +------------------------------------------------+
1257 | decode(encode(test.a,Utf8("hex")),Utf8("hex")) |
1258 +------------------------------------------------+
1259 | abcDEF |
1260 | abc123 |
1261 | CBAdef |
1262 | 123AbcDef |
1263 +------------------------------------------------+
1264 "#);
1265
1266 Ok(())
1267}
1268
1269#[tokio::test]
1270async fn test_fn_array_to_string() -> Result<()> {

Callers

nothing calls this directly

Calls 5

get_batchesFunction · 0.85
test_schemaFunction · 0.70
colFunction · 0.50
litFunction · 0.50
cast_toMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…