From d000ceda5b102bd60120d23da99a60cf155e3ac4 Mon Sep 17 00:00:00 2001 From: Bing Li <63471091+sfc-gh-bli@users.noreply.github.com> Date: Tue, 23 Jul 2024 16:25:18 -0700 Subject: [PATCH] SNOW-1361405 Emit Span for UDx (#122) * create methodChain * alias * rollup * groupByGroupingSets * limit * na * chain * add method chain * update * update test * fix test * fix test * fix test * fix test * fix test * reformat * fix test * rename * temp udf * temp udf * temp udf * perm udf * session.udf * udf * udtf * sproc * sproc * setup Java * temp2 * fix test * udf * table function * sproc * sproc * fix test * fix test * fix test --- .../snowflake/snowpark_java/Functions.java | 81 +- .../snowpark_java/SProcRegistration.java | 1669 ++++++++++------- .../snowpark_java/UDFRegistration.java | 1118 +++++++---- .../snowpark_java/UDTFRegistration.java | 33 +- .../snowpark/SProcRegistration.scala | 554 +++--- .../snowflake/snowpark/UDFRegistration.scala | 512 ++--- .../snowflake/snowpark/UDTFRegistration.scala | 27 +- .../com/snowflake/snowpark/functions.scala | 97 +- .../snowpark/internal/OpenTelemetry.scala | 146 +- .../internal/UDXRegistrationHandler.scala | 14 +- .../JavaUDTFNonStoredProcSuite.java | 2 + .../JavaUDXOpenTelemetryEnabled.java | 58 + .../JavaUDXOpenTelemetrySuite.java | 121 ++ .../com/snowflake/snowpark/JavaAPISuite.scala | 4 + .../snowpark/OpenTelemetryEnabled.scala | 23 + .../com/snowflake/snowpark/TestUtils.scala | 12 +- .../snowpark_test/UdxOpenTelemetrySuite.scala | 117 ++ 17 files changed, 2868 insertions(+), 1720 deletions(-) create mode 100644 src/test/java/com/snowflake/snowpark_test/JavaUDXOpenTelemetryEnabled.java create mode 100644 src/test/java/com/snowflake/snowpark_test/JavaUDXOpenTelemetrySuite.java create mode 100644 src/test/scala/com/snowflake/snowpark_test/UdxOpenTelemetrySuite.scala diff --git a/src/main/java/com/snowflake/snowpark_java/Functions.java b/src/main/java/com/snowflake/snowpark_java/Functions.java index 0515164a..f3fb46eb 100644 --- a/src/main/java/com/snowflake/snowpark_java/Functions.java +++ b/src/main/java/com/snowflake/snowpark_java/Functions.java @@ -1,9 +1,12 @@ package com.snowflake.snowpark_java; +import static com.snowflake.snowpark.internal.OpenTelemetry.javaUDF; + import com.snowflake.snowpark.internal.JavaUtils; import com.snowflake.snowpark_java.types.DataType; import com.snowflake.snowpark_java.udf.*; import java.util.List; +import java.util.function.Supplier; /** * Provides utility functions that generate Column expression that you can pass to DataFrame @@ -3912,8 +3915,8 @@ public static Column callUDF(String udfName, Column... cols) { // |* @return The result UserDefinedFunction reference // |*/ // |public static UserDefinedFunction udf(JavaUDF$x<$types> func,$input DataType output) { - // | return getActiveSession().udf() - // | .registerTemporary(func,${if(x == 0) "" else " input,"} output); + // | return userDefinedFunction("udf", () -> getActiveSession().udf() + // | .registerTemporary(func,${if(x == 0) "" else " input,"} output)); // |} // |""".stripMargin) // } @@ -3927,7 +3930,8 @@ public static Column callUDF(String udfName, Column... cols) { * @return The result UserDefinedFunction reference */ public static UserDefinedFunction udf(JavaUDF0 func, DataType output) { - return getActiveSession().udf().registerTemporary(func, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, output)); } /** @@ -3940,7 +3944,8 @@ public static UserDefinedFunction udf(JavaUDF0 func, DataType output) { * @return The result UserDefinedFunction reference */ public static UserDefinedFunction udf(JavaUDF1 func, DataType input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -3953,7 +3958,8 @@ public static UserDefinedFunction udf(JavaUDF1 func, DataType input, DataT * @return The result UserDefinedFunction reference */ public static UserDefinedFunction udf(JavaUDF2 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -3967,7 +3973,8 @@ public static UserDefinedFunction udf(JavaUDF2 func, DataType[] input, */ public static UserDefinedFunction udf( JavaUDF3 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -3981,7 +3988,8 @@ public static UserDefinedFunction udf( */ public static UserDefinedFunction udf( JavaUDF4 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -3995,7 +4003,8 @@ public static UserDefinedFunction udf( */ public static UserDefinedFunction udf( JavaUDF5 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4009,7 +4018,8 @@ public static UserDefinedFunction udf( */ public static UserDefinedFunction udf( JavaUDF6 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4023,7 +4033,8 @@ public static UserDefinedFunction udf( */ public static UserDefinedFunction udf( JavaUDF7 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4037,7 +4048,8 @@ public static UserDefinedFunction udf( */ public static UserDefinedFunction udf( JavaUDF8 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4051,7 +4063,8 @@ public static UserDefinedFunction udf( */ public static UserDefinedFunction udf( JavaUDF9 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4065,7 +4078,8 @@ public static UserDefinedFunction udf( */ public static UserDefinedFunction udf( JavaUDF10 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4079,7 +4093,8 @@ public static UserDefinedFunction udf( */ public static UserDefinedFunction udf( JavaUDF11 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4093,7 +4108,8 @@ public static UserDefinedFunction udf( */ public static UserDefinedFunction udf( JavaUDF12 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4107,7 +4123,8 @@ public static UserDefinedFunction udf( */ public static UserDefinedFunction udf( JavaUDF13 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4123,7 +4140,8 @@ public static UserDefinedFunction udf( JavaUDF14 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4139,7 +4157,8 @@ public static UserDefinedFunction udf( JavaUDF15 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4155,7 +4174,8 @@ public static UserDefinedFunction udf( JavaUDF16 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4171,7 +4191,8 @@ public static UserDefinedFunction udf( JavaUDF17 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4187,7 +4208,8 @@ public static UserDefinedFunction udf( JavaUDF18 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4203,7 +4225,8 @@ public static UserDefinedFunction udf( JavaUDF19 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4219,7 +4242,8 @@ public static UserDefinedFunction udf( JavaUDF20 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4235,7 +4259,8 @@ public static UserDefinedFunction udf( JavaUDF21 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } /** @@ -4251,10 +4276,16 @@ public static UserDefinedFunction udf( JavaUDF22 func, DataType[] input, DataType output) { - return getActiveSession().udf().registerTemporary(func, input, output); + return userDefinedFunction( + "udf", () -> getActiveSession().udf().registerTemporary(func, input, output)); } private static Session getActiveSession() { return new Session(JavaUtils.getActiveSession()); } + + private static UserDefinedFunction userDefinedFunction( + String funcName, Supplier func) { + return javaUDF("Functions", funcName, "", "", 0, func); + } } diff --git a/src/main/java/com/snowflake/snowpark_java/SProcRegistration.java b/src/main/java/com/snowflake/snowpark_java/SProcRegistration.java index c3506671..acb6c9e4 100644 --- a/src/main/java/com/snowflake/snowpark_java/SProcRegistration.java +++ b/src/main/java/com/snowflake/snowpark_java/SProcRegistration.java @@ -1,5 +1,7 @@ package com.snowflake.snowpark_java; +import static com.snowflake.snowpark.internal.OpenTelemetry.javaSProc; + import com.snowflake.snowpark.PublicPreview; import com.snowflake.snowpark.internal.ErrorMessage; import com.snowflake.snowpark.internal.JavaUtils; @@ -7,6 +9,7 @@ import com.snowflake.snowpark_java.internal.JavaSProc; import com.snowflake.snowpark_java.sproc.*; import com.snowflake.snowpark_java.types.DataType; +import java.util.function.Supplier; /** * Provides methods to register a SProc (Stored Procedure) in the Snowflake database. @@ -79,42 +82,39 @@ public class SProcRegistration { } // Code below for registerPermanent 0-21 generated by this script - // (0 to 21).foreach { x => + // (0 to 21).foreach { x => // val types = (1 to x).foldLeft("?")((i, _) => {s"$i, ?"}) // val (input, doc) = x match { // case 0 => ("", "") // case 1 => (" DataType input,", "@param input the SProc input {@code types.DataType}") // case _ => (" DataType[] input,", "@param input the SProc input {@code types.DataType}s") // } - // val s = if(x > 1) "s" else "" - // val arg = if(x > 0) " UDFRegistration.convertDataType(input)," else "" + // val s = if (x > 1) "s" else "" + // val arg = if (x > 0) " UDFRegistration.convertDataType(input)," else "" // println(s""" - // |/** - // | * Registers a Java Lambda of $x argument$s as a permanent Snowflake Stored Procedure. - // | * - // | *

The function uploads the JAR files that the stored procedure depdends upon to the - // | * specified stage. - // | * - // | * @since 1.8.0 - // | * @param name the name of the stored procedure being registered. - // | * @param sp the Java Lambda to be registered. - // | * $doc - // | * @param output the SProc return {@code types.DataType} - // | * @param stageLocation a stage location that stored procedure jar files being uploaded to. - // | * @param isCallerMode true if the stored procedure is under caller mode. - // | * @return The result StoredProcedure reference - // | */ - // |@PublicPreview - // |public StoredProcedure registerPermanent(String name, - // | JavaSProc$x<$types> sp,$input DataType output, - // | String stageLocation, boolean isCallerMode) { - // | return new StoredProcedure( - // | JavaUtils.registerJavaSProc( - // | sproc, - // | name, - // | ScalaFunctions._toSProc(sp,$arg UDFRegistration.convertDataType(output)), - // | stageLocation, isCallerMode)); - // |}""".stripMargin) + // |/** + // | * Registers a Java Lambda of $x argument$s as a temporary named Stored + // Procedure that is + // | * scoped to this session. + // | * + // | * @since 1.8.0 + // | * @param name the name of the temporary stored procedure being registered. + // | * @param sp the Java Lambda to be registered. + // | * $doc + // | * @param output the SProc return {@code types.DataType} + // | * @return The result StoredProcedure reference + // | */ + // |@PublicPreview + // |public StoredProcedure registerTemporary(String name, + // | JavaSProc$x<$types> sp,$input DataType output) { + // | return sproc("registerTemporary", name, () -> new StoredProcedure( + // | JavaUtils.registerJavaSProc( + // | sproc, + // | name, + // | ScalaFunctions._toSProc(sp,$arg + // UDFRegistration.convertDataType(output)), + // | null))); + // |}""".stripMargin) // } /** @@ -131,16 +131,20 @@ public class SProcRegistration { * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc0 sp, DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc(sp, UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc(sp, UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -158,7 +162,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc1 sp, @@ -166,16 +169,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -193,7 +201,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc2 sp, @@ -201,16 +208,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -228,7 +240,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc3 sp, @@ -236,16 +247,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -263,7 +279,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc4 sp, @@ -271,16 +286,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -298,7 +318,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc5 sp, @@ -306,16 +325,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -333,7 +357,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc6 sp, @@ -341,16 +364,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -368,7 +396,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc7 sp, @@ -376,16 +403,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -403,7 +435,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc8 sp, @@ -411,16 +442,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -438,7 +474,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc9 sp, @@ -446,16 +481,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -473,7 +513,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc10 sp, @@ -481,16 +520,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -508,7 +552,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc11 sp, @@ -516,16 +559,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -543,7 +591,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc12 sp, @@ -551,16 +598,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -578,7 +630,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc13 sp, @@ -586,16 +637,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -613,7 +669,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc14 sp, @@ -621,16 +676,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -648,7 +708,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc15 sp, @@ -656,16 +715,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -683,7 +747,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc16 sp, @@ -691,16 +754,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -718,7 +786,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc17 sp, @@ -726,16 +793,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -753,7 +825,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc18 sp, @@ -761,16 +832,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -788,7 +864,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc19 sp, @@ -796,16 +871,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -823,7 +903,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc20 sp, @@ -831,16 +910,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } /** @@ -858,7 +942,6 @@ public StoredProcedure registerPermanent( * @param isCallerMode true if the stored procedure is under caller mode. * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerPermanent( String name, JavaSProc21 sp, @@ -866,16 +949,21 @@ public StoredProcedure registerPermanent( DataType output, String stageLocation, boolean isCallerMode) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - stageLocation, - isCallerMode)); + return sproc( + "registerPermanent", + name, + stageLocation, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + stageLocation, + isCallerMode))); } // Code below for registerTemporary 0-21 generated by this script @@ -900,14 +988,13 @@ public StoredProcedure registerPermanent( // | * @param output the SProc return {@code types.DataType} // | * @return The result StoredProcedure reference // | */ - // |@PublicPreview // |public StoredProcedure registerTemporary(JavaSProc$x<$types> sp,$input DataType output) { - // | return new StoredProcedure( + // | return sproc("registerTemporary", () -> new StoredProcedure( // | JavaUtils.registerJavaSProc( // | sproc, // | null, // | ScalaFunctions._toSProc(sp,$arg UDFRegistration.convertDataType(output)), - // | null)); + // | null))); // |}""".stripMargin) // } @@ -920,14 +1007,16 @@ public StoredProcedure registerPermanent( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary(JavaSProc0 sp, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc(sp, UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc(sp, UDFRegistration.convertDataType(output)), + null))); } /** @@ -940,17 +1029,19 @@ public StoredProcedure registerTemporary(JavaSProc0 sp, DataType output) { * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary(JavaSProc1 sp, DataType input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -963,18 +1054,20 @@ public StoredProcedure registerTemporary(JavaSProc1 sp, DataType input, Da * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc2 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -987,18 +1080,20 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc3 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1011,18 +1106,20 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc4 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1035,18 +1132,20 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc5 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1059,18 +1158,20 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc6 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1083,18 +1184,20 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc7 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1107,18 +1210,20 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc8 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1131,18 +1236,20 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc9 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1155,18 +1262,20 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc10 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1179,18 +1288,20 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc11 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1203,18 +1314,20 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc12 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1227,18 +1340,20 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc13 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1251,20 +1366,22 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc14 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1277,20 +1394,22 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc15 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1303,20 +1422,22 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc16 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1329,20 +1450,22 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc17 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1355,20 +1478,22 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc18 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1381,20 +1506,22 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc19 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1407,20 +1534,22 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc20 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1433,54 +1562,57 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( JavaSProc21 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - null, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + null, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } // Code below for registerTemporary 0-21 generated by this script - // (0 to 21).foreach { x => + // (0 to 21).foreach { x => // val types = (1 to x).foldLeft("?")((i, _) => {s"$i, ?"}) // val (input, doc) = x match { // case 0 => ("", "") // case 1 => (" DataType input,", "@param input the SProc input {@code types.DataType}") // case _ => (" DataType[] input,", "@param input the SProc input {@code types.DataType}s") // } - // val s = if(x > 1) "s" else "" - // val arg = if(x > 0) " UDFRegistration.convertDataType(input)," else "" + // val s = if (x > 1) "s" else "" + // val arg = if (x > 0) " UDFRegistration.convertDataType(input)," else "" // println(s""" - // |/** - // | * Registers a Java Lambda of $x argument$s as a temporary named Stored Procedure that is - // | * scoped to this session. - // | * - // | * @since 1.8.0 - // | * @param name the name of the temporary stored procedure being registered. - // | * @param sp the Java Lambda to be registered. - // | * $doc - // | * @param output the SProc return {@code types.DataType} - // | * @return The result StoredProcedure reference - // | */ - // |@PublicPreview - // |public StoredProcedure registerTemporary(String name, - // | JavaSProc$x<$types> sp,$input DataType output) { - // | return new StoredProcedure( - // | JavaUtils.registerJavaSProc( - // | sproc, - // | name, - // | ScalaFunctions._toSProc(sp,$arg UDFRegistration.convertDataType(output)), - // | null)); - // |}""".stripMargin) + // |/** + // | * Registers a Java Lambda of $x argument$s as a temporary named Stored + // Procedure that is + // | * scoped to this session. + // | * + // | * @since 1.8.0 + // | * @param name the name of the temporary stored procedure being registered. + // | * @param sp the Java Lambda to be registered. + // | * $doc + // | * @param output the SProc return {@code types.DataType} + // | * @return The result StoredProcedure reference + // | */ + // |public StoredProcedure registerTemporary(String name, + // | JavaSProc$x<$types> sp,$input DataType output) { + // | return sproc("registerTemporary", name, () -> new StoredProcedure( + // | JavaUtils.registerJavaSProc( + // | sproc, + // | name, + // | ScalaFunctions._toSProc(sp,$arg + // UDFRegistration.convertDataType(output)), + // | null))); + // |}""".stripMargin) // } /** @@ -1493,14 +1625,17 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary(String name, JavaSProc0 sp, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc(sp, UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc(sp, UDFRegistration.convertDataType(output)), + null))); } /** @@ -1514,18 +1649,21 @@ public StoredProcedure registerTemporary(String name, JavaSProc0 sp, DataType * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc1 sp, DataType input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1539,18 +1677,21 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc2 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1564,18 +1705,21 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc3 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1589,18 +1733,21 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc4 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1614,18 +1761,21 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc5 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1639,18 +1789,21 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc6 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1664,18 +1817,21 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc7 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1689,18 +1845,21 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc8 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1714,18 +1873,21 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc9 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1739,21 +1901,24 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc10 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1767,21 +1932,24 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc11 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1795,21 +1963,24 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc12 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1823,21 +1994,24 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc13 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1851,21 +2025,24 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc14 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1879,21 +2056,24 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc15 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1907,21 +2087,24 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc16 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1935,21 +2118,24 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc17 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1963,21 +2149,24 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc18 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -1991,21 +2180,24 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc19 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -2019,21 +2211,24 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc20 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -2047,21 +2242,24 @@ public StoredProcedure registerTemporary( * @param output the SProc return {@code types.DataType} * @return The result StoredProcedure reference */ - @PublicPreview public StoredProcedure registerTemporary( String name, JavaSProc21 sp, DataType[] input, DataType output) { - return new StoredProcedure( - JavaUtils.registerJavaSProc( - sproc, - name, - ScalaFunctions._toSProc( - sp, - UDFRegistration.convertDataType(input), - UDFRegistration.convertDataType(output)), - null)); + return sproc( + "registerTemporary", + name, + () -> + new StoredProcedure( + JavaUtils.registerJavaSProc( + sproc, + name, + ScalaFunctions._toSProc( + sp, + UDFRegistration.convertDataType(input), + UDFRegistration.convertDataType(output)), + null))); } /** @@ -2478,4 +2676,17 @@ public Object runLocally(JavaSProc sproc, Object... args) { } throw new UnsupportedOperationException("Unsupported Java SProc Type"); } + + private StoredProcedure sproc( + String funcName, String execName, String execFilePath, Supplier func) { + return javaSProc("SProcRegistration", funcName, execName, execFilePath, 0, func); + } + + private StoredProcedure sproc(String funcName, String execName, Supplier func) { + return javaSProc("SProcRegistration", funcName, execName, "", 0, func); + } + + private StoredProcedure sproc(String funcName, Supplier func) { + return javaSProc("SProcRegistration", funcName, "", "", 0, func); + } } diff --git a/src/main/java/com/snowflake/snowpark_java/UDFRegistration.java b/src/main/java/com/snowflake/snowpark_java/UDFRegistration.java index 1f4508bd..b77581d7 100644 --- a/src/main/java/com/snowflake/snowpark_java/UDFRegistration.java +++ b/src/main/java/com/snowflake/snowpark_java/UDFRegistration.java @@ -1,10 +1,13 @@ package com.snowflake.snowpark_java; +import static com.snowflake.snowpark.internal.OpenTelemetry.javaUDF; + import com.snowflake.snowpark.internal.JavaDataTypeUtils; import com.snowflake.snowpark.internal.JavaUtils; import com.snowflake.snowpark.internal.ScalaFunctions; import com.snowflake.snowpark_java.types.DataType; import com.snowflake.snowpark_java.udf.*; +import java.util.function.Supplier; /** * Provides methods to register lambdas and functions as UDFs in the Snowflake database. {@code @@ -43,12 +46,12 @@ public class UDFRegistration { // | */ // |public UserDefinedFunction registerTemporary(JavaUDF$x<$types> func,$input DataType // output) { - // | return new UserDefinedFunction( + // | return udf("registerTemporary", () -> new UserDefinedFunction( // | JavaUtils.registerUDF( // | udf, // | null, // | ScalaFunctions._toUdf(func,$arg convertDataType(output)), - // | null)); + // | null))); // |}""".stripMargin) // } @@ -62,9 +65,12 @@ public class UDFRegistration { * @return The result UserDefinedFunction reference */ public UserDefinedFunction registerTemporary(JavaUDF0 func, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, null, ScalaFunctions._toUdf(func, convertDataType(output)), null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, null, ScalaFunctions._toUdf(func, convertDataType(output)), null))); } /** @@ -79,12 +85,15 @@ public UserDefinedFunction registerTemporary(JavaUDF0 func, DataType output) */ public UserDefinedFunction registerTemporary( JavaUDF1 func, DataType input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -99,12 +108,15 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( JavaUDF2 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -119,12 +131,15 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( JavaUDF3 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -139,12 +154,15 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( JavaUDF4 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -159,12 +177,15 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( JavaUDF5 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -179,12 +200,15 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( JavaUDF6 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -199,12 +223,15 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( JavaUDF7 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -219,12 +246,15 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( JavaUDF8 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -239,12 +269,15 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( JavaUDF9 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -259,12 +292,15 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( JavaUDF10 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -279,12 +315,15 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( JavaUDF11 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -299,12 +338,15 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( JavaUDF12 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -319,12 +361,15 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( JavaUDF13 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -341,12 +386,15 @@ public UserDefinedFunction registerTemporary( JavaUDF14 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -363,12 +411,15 @@ public UserDefinedFunction registerTemporary( JavaUDF15 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -385,12 +436,15 @@ public UserDefinedFunction registerTemporary( JavaUDF16 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -407,12 +461,15 @@ public UserDefinedFunction registerTemporary( JavaUDF17 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -429,12 +486,15 @@ public UserDefinedFunction registerTemporary( JavaUDF18 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -451,12 +511,15 @@ public UserDefinedFunction registerTemporary( JavaUDF19 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -473,12 +536,15 @@ public UserDefinedFunction registerTemporary( JavaUDF20 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -495,12 +561,15 @@ public UserDefinedFunction registerTemporary( JavaUDF21 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -517,12 +586,15 @@ public UserDefinedFunction registerTemporary( JavaUDF22 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - null, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + null, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } // Code below for registerTemporary 0-22 generated by this script @@ -550,12 +622,12 @@ public UserDefinedFunction registerTemporary( // | */ // |public UserDefinedFunction registerTemporary(String name, JavaUDF$x<$types> func, // |$input DataType output) { - // | return new UserDefinedFunction( + // | return udf("registerTemporary", name, () -> new UserDefinedFunction( // | JavaUtils.registerUDF( // | udf, // | name, // | ScalaFunctions._toUdf(func,$arg convertDataType(output)), - // | null)); + // | null))); // |}""".stripMargin) // } @@ -569,9 +641,13 @@ public UserDefinedFunction registerTemporary( * @return The result UserDefinedFunction reference */ public UserDefinedFunction registerTemporary(String name, JavaUDF0 func, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, name, ScalaFunctions._toUdf(func, convertDataType(output)), null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, name, ScalaFunctions._toUdf(func, convertDataType(output)), null))); } /** @@ -586,12 +662,16 @@ public UserDefinedFunction registerTemporary(String name, JavaUDF0 func, Data */ public UserDefinedFunction registerTemporary( String name, JavaUDF1 func, DataType input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -606,12 +686,16 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( String name, JavaUDF2 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -626,12 +710,16 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( String name, JavaUDF3 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -646,12 +734,16 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( String name, JavaUDF4 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -666,12 +758,16 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( String name, JavaUDF5 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -686,12 +782,16 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( String name, JavaUDF6 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -706,12 +806,16 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( String name, JavaUDF7 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -726,12 +830,16 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( String name, JavaUDF8 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -746,12 +854,16 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerTemporary( String name, JavaUDF9 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -769,12 +881,16 @@ public UserDefinedFunction registerTemporary( JavaUDF10 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -792,12 +908,16 @@ public UserDefinedFunction registerTemporary( JavaUDF11 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -815,12 +935,16 @@ public UserDefinedFunction registerTemporary( JavaUDF12 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -838,12 +962,16 @@ public UserDefinedFunction registerTemporary( JavaUDF13 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -861,12 +989,16 @@ public UserDefinedFunction registerTemporary( JavaUDF14 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -884,12 +1016,16 @@ public UserDefinedFunction registerTemporary( JavaUDF15 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -907,12 +1043,16 @@ public UserDefinedFunction registerTemporary( JavaUDF16 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -930,12 +1070,16 @@ public UserDefinedFunction registerTemporary( JavaUDF17 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -953,12 +1097,16 @@ public UserDefinedFunction registerTemporary( JavaUDF18 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -976,12 +1124,16 @@ public UserDefinedFunction registerTemporary( JavaUDF19 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -999,12 +1151,16 @@ public UserDefinedFunction registerTemporary( JavaUDF20 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -1022,12 +1178,16 @@ public UserDefinedFunction registerTemporary( JavaUDF21 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } /** @@ -1045,12 +1205,16 @@ public UserDefinedFunction registerTemporary( JavaUDF22 func, DataType[] input, DataType output) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - null)); + return udf( + "registerTemporary", + name, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + null))); } // Code below for registerPermanent 0-22 generated by this script @@ -1089,13 +1253,13 @@ public UserDefinedFunction registerTemporary( // | DataType output, // | String stageLocation // |){ - // | return new UserDefinedFunction( + // | return udf("registerPermanent", name, stageLocation, () -> new UserDefinedFunction( // | JavaUtils.registerUDF( // | udf, // | name, // | ScalaFunctions._toUdf(func,$arg convertDataType(output)), // | stageLocation - // | )); + // | ))); // |}""".stripMargin) // } @@ -1118,9 +1282,17 @@ public UserDefinedFunction registerTemporary( */ public UserDefinedFunction registerPermanent( String name, JavaUDF0 func, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, name, ScalaFunctions._toUdf(func, convertDataType(output)), stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(output)), + stageLocation))); } /** @@ -1143,12 +1315,17 @@ public UserDefinedFunction registerPermanent( */ public UserDefinedFunction registerPermanent( String name, JavaUDF1 func, DataType input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1175,12 +1352,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1207,12 +1389,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1239,12 +1426,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1271,12 +1463,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1303,12 +1500,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1335,12 +1537,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1367,12 +1574,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1399,12 +1611,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1431,12 +1648,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1463,12 +1685,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1495,12 +1722,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1527,12 +1759,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1559,12 +1796,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1591,12 +1833,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1623,12 +1870,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1655,12 +1907,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1687,12 +1944,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1719,12 +1981,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1751,12 +2018,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1783,12 +2055,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } /** @@ -1815,12 +2092,17 @@ public UserDefinedFunction registerPermanent( DataType[] input, DataType output, String stageLocation) { - return new UserDefinedFunction( - JavaUtils.registerUDF( - udf, - name, - ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), - stageLocation)); + return udf( + "registerPermanent", + name, + stageLocation, + () -> + new UserDefinedFunction( + JavaUtils.registerUDF( + udf, + name, + ScalaFunctions._toUdf(func, convertDataType(input), convertDataType(output)), + stageLocation))); } static com.snowflake.snowpark.types.DataType convertDataType(DataType javaType) { @@ -1835,4 +2117,18 @@ static com.snowflake.snowpark.types.DataType[] convertDataType(DataType[] javaTy } return result; } + + private UserDefinedFunction udf( + String funcName, String execName, String execFilePath, Supplier func) { + return javaUDF("UDFRegistration", funcName, execName, execFilePath, 0, func); + } + + private UserDefinedFunction udf( + String funcName, String execName, Supplier func) { + return javaUDF("UDFRegistration", funcName, execName, "", 0, func); + } + + private UserDefinedFunction udf(String funcName, Supplier func) { + return javaUDF("UDFRegistration", funcName, "", "", 0, func); + } } diff --git a/src/main/java/com/snowflake/snowpark_java/UDTFRegistration.java b/src/main/java/com/snowflake/snowpark_java/UDTFRegistration.java index 012f5749..13689a7b 100644 --- a/src/main/java/com/snowflake/snowpark_java/UDTFRegistration.java +++ b/src/main/java/com/snowflake/snowpark_java/UDTFRegistration.java @@ -1,7 +1,10 @@ package com.snowflake.snowpark_java; +import static com.snowflake.snowpark.internal.OpenTelemetry.javaUDTF; + import com.snowflake.snowpark.internal.JavaUtils; import com.snowflake.snowpark_java.udtf.*; +import java.util.function.Supplier; /** * Provides methods to register a UDTF (user-defined table function) in the Snowflake database. @@ -255,7 +258,12 @@ public class UDTFRegistration { * @return A TableFunction that represents the corresponding FUNCTION created in Snowflake */ public TableFunction registerTemporary(JavaUDTF udtf) { - return new TableFunction(JavaUtils.registerJavaUDTF(this.udtfRegistration, null, udtf, null)); + return tableFunction( + "registerTemporary", + "", + "", + () -> + new TableFunction(JavaUtils.registerJavaUDTF(this.udtfRegistration, null, udtf, null))); } /** @@ -267,8 +275,13 @@ public TableFunction registerTemporary(JavaUDTF udtf) { * @return A TableFunction that represents the corresponding FUNCTION created in Snowflake */ public TableFunction registerTemporary(String funcName, JavaUDTF udtf) { - return new TableFunction( - JavaUtils.registerJavaUDTF(this.udtfRegistration, funcName, udtf, null)); + return tableFunction( + "registerTemporary", + funcName, + "", + () -> + new TableFunction( + JavaUtils.registerJavaUDTF(this.udtfRegistration, funcName, udtf, null))); } /** @@ -289,7 +302,17 @@ public TableFunction registerTemporary(String funcName, JavaUDTF udtf) { * @return A TableFunction that represents the corresponding FUNCTION created in Snowflake */ public TableFunction registerPermanent(String funcName, JavaUDTF udtf, String stageLocation) { - return new TableFunction( - JavaUtils.registerJavaUDTF(this.udtfRegistration, funcName, udtf, stageLocation)); + return tableFunction( + "registerPermanent", + funcName, + stageLocation, + () -> + new TableFunction( + JavaUtils.registerJavaUDTF(this.udtfRegistration, funcName, udtf, stageLocation))); + } + + private TableFunction tableFunction( + String funcName, String execName, String execFilePath, Supplier func) { + return javaUDTF("UDTFRegistration", funcName, execName, execFilePath, 0, func); } } diff --git a/src/main/scala/com/snowflake/snowpark/SProcRegistration.scala b/src/main/scala/com/snowflake/snowpark/SProcRegistration.scala index 173f3001..7520cffd 100644 --- a/src/main/scala/com/snowflake/snowpark/SProcRegistration.scala +++ b/src/main/scala/com/snowflake/snowpark/SProcRegistration.scala @@ -1,6 +1,7 @@ package com.snowflake.snowpark -import com.snowflake.snowpark.internal.UDXRegistrationHandler +import com.snowflake.snowpark.internal.{OpenTelemetry, UDXRegistrationHandler} + import scala.reflect.runtime.universe.TypeTag import com.snowflake.snowpark.internal.ScalaFunctions._ @@ -73,7 +74,8 @@ class SProcRegistration(session: Session) { * | * @tparam RT Return type of the UDF. * | */ * |def registerPermanent[$typeTags](name: String, sp: Function${x + 1}[Session, $types], - * | stageLocation: String, isCallerMode: Boolean): StoredProcedure = { + * | stageLocation: String, isCallerMode: Boolean): StoredProcedure = + * | sproc("registerPermanent", execName = name, execFilePath = stageLocation) { * | register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) * |}""".stripMargin) * } @@ -85,77 +87,76 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[RT: TypeTag]( name: String, sp: Function1[Session, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 1 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[RT: TypeTag, A1: TypeTag]( name: String, sp: Function2[Session, A1, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 2 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[RT: TypeTag, A1: TypeTag, A2: TypeTag]( name: String, sp: Function3[Session, A1, A2, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 3 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag]( name: String, sp: Function4[Session, A1, A2, A3, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 4 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag]( name: String, sp: Function5[Session, A1, A2, A3, A4, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 5 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -166,16 +167,16 @@ class SProcRegistration(session: Session) { name: String, sp: Function6[Session, A1, A2, A3, A4, A5, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 6 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -187,16 +188,16 @@ class SProcRegistration(session: Session) { name: String, sp: Function7[Session, A1, A2, A3, A4, A5, A6, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 7 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -209,16 +210,16 @@ class SProcRegistration(session: Session) { name: String, sp: Function8[Session, A1, A2, A3, A4, A5, A6, A7, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 8 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -232,16 +233,16 @@ class SProcRegistration(session: Session) { name: String, sp: Function9[Session, A1, A2, A3, A4, A5, A6, A7, A8, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 9 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -256,16 +257,16 @@ class SProcRegistration(session: Session) { name: String, sp: Function10[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 10 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -281,16 +282,16 @@ class SProcRegistration(session: Session) { name: String, sp: Function11[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 11 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -307,16 +308,16 @@ class SProcRegistration(session: Session) { name: String, sp: Function12[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 12 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -334,16 +335,16 @@ class SProcRegistration(session: Session) { name: String, sp: Function13[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 13 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -362,16 +363,16 @@ class SProcRegistration(session: Session) { name: String, sp: Function14[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 14 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -391,16 +392,16 @@ class SProcRegistration(session: Session) { name: String, sp: Function15[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 15 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -438,16 +439,16 @@ class SProcRegistration(session: Session) { A15, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 16 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -487,16 +488,16 @@ class SProcRegistration(session: Session) { A16, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 17 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -538,16 +539,16 @@ class SProcRegistration(session: Session) { A17, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 18 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -591,16 +592,16 @@ class SProcRegistration(session: Session) { A18, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 19 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -646,16 +647,16 @@ class SProcRegistration(session: Session) { A19, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 20 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -703,16 +704,16 @@ class SProcRegistration(session: Session) { A20, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } /** * Registers a Scala closure of 21 arguments as a permanent Stored Procedure. * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerPermanent[ RT: TypeTag, A1: TypeTag, @@ -762,9 +763,10 @@ class SProcRegistration(session: Session) { A21, RT], stageLocation: String, - isCallerMode: Boolean): StoredProcedure = { - register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) - } + isCallerMode: Boolean): StoredProcedure = + sproc("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toSP(sp), Some(stageLocation), isCallerMode) + } // scalastyle:off line.size.limit /* Code below for registerTemporary 0 - 21 generated by this script @@ -778,7 +780,8 @@ class SProcRegistration(session: Session) { * | * * | * @tparam RT Return type of the UDF. * | */ - * |def registerTemporary[$typeTags](sp: Function${x + 1}[Session, $types]): StoredProcedure = { + * |def registerTemporary[$typeTags](sp: Function${x + 1}[Session, $types]): StoredProcedure = + * | sproc("registerTemporary") { * | register(None, _toSP(sp)) * |}""".stripMargin) * } @@ -791,10 +794,10 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview - def registerTemporary[RT: TypeTag](sp: Function1[Session, RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + def registerTemporary[RT: TypeTag](sp: Function1[Session, RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 1 arguments as a temporary Stored Procedure that is @@ -802,11 +805,11 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[RT: TypeTag, A1: TypeTag]( - sp: Function2[Session, A1, RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + sp: Function2[Session, A1, RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 2 arguments as a temporary Stored Procedure that is @@ -814,11 +817,11 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[RT: TypeTag, A1: TypeTag, A2: TypeTag]( - sp: Function3[Session, A1, A2, RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + sp: Function3[Session, A1, A2, RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 3 arguments as a temporary Stored Procedure that is @@ -826,11 +829,11 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag]( - sp: Function4[Session, A1, A2, A3, RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + sp: Function4[Session, A1, A2, A3, RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 4 arguments as a temporary Stored Procedure that is @@ -838,11 +841,11 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag]( - sp: Function5[Session, A1, A2, A3, A4, RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + sp: Function5[Session, A1, A2, A3, A4, RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 5 arguments as a temporary Stored Procedure that is @@ -850,16 +853,16 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, - A5: TypeTag](sp: Function6[Session, A1, A2, A3, A4, A5, RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + A5: TypeTag](sp: Function6[Session, A1, A2, A3, A4, A5, RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 6 arguments as a temporary Stored Procedure that is @@ -867,7 +870,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -875,9 +877,10 @@ class SProcRegistration(session: Session) { A3: TypeTag, A4: TypeTag, A5: TypeTag, - A6: TypeTag](sp: Function7[Session, A1, A2, A3, A4, A5, A6, RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + A6: TypeTag](sp: Function7[Session, A1, A2, A3, A4, A5, A6, RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 7 arguments as a temporary Stored Procedure that is @@ -885,7 +888,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -894,9 +896,10 @@ class SProcRegistration(session: Session) { A4: TypeTag, A5: TypeTag, A6: TypeTag, - A7: TypeTag](sp: Function8[Session, A1, A2, A3, A4, A5, A6, A7, RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + A7: TypeTag](sp: Function8[Session, A1, A2, A3, A4, A5, A6, A7, RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 8 arguments as a temporary Stored Procedure that is @@ -904,7 +907,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -914,10 +916,10 @@ class SProcRegistration(session: Session) { A5: TypeTag, A6: TypeTag, A7: TypeTag, - A8: TypeTag]( - sp: Function9[Session, A1, A2, A3, A4, A5, A6, A7, A8, RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + A8: TypeTag](sp: Function9[Session, A1, A2, A3, A4, A5, A6, A7, A8, RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 9 arguments as a temporary Stored Procedure that is @@ -925,7 +927,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -937,9 +938,10 @@ class SProcRegistration(session: Session) { A7: TypeTag, A8: TypeTag, A9: TypeTag]( - sp: Function10[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + sp: Function10[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 10 arguments as a temporary Stored Procedure that is @@ -947,7 +949,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -960,9 +961,10 @@ class SProcRegistration(session: Session) { A8: TypeTag, A9: TypeTag, A10: TypeTag]( - sp: Function11[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + sp: Function11[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 11 arguments as a temporary Stored Procedure that is @@ -970,7 +972,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -984,9 +985,10 @@ class SProcRegistration(session: Session) { A9: TypeTag, A10: TypeTag, A11: TypeTag](sp: Function12[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, RT]) - : StoredProcedure = { - register(None, _toSP(sp)) - } + : StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 12 arguments as a temporary Stored Procedure that is @@ -994,7 +996,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1010,9 +1011,10 @@ class SProcRegistration(session: Session) { A11: TypeTag, A12: TypeTag]( sp: Function13[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, RT]) - : StoredProcedure = { - register(None, _toSP(sp)) - } + : StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 13 arguments as a temporary Stored Procedure that is @@ -1020,7 +1022,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1037,9 +1038,10 @@ class SProcRegistration(session: Session) { A12: TypeTag, A13: TypeTag]( sp: Function14[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, RT]) - : StoredProcedure = { - register(None, _toSP(sp)) - } + : StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 14 arguments as a temporary Stored Procedure that is @@ -1047,7 +1049,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1065,9 +1066,10 @@ class SProcRegistration(session: Session) { A13: TypeTag, A14: TypeTag]( sp: Function15[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, RT]) - : StoredProcedure = { - register(None, _toSP(sp)) - } + : StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 15 arguments as a temporary Stored Procedure that is @@ -1075,7 +1077,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1110,9 +1111,10 @@ class SProcRegistration(session: Session) { A13, A14, A15, - RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 16 arguments as a temporary Stored Procedure that is @@ -1120,7 +1122,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1157,9 +1158,10 @@ class SProcRegistration(session: Session) { A14, A15, A16, - RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 17 arguments as a temporary Stored Procedure that is @@ -1167,7 +1169,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1206,9 +1207,10 @@ class SProcRegistration(session: Session) { A15, A16, A17, - RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 18 arguments as a temporary Stored Procedure that is @@ -1216,7 +1218,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1257,9 +1258,10 @@ class SProcRegistration(session: Session) { A16, A17, A18, - RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 19 arguments as a temporary Stored Procedure that is @@ -1267,7 +1269,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1310,9 +1311,10 @@ class SProcRegistration(session: Session) { A17, A18, A19, - RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 20 arguments as a temporary Stored Procedure that is @@ -1320,7 +1322,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1365,9 +1366,10 @@ class SProcRegistration(session: Session) { A18, A19, A20, - RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } /** * Registers a Scala closure of 21 arguments as a temporary Stored Procedure that is @@ -1375,7 +1377,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1422,9 +1423,10 @@ class SProcRegistration(session: Session) { A19, A20, A21, - RT]): StoredProcedure = { - register(None, _toSP(sp)) - } + RT]): StoredProcedure = + sproc("registerTemporary") { + register(None, _toSP(sp)) + } // scalastyle:off line.size.limit /* Code below for registerTemporary 0 - 21 generated by this script @@ -1438,7 +1440,8 @@ class SProcRegistration(session: Session) { | * | * @tparam RT Return type of the UDF. | */ - |def registerTemporary[$typeTags](name: String, sp: Function${x + 1}[Session, $types]): StoredProcedure = { + |def registerTemporary[$typeTags](name: String, sp: Function${x + 1}[Session, $types]): StoredProcedure = + | sproc("registerTemporary", execName = name) { | register(Some(name), _toSP(sp)) |}""".stripMargin) } @@ -1451,12 +1454,10 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview - def registerTemporary[RT: TypeTag]( - name: String, - sp: Function1[Session, RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + def registerTemporary[RT: TypeTag](name: String, sp: Function1[Session, RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 1 arguments as a temporary Stored Procedure that is @@ -1464,12 +1465,12 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[RT: TypeTag, A1: TypeTag]( name: String, - sp: Function2[Session, A1, RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + sp: Function2[Session, A1, RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 2 arguments as a temporary Stored Procedure that is @@ -1477,12 +1478,12 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[RT: TypeTag, A1: TypeTag, A2: TypeTag]( name: String, - sp: Function3[Session, A1, A2, RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + sp: Function3[Session, A1, A2, RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 3 arguments as a temporary Stored Procedure that is @@ -1490,12 +1491,12 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag]( name: String, - sp: Function4[Session, A1, A2, A3, RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + sp: Function4[Session, A1, A2, A3, RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 4 arguments as a temporary Stored Procedure that is @@ -1503,12 +1504,12 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag]( name: String, - sp: Function5[Session, A1, A2, A3, A4, RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + sp: Function5[Session, A1, A2, A3, A4, RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 5 arguments as a temporary Stored Procedure that is @@ -1516,7 +1517,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1525,9 +1525,10 @@ class SProcRegistration(session: Session) { A4: TypeTag, A5: TypeTag]( name: String, - sp: Function6[Session, A1, A2, A3, A4, A5, RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + sp: Function6[Session, A1, A2, A3, A4, A5, RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 6 arguments as a temporary Stored Procedure that is @@ -1535,7 +1536,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1545,9 +1545,10 @@ class SProcRegistration(session: Session) { A5: TypeTag, A6: TypeTag]( name: String, - sp: Function7[Session, A1, A2, A3, A4, A5, A6, RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + sp: Function7[Session, A1, A2, A3, A4, A5, A6, RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 7 arguments as a temporary Stored Procedure that is @@ -1555,7 +1556,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1566,9 +1566,10 @@ class SProcRegistration(session: Session) { A6: TypeTag, A7: TypeTag]( name: String, - sp: Function8[Session, A1, A2, A3, A4, A5, A6, A7, RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + sp: Function8[Session, A1, A2, A3, A4, A5, A6, A7, RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 8 arguments as a temporary Stored Procedure that is @@ -1576,7 +1577,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1588,9 +1588,10 @@ class SProcRegistration(session: Session) { A7: TypeTag, A8: TypeTag]( name: String, - sp: Function9[Session, A1, A2, A3, A4, A5, A6, A7, A8, RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + sp: Function9[Session, A1, A2, A3, A4, A5, A6, A7, A8, RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 9 arguments as a temporary Stored Procedure that is @@ -1598,7 +1599,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1611,9 +1611,10 @@ class SProcRegistration(session: Session) { A8: TypeTag, A9: TypeTag]( name: String, - sp: Function10[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + sp: Function10[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 10 arguments as a temporary Stored Procedure that is @@ -1621,7 +1622,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1635,9 +1635,10 @@ class SProcRegistration(session: Session) { A9: TypeTag, A10: TypeTag]( name: String, - sp: Function11[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + sp: Function11[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 11 arguments as a temporary Stored Procedure that is @@ -1645,7 +1646,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1661,9 +1661,10 @@ class SProcRegistration(session: Session) { A11: TypeTag]( name: String, sp: Function12[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, RT]) - : StoredProcedure = { - register(Some(name), _toSP(sp)) - } + : StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 12 arguments as a temporary Stored Procedure that is @@ -1671,7 +1672,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1688,9 +1688,10 @@ class SProcRegistration(session: Session) { A12: TypeTag]( name: String, sp: Function13[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, RT]) - : StoredProcedure = { - register(Some(name), _toSP(sp)) - } + : StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 13 arguments as a temporary Stored Procedure that is @@ -1698,7 +1699,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1716,9 +1716,10 @@ class SProcRegistration(session: Session) { A13: TypeTag]( name: String, sp: Function14[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, RT]) - : StoredProcedure = { - register(Some(name), _toSP(sp)) - } + : StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 14 arguments as a temporary Stored Procedure that is @@ -1726,7 +1727,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1745,9 +1745,10 @@ class SProcRegistration(session: Session) { A14: TypeTag]( name: String, sp: Function15[Session, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, RT]) - : StoredProcedure = { - register(Some(name), _toSP(sp)) - } + : StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 15 arguments as a temporary Stored Procedure that is @@ -1755,7 +1756,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1791,9 +1791,10 @@ class SProcRegistration(session: Session) { A13, A14, A15, - RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 16 arguments as a temporary Stored Procedure that is @@ -1801,7 +1802,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1839,9 +1839,10 @@ class SProcRegistration(session: Session) { A14, A15, A16, - RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 17 arguments as a temporary Stored Procedure that is @@ -1849,7 +1850,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1889,9 +1889,10 @@ class SProcRegistration(session: Session) { A15, A16, A17, - RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 18 arguments as a temporary Stored Procedure that is @@ -1899,7 +1900,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1941,9 +1941,10 @@ class SProcRegistration(session: Session) { A16, A17, A18, - RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 19 arguments as a temporary Stored Procedure that is @@ -1951,7 +1952,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -1995,9 +1995,10 @@ class SProcRegistration(session: Session) { A17, A18, A19, - RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 20 arguments as a temporary Stored Procedure that is @@ -2005,7 +2006,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -2051,9 +2051,10 @@ class SProcRegistration(session: Session) { A18, A19, A20, - RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } /** * Registers a Scala closure of 21 arguments as a temporary Stored Procedure that is @@ -2061,7 +2062,6 @@ class SProcRegistration(session: Session) { * * @tparam RT Return type of the UDF. */ - @PublicPreview def registerTemporary[ RT: TypeTag, A1: TypeTag, @@ -2109,9 +2109,10 @@ class SProcRegistration(session: Session) { A19, A20, A21, - RT]): StoredProcedure = { - register(Some(name), _toSP(sp)) - } + RT]): StoredProcedure = + sproc("registerTemporary", execName = name) { + register(Some(name), _toSP(sp)) + } private[snowpark] def register( name: Option[String], @@ -3171,4 +3172,15 @@ class SProcRegistration(session: Session) { a20, a21) } + + @inline protected def sproc(funcName: String, execName: String = "", execFilePath: String = "")( + func: => StoredProcedure): StoredProcedure = { + OpenTelemetry.udx( + "SProcRegistration", + funcName, + execName, + s"${UDXRegistrationHandler.className}.${UDXRegistrationHandler.methodName}", + execFilePath, + 0)(func) + } } diff --git a/src/main/scala/com/snowflake/snowpark/UDFRegistration.scala b/src/main/scala/com/snowflake/snowpark/UDFRegistration.scala index 8b3a4da4..564c2ed2 100644 --- a/src/main/scala/com/snowflake/snowpark/UDFRegistration.scala +++ b/src/main/scala/com/snowflake/snowpark/UDFRegistration.scala @@ -64,17 +64,21 @@ class UDFRegistration(session: Session) extends Logging { // scalastyle:off line.size.limit /* Code below for registerTemporary 0 - 22 generated by this script - (0 to 10).foreach { x => + (0 to 22).foreach { x => val types = (1 to x).foldRight("RT")((i, s) => {s"A$i, $s"}) val typeTags = (1 to x).map(i => s"A$i: TypeTag").foldLeft("RT: TypeTag")(_ + ", " + _) + val s = if (x > 1) "s" else "" + val version = if (x > 10) "0.12.0" else "0.6.0" println(s""" |/** - | * Registers a Scala closure of $x arguments as a temporary anonymous UDF that is + | * Registers a Scala closure of $x argument$s as a temporary anonymous UDF that is | * scoped to this session. | * | * @tparam RT Return type of the UDF. + | * @since $version | */ - |def registerTemporary[$typeTags](func: Function$x[$types]): UserDefinedFunction = { + |def registerTemporary[$typeTags](func: Function$x[$types]): UserDefinedFunction = + | udf("registerTemporary") { | register(None, _toUdf(func)) |}""".stripMargin) } @@ -87,9 +91,10 @@ class UDFRegistration(session: Session) extends Logging { * @tparam RT Return type of the UDF. * @since 0.6.0 */ - def registerTemporary[RT: TypeTag](func: Function0[RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + def registerTemporary[RT: TypeTag](func: Function0[RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 1 argument as a temporary anonymous UDF that is @@ -98,10 +103,10 @@ class UDFRegistration(session: Session) extends Logging { * @tparam RT Return type of the UDF. * @since 0.6.0 */ - def registerTemporary[RT: TypeTag, A1: TypeTag]( - func: Function1[A1, RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + def registerTemporary[RT: TypeTag, A1: TypeTag](func: Function1[A1, RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 2 arguments as a temporary anonymous UDF that is @@ -111,9 +116,10 @@ class UDFRegistration(session: Session) extends Logging { * @since 0.6.0 */ def registerTemporary[RT: TypeTag, A1: TypeTag, A2: TypeTag]( - func: Function2[A1, A2, RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + func: Function2[A1, A2, RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 3 arguments as a temporary anonymous UDF that is @@ -123,9 +129,10 @@ class UDFRegistration(session: Session) extends Logging { * @since 0.6.0 */ def registerTemporary[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag]( - func: Function3[A1, A2, A3, RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + func: Function3[A1, A2, A3, RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 4 arguments as a temporary anonymous UDF that is @@ -135,9 +142,10 @@ class UDFRegistration(session: Session) extends Logging { * @since 0.6.0 */ def registerTemporary[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag]( - func: Function4[A1, A2, A3, A4, RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + func: Function4[A1, A2, A3, A4, RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 5 arguments as a temporary anonymous UDF that is @@ -152,9 +160,10 @@ class UDFRegistration(session: Session) extends Logging { A2: TypeTag, A3: TypeTag, A4: TypeTag, - A5: TypeTag](func: Function5[A1, A2, A3, A4, A5, RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + A5: TypeTag](func: Function5[A1, A2, A3, A4, A5, RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 6 arguments as a temporary anonymous UDF that is @@ -170,9 +179,10 @@ class UDFRegistration(session: Session) extends Logging { A3: TypeTag, A4: TypeTag, A5: TypeTag, - A6: TypeTag](func: Function6[A1, A2, A3, A4, A5, A6, RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + A6: TypeTag](func: Function6[A1, A2, A3, A4, A5, A6, RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 7 arguments as a temporary anonymous UDF that is @@ -189,9 +199,10 @@ class UDFRegistration(session: Session) extends Logging { A4: TypeTag, A5: TypeTag, A6: TypeTag, - A7: TypeTag](func: Function7[A1, A2, A3, A4, A5, A6, A7, RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + A7: TypeTag](func: Function7[A1, A2, A3, A4, A5, A6, A7, RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 8 arguments as a temporary anonymous UDF that is @@ -209,9 +220,10 @@ class UDFRegistration(session: Session) extends Logging { A5: TypeTag, A6: TypeTag, A7: TypeTag, - A8: TypeTag](func: Function8[A1, A2, A3, A4, A5, A6, A7, A8, RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + A8: TypeTag](func: Function8[A1, A2, A3, A4, A5, A6, A7, A8, RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 9 arguments as a temporary anonymous UDF that is @@ -230,10 +242,10 @@ class UDFRegistration(session: Session) extends Logging { A6: TypeTag, A7: TypeTag, A8: TypeTag, - A9: TypeTag]( - func: Function9[A1, A2, A3, A4, A5, A6, A7, A8, A9, RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + A9: TypeTag](func: Function9[A1, A2, A3, A4, A5, A6, A7, A8, A9, RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 10 arguments as a temporary anonymous UDF that is @@ -254,9 +266,10 @@ class UDFRegistration(session: Session) extends Logging { A8: TypeTag, A9: TypeTag, A10: TypeTag]( - func: Function10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + func: Function10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 11 arguments as a temporary anonymous UDF that is @@ -278,9 +291,10 @@ class UDFRegistration(session: Session) extends Logging { A9: TypeTag, A10: TypeTag, A11: TypeTag]( - func: Function11[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + func: Function11[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 12 arguments as a temporary anonymous UDF that is @@ -303,9 +317,10 @@ class UDFRegistration(session: Session) extends Logging { A10: TypeTag, A11: TypeTag, A12: TypeTag](func: Function12[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, RT]) - : UserDefinedFunction = { - register(None, _toUdf(func)) - } + : UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 13 arguments as a temporary anonymous UDF that is @@ -329,9 +344,10 @@ class UDFRegistration(session: Session) extends Logging { A11: TypeTag, A12: TypeTag, A13: TypeTag](func: Function13[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, RT]) - : UserDefinedFunction = { - register(None, _toUdf(func)) - } + : UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 14 arguments as a temporary anonymous UDF that is @@ -357,9 +373,10 @@ class UDFRegistration(session: Session) extends Logging { A13: TypeTag, A14: TypeTag]( func: Function14[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, RT]) - : UserDefinedFunction = { - register(None, _toUdf(func)) - } + : UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 15 arguments as a temporary anonymous UDF that is @@ -386,9 +403,10 @@ class UDFRegistration(session: Session) extends Logging { A14: TypeTag, A15: TypeTag]( func: Function15[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, RT]) - : UserDefinedFunction = { - register(None, _toUdf(func)) - } + : UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 16 arguments as a temporary anonymous UDF that is @@ -416,9 +434,10 @@ class UDFRegistration(session: Session) extends Logging { A15: TypeTag, A16: TypeTag]( func: Function16[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, RT]) - : UserDefinedFunction = { - register(None, _toUdf(func)) - } + : UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 17 arguments as a temporary anonymous UDF that is @@ -464,9 +483,10 @@ class UDFRegistration(session: Session) extends Logging { A15, A16, A17, - RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 18 arguments as a temporary anonymous UDF that is @@ -514,9 +534,10 @@ class UDFRegistration(session: Session) extends Logging { A16, A17, A18, - RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 19 arguments as a temporary anonymous UDF that is @@ -566,9 +587,10 @@ class UDFRegistration(session: Session) extends Logging { A17, A18, A19, - RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 20 arguments as a temporary anonymous UDF that is @@ -620,9 +642,10 @@ class UDFRegistration(session: Session) extends Logging { A18, A19, A20, - RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 21 arguments as a temporary anonymous UDF that is @@ -676,9 +699,10 @@ class UDFRegistration(session: Session) extends Logging { A19, A20, A21, - RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } /** * Registers a Scala closure of 22 arguments as a temporary anonymous UDF that is @@ -734,9 +758,10 @@ class UDFRegistration(session: Session) extends Logging { A20, A21, A22, - RT]): UserDefinedFunction = { - register(None, _toUdf(func)) - } + RT]): UserDefinedFunction = + udf("registerTemporary") { + register(None, _toUdf(func)) + } // scalastyle:off line.size.limit /* Code below for registerTemporary 0-22 generated by this script @@ -753,7 +778,8 @@ class UDFRegistration(session: Session) extends Logging { | * @tparam RT Return type of the UDF. | * @since $version | */ - |def registerTemporary[$typeTags](name: String, func: Function$x[$types]): UserDefinedFunction = { + |def registerTemporary[$typeTags](name: String, func: Function$x[$types]): UserDefinedFunction = + | udf("registerTemporary", execName = name) { | register(Some(name), _toUdf(func)) |}""".stripMargin) } @@ -765,9 +791,10 @@ class UDFRegistration(session: Session) extends Logging { * @tparam RT Return type of the UDF. * @since 0.1.0 */ - def registerTemporary[RT: TypeTag](name: String, func: Function0[RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + def registerTemporary[RT: TypeTag](name: String, func: Function0[RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 1 argument as a temporary Snowflake Java UDF that you @@ -778,9 +805,10 @@ class UDFRegistration(session: Session) extends Logging { */ def registerTemporary[RT: TypeTag, A1: TypeTag]( name: String, - func: Function1[A1, RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + func: Function1[A1, RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 2 arguments as a temporary Snowflake Java UDF that you @@ -791,9 +819,10 @@ class UDFRegistration(session: Session) extends Logging { */ def registerTemporary[RT: TypeTag, A1: TypeTag, A2: TypeTag]( name: String, - func: Function2[A1, A2, RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + func: Function2[A1, A2, RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 3 arguments as a temporary Snowflake Java UDF that you @@ -804,9 +833,10 @@ class UDFRegistration(session: Session) extends Logging { */ def registerTemporary[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag]( name: String, - func: Function3[A1, A2, A3, RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + func: Function3[A1, A2, A3, RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 4 arguments as a temporary Snowflake Java UDF that you @@ -817,9 +847,10 @@ class UDFRegistration(session: Session) extends Logging { */ def registerTemporary[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag]( name: String, - func: Function4[A1, A2, A3, A4, RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + func: Function4[A1, A2, A3, A4, RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 5 arguments as a temporary Snowflake Java UDF that you @@ -834,9 +865,10 @@ class UDFRegistration(session: Session) extends Logging { A2: TypeTag, A3: TypeTag, A4: TypeTag, - A5: TypeTag](name: String, func: Function5[A1, A2, A3, A4, A5, RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + A5: TypeTag](name: String, func: Function5[A1, A2, A3, A4, A5, RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 6 arguments as a temporary Snowflake Java UDF that you @@ -854,9 +886,10 @@ class UDFRegistration(session: Session) extends Logging { A5: TypeTag, A6: TypeTag]( name: String, - func: Function6[A1, A2, A3, A4, A5, A6, RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + func: Function6[A1, A2, A3, A4, A5, A6, RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 7 arguments as a temporary Snowflake Java UDF that you @@ -875,9 +908,10 @@ class UDFRegistration(session: Session) extends Logging { A6: TypeTag, A7: TypeTag]( name: String, - func: Function7[A1, A2, A3, A4, A5, A6, A7, RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + func: Function7[A1, A2, A3, A4, A5, A6, A7, RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 8 arguments as a temporary Snowflake Java UDF that you @@ -897,9 +931,10 @@ class UDFRegistration(session: Session) extends Logging { A7: TypeTag, A8: TypeTag]( name: String, - func: Function8[A1, A2, A3, A4, A5, A6, A7, A8, RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + func: Function8[A1, A2, A3, A4, A5, A6, A7, A8, RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 9 arguments as a temporary Snowflake Java UDF that you @@ -920,9 +955,10 @@ class UDFRegistration(session: Session) extends Logging { A8: TypeTag, A9: TypeTag]( name: String, - func: Function9[A1, A2, A3, A4, A5, A6, A7, A8, A9, RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + func: Function9[A1, A2, A3, A4, A5, A6, A7, A8, A9, RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 10 arguments as a temporary Snowflake Java UDF that you @@ -944,9 +980,10 @@ class UDFRegistration(session: Session) extends Logging { A9: TypeTag, A10: TypeTag]( name: String, - func: Function10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + func: Function10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 11 arguments as a temporary Snowflake Java UDF that you @@ -969,9 +1006,10 @@ class UDFRegistration(session: Session) extends Logging { A10: TypeTag, A11: TypeTag]( name: String, - func: Function11[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + func: Function11[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 12 arguments as a temporary Snowflake Java UDF that you @@ -996,9 +1034,10 @@ class UDFRegistration(session: Session) extends Logging { A12: TypeTag]( name: String, func: Function12[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, RT]) - : UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + : UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 13 arguments as a temporary Snowflake Java UDF that you @@ -1024,9 +1063,10 @@ class UDFRegistration(session: Session) extends Logging { A13: TypeTag]( name: String, func: Function13[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, RT]) - : UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + : UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 14 arguments as a temporary Snowflake Java UDF that you @@ -1053,9 +1093,10 @@ class UDFRegistration(session: Session) extends Logging { A14: TypeTag]( name: String, func: Function14[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, RT]) - : UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + : UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 15 arguments as a temporary Snowflake Java UDF that you @@ -1083,9 +1124,10 @@ class UDFRegistration(session: Session) extends Logging { A15: TypeTag]( name: String, func: Function15[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, RT]) - : UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + : UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 16 arguments as a temporary Snowflake Java UDF that you @@ -1114,9 +1156,10 @@ class UDFRegistration(session: Session) extends Logging { A16: TypeTag]( name: String, func: Function16[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, RT]) - : UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + : UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 17 arguments as a temporary Snowflake Java UDF that you @@ -1163,9 +1206,10 @@ class UDFRegistration(session: Session) extends Logging { A15, A16, A17, - RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 18 arguments as a temporary Snowflake Java UDF that you @@ -1214,9 +1258,10 @@ class UDFRegistration(session: Session) extends Logging { A16, A17, A18, - RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 19 arguments as a temporary Snowflake Java UDF that you @@ -1267,9 +1312,10 @@ class UDFRegistration(session: Session) extends Logging { A17, A18, A19, - RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 20 arguments as a temporary Snowflake Java UDF that you @@ -1322,9 +1368,10 @@ class UDFRegistration(session: Session) extends Logging { A18, A19, A20, - RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 21 arguments as a temporary Snowflake Java UDF that you @@ -1379,9 +1426,10 @@ class UDFRegistration(session: Session) extends Logging { A19, A20, A21, - RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } /** * Registers a Scala closure of 22 arguments as a temporary Snowflake Java UDF that you @@ -1438,9 +1486,10 @@ class UDFRegistration(session: Session) extends Logging { A20, A21, A22, - RT]): UserDefinedFunction = { - register(Some(name), _toUdf(func)) - } + RT]): UserDefinedFunction = + udf("registerTemporary", execName = name) { + register(Some(name), _toUdf(func)) + } // scalastyle:off line.size.limit /* Code below for _toUdf 0-22 generated by this script @@ -1465,7 +1514,8 @@ class UDFRegistration(session: Session) extends Logging { | * @param stageLocation Stage location where the JAR files for the UDF and its | * and its dependencies should be uploaded. | */ - |def registerPermanent[$typeTags](name: String, func: Function$x[$types], stageLocation: String): UserDefinedFunction = { + |def registerPermanent[$typeTags](name: String, func: Function$x[$types], stageLocation: String): UserDefinedFunction = + | udf("registerPermanent", execName = name, execFilePath = stageLocation) { | register(Some(name), _toUdf(func), Some(stageLocation)) |}""".stripMargin) } @@ -1488,9 +1538,10 @@ class UDFRegistration(session: Session) extends Logging { def registerPermanent[RT: TypeTag]( name: String, func: Function0[RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 1 argument as a Snowflake Java UDF. @@ -1510,9 +1561,10 @@ class UDFRegistration(session: Session) extends Logging { def registerPermanent[RT: TypeTag, A1: TypeTag]( name: String, func: Function1[A1, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 2 arguments as a Snowflake Java UDF. @@ -1532,9 +1584,10 @@ class UDFRegistration(session: Session) extends Logging { def registerPermanent[RT: TypeTag, A1: TypeTag, A2: TypeTag]( name: String, func: Function2[A1, A2, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 3 arguments as a Snowflake Java UDF. @@ -1554,9 +1607,10 @@ class UDFRegistration(session: Session) extends Logging { def registerPermanent[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag]( name: String, func: Function3[A1, A2, A3, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 4 arguments as a Snowflake Java UDF. @@ -1576,9 +1630,10 @@ class UDFRegistration(session: Session) extends Logging { def registerPermanent[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag]( name: String, func: Function4[A1, A2, A3, A4, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 5 arguments as a Snowflake Java UDF. @@ -1604,9 +1659,10 @@ class UDFRegistration(session: Session) extends Logging { A5: TypeTag]( name: String, func: Function5[A1, A2, A3, A4, A5, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 6 arguments as a Snowflake Java UDF. @@ -1633,9 +1689,10 @@ class UDFRegistration(session: Session) extends Logging { A6: TypeTag]( name: String, func: Function6[A1, A2, A3, A4, A5, A6, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 7 arguments as a Snowflake Java UDF. @@ -1663,9 +1720,10 @@ class UDFRegistration(session: Session) extends Logging { A7: TypeTag]( name: String, func: Function7[A1, A2, A3, A4, A5, A6, A7, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 8 arguments as a Snowflake Java UDF. @@ -1694,9 +1752,10 @@ class UDFRegistration(session: Session) extends Logging { A8: TypeTag]( name: String, func: Function8[A1, A2, A3, A4, A5, A6, A7, A8, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 9 arguments as a Snowflake Java UDF. @@ -1726,9 +1785,10 @@ class UDFRegistration(session: Session) extends Logging { A9: TypeTag]( name: String, func: Function9[A1, A2, A3, A4, A5, A6, A7, A8, A9, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 10 arguments as a Snowflake Java UDF. @@ -1759,9 +1819,10 @@ class UDFRegistration(session: Session) extends Logging { A10: TypeTag]( name: String, func: Function10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 11 arguments as a Snowflake Java UDF. @@ -1793,9 +1854,10 @@ class UDFRegistration(session: Session) extends Logging { A11: TypeTag]( name: String, func: Function11[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 12 arguments as a Snowflake Java UDF. @@ -1828,9 +1890,10 @@ class UDFRegistration(session: Session) extends Logging { A12: TypeTag]( name: String, func: Function12[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 13 arguments as a Snowflake Java UDF. @@ -1864,9 +1927,10 @@ class UDFRegistration(session: Session) extends Logging { A13: TypeTag]( name: String, func: Function13[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 14 arguments as a Snowflake Java UDF. @@ -1901,9 +1965,10 @@ class UDFRegistration(session: Session) extends Logging { A14: TypeTag]( name: String, func: Function14[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 15 arguments as a Snowflake Java UDF. @@ -1939,9 +2004,10 @@ class UDFRegistration(session: Session) extends Logging { A15: TypeTag]( name: String, func: Function15[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 16 arguments as a Snowflake Java UDF. @@ -1978,9 +2044,10 @@ class UDFRegistration(session: Session) extends Logging { A16: TypeTag]( name: String, func: Function16[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 17 arguments as a Snowflake Java UDF. @@ -2036,9 +2103,10 @@ class UDFRegistration(session: Session) extends Logging { A16, A17, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 18 arguments as a Snowflake Java UDF. @@ -2096,9 +2164,10 @@ class UDFRegistration(session: Session) extends Logging { A17, A18, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 19 arguments as a Snowflake Java UDF. @@ -2158,9 +2227,10 @@ class UDFRegistration(session: Session) extends Logging { A18, A19, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 20 arguments as a Snowflake Java UDF. @@ -2222,9 +2292,10 @@ class UDFRegistration(session: Session) extends Logging { A19, A20, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 21 arguments as a Snowflake Java UDF. @@ -2288,9 +2359,10 @@ class UDFRegistration(session: Session) extends Logging { A20, A21, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } /** * Registers a Scala closure of 22 arguments as a Snowflake Java UDF. @@ -2356,9 +2428,10 @@ class UDFRegistration(session: Session) extends Logging { A21, A22, RT], - stageLocation: String): UserDefinedFunction = { - register(Some(name), _toUdf(func), Some(stageLocation)) - } + stageLocation: String): UserDefinedFunction = + udf("registerPermanent", execName = name, execFilePath = stageLocation) { + register(Some(name), _toUdf(func), Some(stageLocation)) + } private[snowpark] def register( name: Option[String], @@ -2366,4 +2439,15 @@ class UDFRegistration(session: Session) extends Logging { // if stageLocation is none, this udf will be temporary udf stageLocation: Option[String] = None): UserDefinedFunction = handler.registerUDF(name, udf, stageLocation) + + @inline protected def udf(funcName: String, execName: String = "", execFilePath: String = "")( + func: => UserDefinedFunction): UserDefinedFunction = { + OpenTelemetry.udx( + "UDFRegistration", + funcName, + execName, + s"${UDXRegistrationHandler.className}.${UDXRegistrationHandler.methodName}", + execFilePath, + 0)(func) + } } diff --git a/src/main/scala/com/snowflake/snowpark/UDTFRegistration.scala b/src/main/scala/com/snowflake/snowpark/UDTFRegistration.scala index fab1d4a7..2f553ee3 100644 --- a/src/main/scala/com/snowflake/snowpark/UDTFRegistration.scala +++ b/src/main/scala/com/snowflake/snowpark/UDTFRegistration.scala @@ -1,6 +1,6 @@ package com.snowflake.snowpark -import com.snowflake.snowpark.internal.{Logging, UDXRegistrationHandler} +import com.snowflake.snowpark.internal.{Logging, OpenTelemetry, UDXRegistrationHandler} import com.snowflake.snowpark.udtf.UDTF import com.snowflake.snowpark_java.udtf.JavaUDTF @@ -176,7 +176,9 @@ class UDTFRegistration(session: Session) extends Logging { * @param udtf The UDTF instance to be registered * @since 1.2.0 */ - def registerTemporary(udtf: UDTF): TableFunction = handler.registerUDTF(None, udtf) + def registerTemporary(udtf: UDTF): TableFunction = tableFunction("registerTemporary") { + handler.registerUDTF(None, udtf) + } /** * Registers an UDTF instance as a temporary Snowflake Java UDTF that you @@ -187,7 +189,9 @@ class UDTFRegistration(session: Session) extends Logging { * @since 1.2.0 */ def registerTemporary(funcName: String, udtf: UDTF): TableFunction = - handler.registerUDTF(Some(funcName), udtf) + tableFunction("registerTemporary", execName = funcName) { + handler.registerUDTF(Some(funcName), udtf) + } /** * Registers an UDTF instance as a Snowflake Java UDTF. @@ -206,7 +210,9 @@ class UDTFRegistration(session: Session) extends Logging { * @since 1.2.0 */ def registerPermanent(funcName: String, udtf: UDTF, stageLocation: String): TableFunction = - handler.registerUDTF(Some(funcName), udtf, Some(stageLocation)) + tableFunction("registerPermanent", execName = funcName, execFilePath = stageLocation) { + handler.registerUDTF(Some(funcName), udtf, Some(stageLocation)) + } // Internal function for Java API UDTF support private[snowpark] def registerJavaUDTF( @@ -214,4 +220,17 @@ class UDTFRegistration(session: Session) extends Logging { udtf: JavaUDTF, stageLocation: Option[String]): TableFunction = handler.registerJavaUDTF(name, udtf, stageLocation) + + @inline protected def tableFunction( + funcName: String, + execName: String = "", + execFilePath: String = "")(func: => TableFunction): TableFunction = { + OpenTelemetry.udx( + "UDTFRegistration", + funcName, + execName, + UDXRegistrationHandler.udtfClassName, + execFilePath, + 0)(func) + } } diff --git a/src/main/scala/com/snowflake/snowpark/functions.scala b/src/main/scala/com/snowflake/snowpark/functions.scala index 0f48d01f..db5d76a5 100644 --- a/src/main/scala/com/snowflake/snowpark/functions.scala +++ b/src/main/scala/com/snowflake/snowpark/functions.scala @@ -2,7 +2,12 @@ package com.snowflake.snowpark import com.snowflake.snowpark.internal.analyzer._ import com.snowflake.snowpark.internal.ScalaFunctions._ -import com.snowflake.snowpark.internal.{ErrorMessage, Utils} +import com.snowflake.snowpark.internal.{ + ErrorMessage, + OpenTelemetry, + UDXRegistrationHandler, + Utils +} import scala.reflect.runtime.universe.TypeTag import scala.util.Random @@ -3183,7 +3188,7 @@ object functions { | * @group udf_func | * @since $version | */ - |def udf[$typeTags](func: Function$x[$types]): UserDefinedFunction = { + |def udf[$typeTags](func: Function$x[$types]): UserDefinedFunction = udf("udf") { | registerUdf(_toUdf(func)) |}""".stripMargin) } @@ -3195,7 +3200,7 @@ object functions { * @group udf_func * @since 0.1.0 */ - def udf[RT: TypeTag](func: Function0[RT]): UserDefinedFunction = { + def udf[RT: TypeTag](func: Function0[RT]): UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3205,7 +3210,7 @@ object functions { * @group udf_func * @since 0.1.0 */ - def udf[RT: TypeTag, A1: TypeTag](func: Function1[A1, RT]): UserDefinedFunction = { + def udf[RT: TypeTag, A1: TypeTag](func: Function1[A1, RT]): UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3216,7 +3221,7 @@ object functions { * @since 0.1.0 */ def udf[RT: TypeTag, A1: TypeTag, A2: TypeTag]( - func: Function2[A1, A2, RT]): UserDefinedFunction = { + func: Function2[A1, A2, RT]): UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3227,7 +3232,7 @@ object functions { * @since 0.1.0 */ def udf[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag]( - func: Function3[A1, A2, A3, RT]): UserDefinedFunction = { + func: Function3[A1, A2, A3, RT]): UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3238,7 +3243,7 @@ object functions { * @since 0.1.0 */ def udf[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag]( - func: Function4[A1, A2, A3, A4, RT]): UserDefinedFunction = { + func: Function4[A1, A2, A3, A4, RT]): UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3249,7 +3254,7 @@ object functions { * @since 0.1.0 */ def udf[RT: TypeTag, A1: TypeTag, A2: TypeTag, A3: TypeTag, A4: TypeTag, A5: TypeTag]( - func: Function5[A1, A2, A3, A4, A5, RT]): UserDefinedFunction = { + func: Function5[A1, A2, A3, A4, A5, RT]): UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3266,9 +3271,10 @@ object functions { A3: TypeTag, A4: TypeTag, A5: TypeTag, - A6: TypeTag](func: Function6[A1, A2, A3, A4, A5, A6, RT]): UserDefinedFunction = { - registerUdf(_toUdf(func)) - } + A6: TypeTag](func: Function6[A1, A2, A3, A4, A5, A6, RT]): UserDefinedFunction = + udf("udf") { + registerUdf(_toUdf(func)) + } /** * Registers a Scala closure of 7 arguments as a Snowflake Java UDF and returns the UDF. @@ -3284,9 +3290,10 @@ object functions { A4: TypeTag, A5: TypeTag, A6: TypeTag, - A7: TypeTag](func: Function7[A1, A2, A3, A4, A5, A6, A7, RT]): UserDefinedFunction = { - registerUdf(_toUdf(func)) - } + A7: TypeTag](func: Function7[A1, A2, A3, A4, A5, A6, A7, RT]): UserDefinedFunction = + udf("udf") { + registerUdf(_toUdf(func)) + } /** * Registers a Scala closure of 8 arguments as a Snowflake Java UDF and returns the UDF. @@ -3303,9 +3310,10 @@ object functions { A5: TypeTag, A6: TypeTag, A7: TypeTag, - A8: TypeTag](func: Function8[A1, A2, A3, A4, A5, A6, A7, A8, RT]): UserDefinedFunction = { - registerUdf(_toUdf(func)) - } + A8: TypeTag](func: Function8[A1, A2, A3, A4, A5, A6, A7, A8, RT]): UserDefinedFunction = + udf("udf") { + registerUdf(_toUdf(func)) + } /** * Registers a Scala closure of 9 arguments as a Snowflake Java UDF and returns the UDF. @@ -3323,10 +3331,10 @@ object functions { A6: TypeTag, A7: TypeTag, A8: TypeTag, - A9: TypeTag]( - func: Function9[A1, A2, A3, A4, A5, A6, A7, A8, A9, RT]): UserDefinedFunction = { - registerUdf(_toUdf(func)) - } + A9: TypeTag](func: Function9[A1, A2, A3, A4, A5, A6, A7, A8, A9, RT]): UserDefinedFunction = + udf("udf") { + registerUdf(_toUdf(func)) + } /** * Registers a Scala closure of 10 arguments as a Snowflake Java UDF and returns the UDF. @@ -3346,9 +3354,10 @@ object functions { A8: TypeTag, A9: TypeTag, A10: TypeTag]( - func: Function10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, RT]): UserDefinedFunction = { - registerUdf(_toUdf(func)) - } + func: Function10[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, RT]): UserDefinedFunction = + udf("udf") { + registerUdf(_toUdf(func)) + } /** * Registers a Scala closure of 11 arguments as a Snowflake Java UDF and returns the UDF. @@ -3369,9 +3378,10 @@ object functions { A9: TypeTag, A10: TypeTag, A11: TypeTag]( - func: Function11[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, RT]): UserDefinedFunction = { - registerUdf(_toUdf(func)) - } + func: Function11[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, RT]): UserDefinedFunction = + udf("udf") { + registerUdf(_toUdf(func)) + } /** * Registers a Scala closure of 12 arguments as a Snowflake Java UDF and returns the UDF. @@ -3393,7 +3403,7 @@ object functions { A10: TypeTag, A11: TypeTag, A12: TypeTag](func: Function12[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, RT]) - : UserDefinedFunction = { + : UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3418,7 +3428,7 @@ object functions { A11: TypeTag, A12: TypeTag, A13: TypeTag](func: Function13[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, RT]) - : UserDefinedFunction = { + : UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3445,7 +3455,7 @@ object functions { A13: TypeTag, A14: TypeTag]( func: Function14[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, RT]) - : UserDefinedFunction = { + : UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3473,7 +3483,7 @@ object functions { A14: TypeTag, A15: TypeTag]( func: Function15[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, RT]) - : UserDefinedFunction = { + : UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3502,7 +3512,7 @@ object functions { A15: TypeTag, A16: TypeTag]( func: Function16[A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, RT]) - : UserDefinedFunction = { + : UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3549,7 +3559,7 @@ object functions { A15, A16, A17, - RT]): UserDefinedFunction = { + RT]): UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3598,7 +3608,7 @@ object functions { A16, A17, A18, - RT]): UserDefinedFunction = { + RT]): UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3649,7 +3659,7 @@ object functions { A17, A18, A19, - RT]): UserDefinedFunction = { + RT]): UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3702,7 +3712,7 @@ object functions { A18, A19, A20, - RT]): UserDefinedFunction = { + RT]): UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3757,7 +3767,7 @@ object functions { A19, A20, A21, - RT]): UserDefinedFunction = { + RT]): UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3814,7 +3824,7 @@ object functions { A20, A21, A22, - RT]): UserDefinedFunction = { + RT]): UserDefinedFunction = udf("udf") { registerUdf(_toUdf(func)) } @@ -3847,4 +3857,15 @@ object functions { Column(FunctionExpression(name, exprs, isDistinct)) } + @inline protected def udf(funcName: String)( + func: => UserDefinedFunction): UserDefinedFunction = { + OpenTelemetry.udx( + "functions", + funcName, + "", + s"${UDXRegistrationHandler.className}.${UDXRegistrationHandler.methodName}", + "", + 0)(func) + } + } diff --git a/src/main/scala/com/snowflake/snowpark/internal/OpenTelemetry.scala b/src/main/scala/com/snowflake/snowpark/internal/OpenTelemetry.scala index 6d9d4248..975f79a4 100644 --- a/src/main/scala/com/snowflake/snowpark/internal/OpenTelemetry.scala +++ b/src/main/scala/com/snowflake/snowpark/internal/OpenTelemetry.scala @@ -3,13 +3,105 @@ package com.snowflake.snowpark.internal import io.opentelemetry.api.GlobalOpenTelemetry import io.opentelemetry.api.trace.{Span, StatusCode} +import java.util.function.Supplier import scala.util.DynamicVariable +import com.snowflake.snowpark_java.{ + UserDefinedFunction => JavaUDF, + TableFunction => JavaTableFunction, + StoredProcedure => JavaSProc +} object OpenTelemetry extends Logging { - // only report the top function info in case of recursion. - private val actionInfo = new DynamicVariable[Option[ActionInfo]](None) + private val spanInfo = new DynamicVariable[Option[SpanInfo]](None) + + // Java API + def javaUDF( + className: String, + funcName: String, + execName: String, + execFilePath: String, + stackOffset: Int, + func: Supplier[JavaUDF]): JavaUDF = { + udx( + className, + funcName, + execName, + s"${UDXRegistrationHandler.className}.${UDXRegistrationHandler.methodName}", + execFilePath, + stackOffset + 2)(func.get()) + } + def javaUDTF( + className: String, + funcName: String, + execName: String, + execFilePath: String, + stackOffset: Int, + func: Supplier[JavaTableFunction]): JavaTableFunction = { + udx( + className, + funcName, + execName, + UDXRegistrationHandler.udtfClassName, + execFilePath, + stackOffset + 2)(func.get()) + } + def javaSProc( + className: String, + funcName: String, + execName: String, + execFilePath: String, + stackOffset: Int, + func: Supplier[JavaSProc]): JavaSProc = { + udx( + className, + funcName, + execName, + s"${UDXRegistrationHandler.className}.${UDXRegistrationHandler.methodName}", + execFilePath, + stackOffset + 2)(func.get()) + } + + // Scala API + def udx[T]( + className: String, + funcName: String, + execName: String, + execHandler: String, + execFilePath: String, + stackOffset: Int)(func: => T): T = { + try { + spanInfo.withValue[T](spanInfo.value match { + // empty info means this is the entry of the recursion + case None => + val stacks = Thread.currentThread().getStackTrace + val index = 4 + stackOffset + val fileName = stacks(index).getFileName + val lineNumber = stacks(index).getLineNumber + Some( + UdfInfo( + className, + funcName, + fileName, + lineNumber, + execName, + execHandler, + execFilePath)) + // if value is not empty, this function call should be recursion. + // do not issue new SpanInfo, use the info inherited from previous. + case other => other + }) { + val result: T = func + OpenTelemetry.emit(spanInfo.value.get) + result + } + } catch { + case error: Throwable => + OpenTelemetry.reportError(className, funcName, error) + throw error + } + } // wrapper of all action functions def action[T]( className: String, @@ -18,7 +110,7 @@ object OpenTelemetry extends Logging { isScala: Boolean, javaOffSet: Int = 0)(func: => T): T = { try { - actionInfo.withValue[T](actionInfo.value match { + spanInfo.withValue[T](spanInfo.value match { // empty info means this is the entry of the recursion case None => val stacks = Thread.currentThread().getStackTrace @@ -31,7 +123,7 @@ object OpenTelemetry extends Logging { case other => other }) { val result: T = func - OpenTelemetry.emit(actionInfo.value.get) + OpenTelemetry.emit(spanInfo.value.get) result } } catch { @@ -40,14 +132,20 @@ object OpenTelemetry extends Logging { throw error } } - // class name format: snow.snowpark. - // method chain: Dataframe.filter.join.select.collect - def emit(spanInfo: ActionInfo): Unit = - emit(spanInfo.className, spanInfo.funcName) { span => + + def emit(info: SpanInfo): Unit = + emit(info.className, info.funcName) { span => { - span.setAttribute("code.filepath", spanInfo.fileName) - span.setAttribute("code.lineno", spanInfo.lineNumber) - span.setAttribute("method.chain", spanInfo.methodChain) + span.setAttribute("code.filepath", info.fileName) + span.setAttribute("code.lineno", info.lineNumber) + info match { + case ActionInfo(_, _, _, _, methodChain) => + span.setAttribute("method.chain", methodChain) + case UdfInfo(_, _, _, _, execName, execHandler, execFilePath) => + span.setAttribute("snow.executable.name", execName) + span.setAttribute("snow.executable.handler", execHandler) + span.setAttribute("snow.executable.filepath", execFilePath) + } } } @@ -81,9 +179,27 @@ object OpenTelemetry extends Logging { } +trait SpanInfo { + val className: String + val funcName: String + val fileName: String + val lineNumber: Int +} + case class ActionInfo( - className: String, - funcName: String, - fileName: String, - lineNumber: Int, + override val className: String, + override val funcName: String, + override val fileName: String, + override val lineNumber: Int, methodChain: String) + extends SpanInfo + +case class UdfInfo( + override val className: String, + override val funcName: String, + override val fileName: String, + override val lineNumber: Int, + execName: String, + execHandler: String, + execFilePath: String) + extends SpanInfo diff --git a/src/main/scala/com/snowflake/snowpark/internal/UDXRegistrationHandler.scala b/src/main/scala/com/snowflake/snowpark/internal/UDXRegistrationHandler.scala index acf9b62e..dad001f6 100644 --- a/src/main/scala/com/snowflake/snowpark/internal/UDXRegistrationHandler.scala +++ b/src/main/scala/com/snowflake/snowpark/internal/UDXRegistrationHandler.scala @@ -27,12 +27,18 @@ import scala.reflect.internal.util.AbstractFileClassLoader import scala.reflect.io.{AbstractFile, VirtualDirectory} import scala.util.Random -class UDXRegistrationHandler(session: Session) extends Logging { +import UDXRegistrationHandler._ + +object UDXRegistrationHandler { // Class name for generated Java code - private val className = "SnowUDF" + val className = "SnowUDF" // Method name for generated Java code - private val methodName = "compute" - private val udtfClassName = "SnowparkGeneratedUDTF" + val methodName = "compute" + val udtfClassName = "SnowparkGeneratedUDTF" +} + +class UDXRegistrationHandler(session: Session) extends Logging { + private val jarBuilder = new FatJarBuilder() private val javaUdtfDefaultStructType = diff --git a/src/test/java/com/snowflake/snowpark_test/JavaUDTFNonStoredProcSuite.java b/src/test/java/com/snowflake/snowpark_test/JavaUDTFNonStoredProcSuite.java index f13d59c9..9caa7e10 100644 --- a/src/test/java/com/snowflake/snowpark_test/JavaUDTFNonStoredProcSuite.java +++ b/src/test/java/com/snowflake/snowpark_test/JavaUDTFNonStoredProcSuite.java @@ -119,6 +119,8 @@ public void testPermanentUdtf() { Row[] rows2 = getAnotherSession().tableFunction(permFunc, lit(3), lit(4)).collect(); assert rows2.length == 1 && rows2[0].size() == 1 && rows2[0].getInt(0) == 7; + getSession().sql("drop function " + permFunc.funcName() + "(int, int)").collect(); + TableFunction tempFunc = getSession().udtf().registerTemporary(new MyJavaUDTFOf2()); // use temp UDTF in current session Row[] rows3 = getSession().tableFunction(tempFunc, lit(11), lit(22)).collect(); diff --git a/src/test/java/com/snowflake/snowpark_test/JavaUDXOpenTelemetryEnabled.java b/src/test/java/com/snowflake/snowpark_test/JavaUDXOpenTelemetryEnabled.java new file mode 100644 index 00000000..e0901965 --- /dev/null +++ b/src/test/java/com/snowflake/snowpark_test/JavaUDXOpenTelemetryEnabled.java @@ -0,0 +1,58 @@ +package com.snowflake.snowpark_test; + +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.exporters.inmemory.InMemorySpanExporter; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import io.opentelemetry.sdk.resources.Resource; +import io.opentelemetry.sdk.trace.SdkTracerProvider; +import io.opentelemetry.sdk.trace.data.SpanData; +import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; +import java.util.Objects; + +public abstract class JavaUDXOpenTelemetryEnabled extends UDFTestBase { + protected InMemorySpanExporter testSpanExporter = init(); + + private InMemorySpanExporter init() { + InMemorySpanExporter testExporter = InMemorySpanExporter.create(); + GlobalOpenTelemetry.resetForTest(); + Resource resource = + Resource.getDefault() + .toBuilder() + .put("service.name", "test-server") + .put("service.version", "0.1.0") + .build(); + SdkTracerProvider sdkTracerProvider = + SdkTracerProvider.builder() + .addSpanProcessor(SimpleSpanProcessor.create(testExporter)) + .setResource(resource) + .build(); + OpenTelemetrySdk.builder().setTracerProvider(sdkTracerProvider).buildAndRegisterGlobal(); + return testExporter; + } + + protected void checkSpan( + String className, + String funcName, + String fileName, + int lineNumber, + String execName, + String execHandler, + String execFilePath) { + SpanData span = testSpanExporter.getFinishedSpanItems().get(0); + assert span.getName().equals(funcName); + assert span.getInstrumentationScopeInfo().getName().equals(className); + assert span.getTotalAttributeCount() == 5; + assert Objects.equals( + span.getAttributes().get(AttributeKey.stringKey("code.filepath")), fileName); + assert Objects.equals( + span.getAttributes().get(AttributeKey.longKey("code.lineno")), (long) lineNumber); + assert Objects.equals( + span.getAttributes().get(AttributeKey.stringKey("snow.executable.name")), execName); + assert Objects.equals( + span.getAttributes().get(AttributeKey.stringKey("snow.executable.handler")), execHandler); + assert Objects.equals( + span.getAttributes().get(AttributeKey.stringKey("snow.executable.filepath")), execFilePath); + testSpanExporter.reset(); + } +} diff --git a/src/test/java/com/snowflake/snowpark_test/JavaUDXOpenTelemetrySuite.java b/src/test/java/com/snowflake/snowpark_test/JavaUDXOpenTelemetrySuite.java new file mode 100644 index 00000000..a213f813 --- /dev/null +++ b/src/test/java/com/snowflake/snowpark_test/JavaUDXOpenTelemetrySuite.java @@ -0,0 +1,121 @@ +package com.snowflake.snowpark_test; + +import com.snowflake.snowpark_java.Functions; +import com.snowflake.snowpark_java.Session; +import com.snowflake.snowpark_java.sproc.JavaSProc0; +import com.snowflake.snowpark_java.types.DataTypes; +import com.snowflake.snowpark_java.udf.JavaUDF0; +import org.junit.Test; + +public class JavaUDXOpenTelemetrySuite extends JavaUDXOpenTelemetryEnabled { + + public JavaUDXOpenTelemetrySuite() {} + + private boolean dependencyAdded = false; + + @Override + public Session getSession() { + Session session = super.getSession(); + if (!dependencyAdded) { + dependencyAdded = true; + addDepsToClassPath(session); + } + testSpanExporter.reset(); + return session; + } + + @Test + public void udf() { + String className = "snow.snowpark.UDFRegistration"; + String className2 = "snow.snowpark.Functions"; + JavaUDF0 func = () -> 100; + getSession().udf().registerTemporary(func, DataTypes.IntegerType); + checkUdfSpan(className, "registerTemporary", "", ""); + String funcName = randomFunctionName(); + String funcName2 = randomFunctionName(); + getSession().udf().registerTemporary(funcName, func, DataTypes.IntegerType); + checkUdfSpan(className, "registerTemporary", funcName, ""); + Functions.udf(func, DataTypes.IntegerType); + checkUdfSpan(className2, "udf", "", ""); + + String stageName = randomName(); + try { + createStage(stageName, false); + getSession().udf().registerPermanent(funcName2, func, DataTypes.IntegerType, stageName); + checkUdfSpan(className, "registerPermanent", funcName2, stageName); + } finally { + dropStage(stageName); + getSession().sql("drop function " + funcName2 + "()").collect(); + } + } + + @Test + public void udtf() { + String className = "snow.snowpark.UDTFRegistration"; + getSession().udtf().registerTemporary(new MyJavaUDTFOf0()); + checkUdtfSpan(className, "registerTemporary", "", ""); + String funcName = randomFunctionName(); + String funcName2 = randomFunctionName(); + getSession().udtf().registerTemporary(funcName, new MyJavaUDTFOf0()); + checkUdtfSpan(className, "registerTemporary", funcName, ""); + + String stageName = randomStageName(); + try { + createStage(stageName, false); + getSession().udtf().registerPermanent(funcName2, new MyJavaUDTFOf2(), stageName); + checkUdtfSpan(className, "registerPermanent", funcName2, stageName); + } finally { + getSession().sql("drop function " + funcName2 + "(int, int)").collect(); + dropStage(stageName); + } + } + + @Test + public void sproc() { + String className = "snow.snowpark.SProcRegistration"; + String spName = randomName(); + String spName2 = randomName(); + String stageName = randomStageName(); + JavaSProc0 sproc = session -> "SUCCESS"; + getSession().sproc().registerTemporary(sproc, DataTypes.StringType); + checkUdfSpan(className, "registerTemporary", "", ""); + getSession().sproc().registerTemporary(spName2, sproc, DataTypes.StringType); + checkUdfSpan(className, "registerTemporary", spName2, ""); + try { + createStage(stageName, false); + getSession().sproc().registerPermanent(spName, sproc, DataTypes.StringType, stageName, true); + checkUdfSpan(className, "registerPermanent", spName, stageName); + } finally { + dropStage(stageName); + getSession().sql("drop procedure " + spName + "()").collect(); + } + } + + private void checkUdfSpan( + String className, String funcName, String execName, String execFilePath) { + StackTraceElement[] stack = Thread.currentThread().getStackTrace(); + StackTraceElement file = stack[2]; + checkSpan( + className, + funcName, + "JavaUDXOpenTelemetrySuite.java", + file.getLineNumber() - 1, + execName, + "SnowUDF.compute", + execFilePath); + } + + private void checkUdtfSpan( + String className, String funcName, String execName, String execFilePath) { + StackTraceElement[] stack = Thread.currentThread().getStackTrace(); + StackTraceElement file = stack[2]; + checkSpan( + className, + funcName, + "JavaUDXOpenTelemetrySuite.java", + file.getLineNumber() - 1, + execName, + "SnowparkGeneratedUDTF", + execFilePath); + } +} diff --git a/src/test/scala/com/snowflake/snowpark/JavaAPISuite.scala b/src/test/scala/com/snowflake/snowpark/JavaAPISuite.scala index 36caa9af..cdccb9b6 100644 --- a/src/test/scala/com/snowflake/snowpark/JavaAPISuite.scala +++ b/src/test/scala/com/snowflake/snowpark/JavaAPISuite.scala @@ -124,6 +124,10 @@ class JavaAPISuite extends FunSuite { TestRunner.run(classOf[JavaOpenTelemetrySuite]) } + test("Java UDX OpenTelemetry") { + TestRunner.run(classOf[JavaUDXOpenTelemetrySuite]) + } + // some tests can't be implemented in Java are listed below // console redirect doesn't work in Java since run JUnit from Scala diff --git a/src/test/scala/com/snowflake/snowpark/OpenTelemetryEnabled.scala b/src/test/scala/com/snowflake/snowpark/OpenTelemetryEnabled.scala index 949014ce..902f8fca 100644 --- a/src/test/scala/com/snowflake/snowpark/OpenTelemetryEnabled.scala +++ b/src/test/scala/com/snowflake/snowpark/OpenTelemetryEnabled.scala @@ -49,6 +49,29 @@ trait OpenTelemetryEnabled extends TestData { } } + def checkSpan( + className: String, + funcName: String, + fileName: String, + lineNumber: Int, + execName: String, + execHandler: String, + execFilePath: String): Unit = + checkSpan(className, funcName) { span => + { + assert(span.getTotalAttributeCount == 5) + assert(span.getAttributes.get(AttributeKey.stringKey("code.filepath")) == fileName) + assert(span.getAttributes.get(AttributeKey.longKey("code.lineno")) == lineNumber) + assert(span.getAttributes.get(AttributeKey.stringKey("snow.executable.name")) == execName) + assert( + span.getAttributes + .get(AttributeKey.stringKey("snow.executable.handler")) == execHandler) + assert( + span.getAttributes + .get(AttributeKey.stringKey("snow.executable.filepath")) == execFilePath) + } + } + def checkSpan(className: String, funcName: String)(func: SpanData => Unit): Unit = { val span: SpanData = testSpanExporter.getFinishedSpanItems.get(0) assert(span.getName == funcName) diff --git a/src/test/scala/com/snowflake/snowpark/TestUtils.scala b/src/test/scala/com/snowflake/snowpark/TestUtils.scala index e1abedff..84b9393a 100644 --- a/src/test/scala/com/snowflake/snowpark/TestUtils.scala +++ b/src/test/scala/com/snowflake/snowpark/TestUtils.scala @@ -143,8 +143,10 @@ object TestUtils extends Logging { List( classOf[BeforeAndAfterAll], // scala test jar - classOf[org.scalactic.TripleEquals] // scalactic jar - ).flatMap(UDFClassPath.getPathForClass(_)) + classOf[org.scalactic.TripleEquals], // scalactic jar + classOf[io.opentelemetry.exporters.inmemory.InMemorySpanExporter], + classOf[io.opentelemetry.sdk.trace.export.SpanExporter]) + .flatMap(UDFClassPath.getPathForClass(_)) .foreach(path => { val file = new File(path) sess.conn @@ -172,8 +174,10 @@ object TestUtils extends Logging { List( classOf[BeforeAndAfterAll], // scala test jar - classOf[org.scalactic.TripleEquals] // scalactic jar - ).flatMap(UDFClassPath.getPathForClass(_)) + classOf[org.scalactic.TripleEquals], // scalactic jar + classOf[io.opentelemetry.exporters.inmemory.InMemorySpanExporter], + classOf[io.opentelemetry.sdk.trace.export.SpanExporter]) + .flatMap(UDFClassPath.getPathForClass(_)) .foreach(path => { val file = new File(path) sess.sql(s"put file://$path @$stage/ AUTO_COMPRESS = FALSE").collect() diff --git a/src/test/scala/com/snowflake/snowpark_test/UdxOpenTelemetrySuite.scala b/src/test/scala/com/snowflake/snowpark_test/UdxOpenTelemetrySuite.scala new file mode 100644 index 00000000..8f21b2fd --- /dev/null +++ b/src/test/scala/com/snowflake/snowpark_test/UdxOpenTelemetrySuite.scala @@ -0,0 +1,117 @@ +package com.snowflake.snowpark_test + +import com.snowflake.snowpark.types.{IntegerType, StructField, StructType} +import com.snowflake.snowpark.udtf.UDTF0 +import com.snowflake.snowpark.{OpenTelemetryEnabled, Row, Session, TestUtils, functions} + +class UdxOpenTelemetrySuite extends OpenTelemetryEnabled { + override def beforeAll: Unit = { + super.beforeAll + if (!isStoredProc(session)) { + TestUtils.addDepsToClassPath(session) + } + } + + test("udf") { + val className = "snow.snowpark.UDFRegistration" + val func = () => 100 + session.udf.registerTemporary(func) + checkUdfSpan(className, "registerTemporary", "", "") + val udfName = randomName() + session.udf.registerTemporary(udfName, func) + checkUdfSpan(className, "registerTemporary", udfName, "") + functions.udf(func) + checkUdfSpan("snow.snowpark.functions", "udf", "", "") + val stageName = randomName() + val udfName2 = randomFunctionName() + try { + createStage(stageName, isTemporary = false) + session.udf.registerPermanent(udfName2, func, stageName) + checkUdfSpan(className, "registerPermanent", udfName2, stageName) + } finally { + runQuery(s"drop function $udfName2()", session) + dropStage(stageName) + } + } + + test("udtf") { + val className = "snow.snowpark.UDTFRegistration" + class MyUDTF0 extends UDTF0 { + override def process(): Iterable[Row] = { + Seq(Row(123), Row(123)) + } + override def endPartition(): Iterable[Row] = Seq.empty + override def outputSchema(): StructType = StructType(StructField("sum", IntegerType)) + } + session.udtf.registerTemporary(new MyUDTF0()) + checkUdtfSpan(className, "registerTemporary", "", "") + val udtfName = randomFunctionName() + session.udtf.registerTemporary(udtfName, new MyUDTF0) + checkUdtfSpan(className, "registerTemporary", udtfName, "") + + val stageName: String = randomName() + val udtfName2 = randomFunctionName() + try { + createStage(stageName, isTemporary = false) + session.udtf.registerPermanent(udtfName2, new MyUDTF0(), stageName) + checkUdtfSpan(className, "registerPermanent", udtfName2, stageName) + } finally { + runQuery(s"drop function $udtfName2()", session) + dropStage(stageName) + } + } + + test("sproc") { + val className: String = "snow.snowpark.SProcRegistration" + val spName: String = randomName() + val stageName: String = randomName() + val spName1: String = randomName() + val sproc = (_: Session) => s"SUCCESS" + session.sproc.registerTemporary(sproc) + checkUdfSpan(className, "registerTemporary", "", "") + session.sproc.registerTemporary(spName1, sproc) + checkUdfSpan(className, "registerTemporary", spName1, "") + try { + createStage(stageName, isTemporary = false) + session.sproc.registerPermanent(spName, sproc, stageName, isCallerMode = true) + checkUdfSpan(className, "registerPermanent", spName, stageName) + } finally { + dropStage(stageName) + session.sql(s"drop procedure if exists $spName ()").show() + } + } + + def checkUdfSpan( + className: String, + funcName: String, + execName: String, + execFilePath: String): Unit = { + val stack = Thread.currentThread().getStackTrace + val file = stack(2) // this file + checkSpan( + className, + funcName, + "UdxOpenTelemetrySuite.scala", + file.getLineNumber - 1, + execName, + "SnowUDF.compute", + execFilePath) + } + + def checkUdtfSpan( + className: String, + funcName: String, + execName: String, + execFilePath: String): Unit = { + val stack = Thread.currentThread().getStackTrace + val file = stack(2) // this file + checkSpan( + className, + funcName, + "UdxOpenTelemetrySuite.scala", + file.getLineNumber - 1, + execName, + "SnowparkGeneratedUDTF", + execFilePath) + } +}