Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-946574 Support Java 17 when Register UDF #74

Merged
merged 4 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/precommit-udf-multiple-jdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: precommit test - udf with multiple JDK
on:
push:
branches: [ main ]
pull_request:
branches: '**'

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 11, 17 ]
fail-fast: false
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Install Java
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: Decrypt profile.properties
run: .github/scripts/decrypt_profile.sh
env:
PROFILE_PASSWORD: ${{ secrets.PROFILE_PASSWORD }}
- name: Run test
run: mvn -Dgpg.skip test -Dsuites="com.snowflake.snowpark_test.AlwaysCleanUDFSuite"
2 changes: 2 additions & 0 deletions fips-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@
--add-opens=java.base/java.util=ALL-UNNAMED
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED
--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
--add-opens=java.base/sun.security.util=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
Expand All @@ -588,6 +589,7 @@
--add-opens=java.base/java.util=ALL-UNNAMED
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED
--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
--add-opens=java.base/sun.security.util=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
Expand Down
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@
--add-opens=java.base/java.util=ALL-UNNAMED
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED
--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
--add-opens=java.base/sun.security.util=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
Expand All @@ -620,6 +621,7 @@
--add-opens=java.base/java.util=ALL-UNNAMED
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED
--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
--add-opens=java.base/sun.security.util=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,8 @@ class UDXRegistrationHandler(session: Session) extends Logging {
} else ""
val createUdfQuery = s"CREATE $tempType " +
s"FUNCTION $udfName($sqlFunctionArgs) RETURNS " +
s"$returnSqlType LANGUAGE JAVA $importSql HANDLER='$className.$methodName' " +
s"$returnSqlType LANGUAGE JAVA $getRuntimeVersion " +
s"$importSql HANDLER='$className.$methodName' " +
s"target_path='$targetJarStageLocation' " + packageSql +
"AS $$ \n" + code + "\n$$"
logDebug(s"""
Expand Down Expand Up @@ -1156,4 +1157,15 @@ class UDXRegistrationHandler(session: Session) extends Logging {
}
}
}

private def getRuntimeVersion: String = {
val version = Utils.JavaVersion
if (version.startsWith("17")) {
"runtime_version = '17'"
} else {
// for any other version of JVM, let's use the default jvm, which is java 11.
// it is current behavior.
""
}
}
}
3 changes: 2 additions & 1 deletion src/test/scala/com/snowflake/snowpark_test/UDFSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2773,7 +2773,8 @@ trait UDFSuite extends TestData {

@UDFTest
class AlwaysCleanUDFSuite extends UDFSuite with AlwaysCleanSession {
test("Test with closure cleaner enabled") {
// todo: closure cleaner doesn't work with Java 17, fix in SNOW-991144
ignore("Test with closure cleaner enabled") {
val myDf = session.sql("select 'Raymond' NAME")
val readFileUdf = udf(TestClassWithoutFieldAccess.run)
myDf.withColumn("CONCAT", readFileUdf(col("NAME"))).show()
Expand Down
Loading