Skip to content

Commit 7de565e

Browse files
committed
Move with_custom_scalar_overrides definition on Dialect trait level
1 parent 13254d2 commit 7de565e

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

datafusion/sql/src/unparser/dialect.rs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,18 @@ pub trait Dialect: Send + Sync {
153153
Ok(None)
154154
}
155155

156+
/// Extends the dialect's default rules for unparsing scalar functions.
157+
/// This is useful for supporting application-specific UDFs or custom engine extensions.
158+
fn with_custom_scalar_overrides(
159+
self,
160+
_handlers: Vec<(&str, ScalarFnToSqlHandler)>,
161+
) -> Self
162+
where
163+
Self: Sized,
164+
{
165+
unimplemented!("Custom scalar overrides are not supported by this dialect yet");
166+
}
167+
156168
/// Allow to unparse a qualified column with a full qualified name
157169
/// (e.g. catalog_name.schema_name.table_name.column_name)
158170
/// Otherwise, the column will be unparsed with only the table name and column name
@@ -320,17 +332,6 @@ impl DuckDBDialect {
320332
custom_scalar_fn_overrides: HashMap::new(),
321333
}
322334
}
323-
324-
pub fn with_custom_scalar_overrides(
325-
mut self,
326-
handlers: Vec<(&str, ScalarFnToSqlHandler)>,
327-
) -> Self {
328-
for (func_name, handler) in handlers {
329-
self.custom_scalar_fn_overrides
330-
.insert(func_name.to_string(), handler);
331-
}
332-
self
333-
}
334335
}
335336

336337
impl Dialect for DuckDBDialect {
@@ -346,6 +347,17 @@ impl Dialect for DuckDBDialect {
346347
BinaryOperator::DuckIntegerDivide
347348
}
348349

350+
fn with_custom_scalar_overrides(
351+
mut self,
352+
handlers: Vec<(&str, ScalarFnToSqlHandler)>,
353+
) -> Self {
354+
for (func_name, handler) in handlers {
355+
self.custom_scalar_fn_overrides
356+
.insert(func_name.to_string(), handler);
357+
}
358+
self
359+
}
360+
349361
fn scalar_function_to_sql_overrides(
350362
&self,
351363
unparser: &Unparser,

0 commit comments

Comments
 (0)