You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Vladimir Steshin (Jira)" <ji...@apache.org> on 2025/02/05 08:23:00 UTC
[jira] [Updated] (IGNITE-24358) Calcite. User is able to override standard SQL functions.
[ https://issues.apache.org/jira/browse/IGNITE-24358?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vladimir Steshin updated IGNITE-24358:
--------------------------------------
Summary: Calcite. User is able to override standard SQL functions. (was: Calcite. User is able to override standard or system SQL functions.)
> Calcite. User is able to override standard SQL functions.
> ---------------------------------------------------------
>
> Key: IGNITE-24358
> URL: https://issues.apache.org/jira/browse/IGNITE-24358
> Project: Ignite
> Issue Type: Bug
> Reporter: Vladimir Steshin
> Priority: Major
> Labels: calcite, ignite-2, ise
> Time Spent: 10m
> Remaining Estimate: 0h
>
> We should not allow user to override standard and systems (Inginte's) SQL fucntions with UDF.
> Reproducer:
> {code:java}
> public static class OverrideSystemFunctionLibrary {
> /** Overwrites standard 'UPPER(VARCHAR)'. */
> @QuerySqlFunction
> public static int upper(String s) {
> return F.isEmpty(s) ? 0 : s.length();
> }
> /** Overwrites standard 'UNIX_SECONDS(Timestamp)'. */
> @QuerySqlFunction
> public static int unix_seconds(Timestamp ts) {
> return 1;
> }
> /** Overwrites Ignite's 'TYPEOF(Object)'. */
> @QuerySqlFunction
> public static int typeof(Object o) {
> return 1;
> }
> }
> /** */
> @Test
> public void testOverrideSystemFunction() {
> assertQuery("SELECT UPPER(?)").withParams("abc").returns("ABC").check();
> assertQuery("select UNIX_SECONDS(TIMESTAMP '2021-01-01 00:00:00')").returns(1609459200L).check();
> assertQuery("select TYPEOF(?)").withParams(1L).returns("BIGINT").check();
> client.getOrCreateCache(new CacheConfiguration<Integer, Employer>("testCache")
> .setSqlFunctionClasses(OverrideSystemFunctionLibrary.class)
> .setSqlSchema("PUBLIC")
> .setQueryEntities(F.asList(new QueryEntity(Integer.class, Employer.class).setTableName("emp")))
> );
> // Fails with 'Expected: [[ABC]], Actual: [[3]]'
> assertQuery("SELECT UPPER(?)").withParams("abc").returns("ABC").check();
> // Fails with 'Expected: [[1609459200]], Actual: [[1]]'
> assertQuery("select UNIX_SECONDS(TIMESTAMP '2021-01-01 00:00:00')").returns(1609459200L).check();
> // Fails with 'Expected: [[BIGINT]], Actual: [[1]]' or even with other assertion with '-ea'.
> assertQuery("select TYPEOF(?)").withParams(1L).returns("BIGINT").check();
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)