使用 Snowpark Java 分析查询和故障排除¶
本主题提供了一些有关在使用 Snowpark 库时分析查询和故障排除的指引。
在 Snowpark 中查看查询的执行计划¶
To inspect the evaluation plan of a DataFrame, call the explain method of the DataFrame. This prints the SQL statements
used to evaluate the DataFrame. If there is only one SQL statement, the method also prints the logical plan for the statement.
After the execution of a DataFrame has been triggered, you can check on the progress of the query in the Query History page in Snowsight.
In the Query Tag column, you can find the name of the function and the line number in your code that triggered this query.
更改日志记录设置
By default, the Snowpark library logs INFO level messages to stdout. To change the logging settings, create a
simplelogger.properties file, and configure the logger properties in that file. For example, to set the log level to
DEBUG:
Put this file in your classpath. If you are using a Maven directory layout, put the file in the src/main/resources/
directory.
java.lang.OutOfMemoryError 异常¶
If a java.lang.OutOfMemoryError exception is thrown, increase the maximum heap size for the JVM (e.g. through the
-J-Xmxmaximum_size flag).
Java 17 上的未命名模块错误¶
在 Java 17 上执行 Snowpark Java 或 Scala 客户端时,您可能会看到以下错误:
This is because Snowpark uses the Apache Arrow connector (https://arrow.apache.org/docs/java/install.html#id3), which depends on internal Java APIs that are not exposed by default after Java 9.
若要解决此错误,请在运行应用程序时或在系统的环境变量中将以下参数设置为命令行参数。
Note
Snowpark API 支持以下 Java 版本:
- 11.x
- 17.x
在运行应用程序时设置实参
您可以在运行应用程序时通过命令行设置此参数。
For example, when calling the java command, you can add --add-opens=java.base/java.nio=ALL-UNNAMED, as in the following:
If you are also using RSA private key authentication, you will also need to allow sun.security.util, as in the following example:
将参数设置为环境变量
您可以在系统的环境变量中设置参数。有关设置环境变量的说明,请参阅操作系统文档。
Create or update a JDK_JAVA_OPTIONS environment variable, as in the following Unix-based example:
If you are also using RSA private key authentication, you will also need to allow sun.security.util, as in the following example:
