@@ -86,8 +86,10 @@ public void test() throws Exception {
8686 Assert .assertNotNull (db );
8787
8888 // create alias function
89- String createFuncStr = "create alias function db1.id_masking(bigint) with parameter(id) as concat(left(id,3),'****',right(id,4));" ;
90- CreateFunctionStmt createFunctionStmt = (CreateFunctionStmt ) UtFrameUtils .parseAndAnalyzeStmt (createFuncStr , ctx );
89+ String createFuncStr
90+ = "create alias function db1.id_masking(bigint) with parameter(id) as concat(left(id,3),'****',right(id,4));" ;
91+ CreateFunctionStmt createFunctionStmt = (CreateFunctionStmt ) UtFrameUtils .parseAndAnalyzeStmt (createFuncStr ,
92+ ctx );
9193 Env .getCurrentEnv ().createFunction (createFunctionStmt );
9294
9395 List <Function > functions = db .getFunctions ();
@@ -202,7 +204,7 @@ public void test() throws Exception {
202204 public void testCreateGlobalFunction () throws Exception {
203205 ConnectContext ctx = UtFrameUtils .createDefaultCtx ();
204206
205- //1. create database db1、db2
207+ // 1. create database db1、db2
206208 createDatabase (ctx , "create database db1;" );
207209 createDatabase (ctx , "create database db2;" );
208210
@@ -218,11 +220,12 @@ public void testCreateGlobalFunction() throws Exception {
218220 Database db = Env .getCurrentInternalCatalog ().getDbNullable ("default_cluster:db1" );
219221 Assert .assertNotNull (db );
220222
221- //2. create global function
223+ // 2. create global function
222224
223225 String createFuncStr
224226 = "create global alias function id_masking(bigint) with parameter(id) as concat(left(id,3),'****',right(id,4));" ;
225- CreateFunctionStmt createFunctionStmt = (CreateFunctionStmt ) UtFrameUtils .parseAndAnalyzeStmt (createFuncStr , ctx );
227+ CreateFunctionStmt createFunctionStmt = (CreateFunctionStmt ) UtFrameUtils .parseAndAnalyzeStmt (createFuncStr ,
228+ ctx );
226229 Env .getCurrentEnv ().createFunction (createFunctionStmt );
227230
228231 List <Function > functions = Env .getCurrentEnv ().getGlobalFunctionMgr ().getFunctions ();
@@ -235,7 +238,7 @@ public void testCreateGlobalFunction() throws Exception {
235238 Assert .assertTrue (
236239 dorisAssert .query (queryStr ).explainQuery ().contains ("concat(left(`k1`, 3), '****', right(`k1`, 4))" ));
237240
238- //4. create alias function with cast
241+ // 4. create alias function with cast
239242 // cast any type to decimal with specific precision and scale
240243 createFuncStr = "create global alias function decimal(all, int, int) with parameter(col, precision, scale)"
241244 + " as cast(col as decimal(precision, scale));" ;
@@ -255,7 +258,7 @@ public void testCreateGlobalFunction() throws Exception {
255258 Assert .assertTrue (dorisAssert .query (queryStr ).explainQuery ().contains ("CAST(`k3` AS DECIMAL(4,1))" ));
256259 }
257260
258- //5. cast any type to varchar with fixed length
261+ // 5. cast any type to varchar with fixed length
259262 createFuncStr = "create global alias function db1.varchar(all, int) with parameter(text, length) as "
260263 + "cast(text as varchar(length));" ;
261264 createFunctionStmt = (CreateFunctionStmt ) UtFrameUtils .parseAndAnalyzeStmt (createFuncStr , ctx );
@@ -270,7 +273,7 @@ public void testCreateGlobalFunction() throws Exception {
270273 queryStr = "select varchar(k1, 4) from db1.tbl1;" ;
271274 Assert .assertTrue (dorisAssert .query (queryStr ).explainQuery ().contains ("CAST(`k1` AS CHARACTER)" ));
272275
273- //6. cast any type to char with fixed length
276+ // 6. cast any type to char with fixed length
274277 createFuncStr = "create global alias function db1.char(all, int) with parameter(text, length) as "
275278 + "cast(text as char(length));" ;
276279 createFunctionStmt = (CreateFunctionStmt ) UtFrameUtils .parseAndAnalyzeStmt (createFuncStr , ctx );
@@ -287,12 +290,11 @@ public void testCreateGlobalFunction() throws Exception {
287290 }
288291
289292
290-
291293 @ Test
292294 public void testGlobalFunctionPersist () throws Exception {
293295 ConnectContext ctx = UtFrameUtils .createDefaultCtx ();
294296
295- //1. create database db1、db2
297+ // 1. create database db1、db2
296298 createDatabase (ctx , "create database db1;" );
297299
298300 createTable ("create table db1.tbl1(k1 int, k2 bigint, k3 varchar(10), k4 char(5)) duplicate key(k1) "
@@ -304,16 +306,17 @@ public void testGlobalFunctionPersist() throws Exception {
304306 Database db = Env .getCurrentInternalCatalog ().getDbNullable ("default_cluster:db1" );
305307 Assert .assertNotNull (db );
306308
307- //2. create global function
309+ // 2. create global function
308310 String createFuncStr
309311 = "create global alias function id_masking(bigint) with parameter(id) as concat(left(id,3),'****',right(id,4));" ;
310- CreateFunctionStmt createFunctionStmt = (CreateFunctionStmt ) UtFrameUtils .parseAndAnalyzeStmt (createFuncStr , ctx );
312+ CreateFunctionStmt createFunctionStmt = (CreateFunctionStmt ) UtFrameUtils .parseAndAnalyzeStmt (createFuncStr ,
313+ ctx );
311314 Env .getCurrentEnv ().createFunction (createFunctionStmt );
312315
313316 List <Function > functions = Env .getCurrentEnv ().getGlobalFunctionMgr ().getFunctions ();
314317 Assert .assertEquals (1 , functions .size ());
315318
316- //3. validate persist
319+ // 3. validate persist
317320 String imageDir = ctx .getEnv ().getImageDir ();
318321 ctx .getEnv ().saveImage ();
319322 ctx .getEnv ().loadImage (imageDir );
0 commit comments