Skip to content

Commit 2d3f497

Browse files
authored
Wire PPL conversion scalar functions with analytics-backend-datafusion (opensearch-project#21628)
* Wire PPL conversion scalar functions with analytics-backend-datafusion Signed-off-by: Tanik Pansuriya <panbhai@amazon.com> * Refactor conversion functions Signed-off-by: Tanik Pansuriya <panbhai@amazon.com> --------- Signed-off-by: Tanik Pansuriya <panbhai@amazon.com>
1 parent 74a2766 commit 2d3f497

16 files changed

Lines changed: 2206 additions & 7 deletions

File tree

β€Žsandbox/libs/analytics-framework/src/main/java/org/opensearch/analytics/spi/ScalarFunction.javaβ€Ž

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,21 @@ public enum ScalarFunction {
102102
REX_EXTRACT_MULTI(Category.STRING, SqlKind.OTHER_FUNCTION),
103103
REX_OFFSET(Category.STRING, SqlKind.OTHER_FUNCTION),
104104

105+
// TODO: Frontend/lang-specific functions (NUM/AUTO/MEMK/MKTIME etc.) shouldn't
106+
// live in the shared analytics-framework SPI β€” they couple the framework to PPL
107+
// vocabulary. Replace with a registration-at-startup mechanism where each frontend
108+
// supplies its own function set, keeping ScalarFunction to operators with
109+
// cross-frontend semantics (CASE, COALESCE, comparisons, etc.).
110+
NUM(Category.SCALAR, SqlKind.OTHER_FUNCTION),
111+
AUTO(Category.SCALAR, SqlKind.OTHER_FUNCTION),
112+
MEMK(Category.SCALAR, SqlKind.OTHER_FUNCTION),
113+
RMCOMMA(Category.SCALAR, SqlKind.OTHER_FUNCTION),
114+
RMUNIT(Category.SCALAR, SqlKind.OTHER_FUNCTION),
115+
DUR2SEC(Category.SCALAR, SqlKind.OTHER_FUNCTION),
116+
MSTIME(Category.SCALAR, SqlKind.OTHER_FUNCTION),
117+
CTIME(Category.SCALAR, SqlKind.OTHER_FUNCTION),
118+
MKTIME(Category.SCALAR, SqlKind.OTHER_FUNCTION),
119+
105120
// ── Cryptographic hash ─────────────────────────────────────────────
106121
// md5(x), sha1(x), sha2(x, bitLen) with bitLen ∈ {224,256,384,512}, crc32(x).
107122
MD5(Category.STRING, SqlKind.OTHER_FUNCTION),
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
//! Conversion-family UDFs grouped under one module.
10+
11+
use datafusion::execution::context::SessionContext;
12+
13+
pub mod numeric_conversion;
14+
pub mod time_conversion;
15+
pub mod tonumber;
16+
pub mod tostring;
17+
18+
/// Register every conversion-family UDF on the given session context.
19+
pub fn register_all(ctx: &SessionContext) {
20+
numeric_conversion::register_all(ctx);
21+
time_conversion::register_all(ctx);
22+
tonumber::register_all(ctx);
23+
tostring::register_all(ctx);
24+
}

0 commit comments

Comments
Β (0)