1- module . exports = ( { _, templates, assignTemplates, getFunctionArguments, getNamePrefixedWithSchemaName } ) => {
1+ module . exports = ( {
2+ _,
3+ templates,
4+ assignTemplates,
5+ getFunctionArguments,
6+ getNamePrefixedWithSchemaName,
7+ wrapComment,
8+ } ) => {
29 const getFunctionsScript = ( schemaName , udfs ) => {
310 return _ . map ( udfs , udf => {
411 const orReplace = udf . functionOrReplace ? ' OR REPLACE' : '' ;
5-
6- return assignTemplates ( templates . createFunction , {
12+ const createFunctionStatement = assignTemplates ( templates . createFunction , {
713 name : getNamePrefixedWithSchemaName ( udf . name , schemaName ) ,
814 orReplace : orReplace ,
915 parameters : getFunctionArguments ( udf . functionArguments ) ,
@@ -12,6 +18,15 @@ module.exports = ({ _, templates, assignTemplates, getFunctionArguments, getName
1218 properties : getProperties ( udf ) ,
1319 definition : udf . functionBody ,
1420 } ) ;
21+ const commentOnFunction = udf . functionDescription
22+ ? assignTemplates ( templates . comment , {
23+ object : 'FUNCTION' ,
24+ objectName : getNamePrefixedWithSchemaName ( udf . name , schemaName ) ,
25+ comment : wrapComment ( udf . functionDescription ) ,
26+ } )
27+ : '' ;
28+
29+ return [ createFunctionStatement , commentOnFunction ] . filter ( Boolean ) . join ( '\n' ) ;
1530 } ) . join ( '\n' ) ;
1631 } ;
1732
0 commit comments