Skip to content

support create and drop function statement like apache hive#920

Closed
ambition119 wants to merge 5 commits intoapache:branch-1.17from
ambition119:branch-1.17
Closed

support create and drop function statement like apache hive#920
ambition119 wants to merge 5 commits intoapache:branch-1.17from
ambition119:branch-1.17

Conversation

@ambition119
Copy link
Contributor

jira links https://issues.apache.org/jira/browse/CALCITE-2663

Flink uses the calcite SQL engine. CREATE FUNCTION statement Can help create SQL functions and user-defined functions, like apache hive . Create function statemen:

CREATE [OR REPLACE] FUNCTION [IF NOT EXISTS] [db_name.]function_name AS class_name
  [USING JAR|FILE|ARCHIVE 'file_uri' [, JAR|FILE|ARCHIVE 'file_uri'] ];

DROP FUNCTION [IF EXISTS] function_name;

sample sql demo:

CREATE TABLE emp (
 id int,
 name varchar,
 birthday timestamp,
 other_info varchar
)

CREATE FUNCTION
    Date_Format AS 'org.apache.udf.DateFormat'
USING JAR 'file:/udf/udf-0.0.1-SNAPSHOT.jar';

CREATE FUNCTION
    Get_Json_Object AS 'org.apache.udf.GetJsonObject'
USING JAR 'file:/udf/udf-0.0.1-SNAPSHOT.jar';

SELECT
  count(id) as total_emp,
  Date_Format(birthday,'yyyy') as `year`,
  Get_Json_Object(Get_Json_Object(other_info,'address'),'province') as province
FROM emp
WHERE
  Date_Format(birthday,'yyyy') = '1990'
AND  
  Get_Json_Object(GetJsonObject(other_info,'address'),'province')
GROUP BY 
  `year`,
  province
;

@ambition119 ambition119 reopened this Nov 15, 2018
julianhyde pushed a commit to julianhyde/calcite that referenced this pull request Nov 16, 2018
Syntax is similar to Apache Hive's function syntax.

Close apache#908
Close apache#920
Close apache#913
@asfgit asfgit closed this in bd95645 Nov 17, 2018
F21 pushed a commit to F21/calcite that referenced this pull request Jan 3, 2019
Syntax is similar to Apache Hive's function syntax.

Close apache#908
Close apache#920
Close apache#913
wangxlong pushed a commit to wangxlong/calcite that referenced this pull request Feb 13, 2020
Syntax is similar to Apache Hive's function syntax.

Close apache#908
Close apache#920
Close apache#913
jamesstarr pushed a commit to jamesstarr/calcite that referenced this pull request Aug 28, 2025
Syntax is similar to Apache Hive's function syntax.

Close apache#908
Close apache#920
Close apache#913

Change-Id: Ib24b91e336c2c733dcdcd79de8cab8ee707abc07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant