From 482ef4551a4828825da8deb29d222fa82e1cfaa9 Mon Sep 17 00:00:00 2001 From: Leonardo Yvens Date: Wed, 14 Aug 2024 08:22:56 +0100 Subject: [PATCH] register get_field by default (#11959) This makes sense in principle, as all other core udfs are register by default in the context. It also has a practical use, which is executing logical plans that have field access already de-sugared into get_field invocations. --- datafusion/functions/src/core/mod.rs | 1 + datafusion/sqllogictest/test_files/struct.slt | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/datafusion/functions/src/core/mod.rs b/datafusion/functions/src/core/mod.rs index 8c5121397284..062a4a104d54 100644 --- a/datafusion/functions/src/core/mod.rs +++ b/datafusion/functions/src/core/mod.rs @@ -94,6 +94,7 @@ pub fn functions() -> Vec> { nvl2(), arrow_typeof(), named_struct(), + get_field(), coalesce(), ] } diff --git a/datafusion/sqllogictest/test_files/struct.slt b/datafusion/sqllogictest/test_files/struct.slt index 5c66bca1e0c2..f3ac6549ad06 100644 --- a/datafusion/sqllogictest/test_files/struct.slt +++ b/datafusion/sqllogictest/test_files/struct.slt @@ -72,6 +72,14 @@ select struct(a, b, c)['c1'] from values; 2.2 3.3 +# explicit invocation of get_field +query R +select get_field(struct(a, b, c), 'c1') from values; +---- +1.1 +2.2 +3.3 + # struct scalar function #1 query ? select struct(1, 3.14, 'e');