2025 年 Snowpark Library for Python 版本说明¶
本文包含 Snowpark Library for Python 的版本说明,包括以下内容(如果适用):
行为变更
新功能
面向客户的错误修复
Snowflake 对 Snowpark Library for Python 更新使用语义版本控制。
有关文档,请参阅 Snowpark Python 开发者指南。
警告
由于 Python 3.8 已 终止服务 (https://devguide.python.org/versions/),在 Python 3.8 中使用 snowpark-python 时将触发弃用警告。有关更多信息,请参阅 Snowflake Python 运行时支持。根据 Anaconda 的策略 (https://forum.anaconda.com/t/python-3-8-reaches-end-of-life/87265),Snowpark Python 1.24.0 将是支持 Python 3.8 的最后一个客户端和服务器版本。将现有 Python 3.8 对象升级到 Python 3.9 或更新版本。
Version 1.41.0: Oct 23, 2025¶
新功能¶
Added a new function
serviceinsnowflake.snowpark.functionsthat allows users to create a callable representing a Snowpark Container Services (SPCS) service.Added a new function
group_by_all()to theDataFrameclass.Added
connection_parametersparameter toDataFrameReader.dbapi()(Public Preview) method to allow passing keyword arguments to thecreate_connectioncallable.Added support for
Session.begin_transaction,Session.commit, andSession.rollback.在
functions.py中添加了对以下函数的支持:Geospatial functions:
st_interpolatest_intersectionst_intersection_aggst_intersectsst_isvalidst_lengthst_makegeompointst_makelinest_makepolygonst_makepolygonorientedst_disjointst_distancest_dwithinst_endpointst_envelopest_geohashst_geomfromgeohashst_geompointfromgeohashst_hausdorffdistancest_makepointst_npointsst_perimeterst_pointnst_setsridst_simplifyst_sridst_startpointst_symdifferencest_transformst_unionst_union_aggst_withinst_xst_xmaxst_xminst_yst_ymaxst_yminst_geogfromgeohashst_geogpointfromgeohashst_geographyfromwkbst_geographyfromwktst_geometryfromwkbst_geometryfromwkttry_to_geographytry_to_geometry
Added a parameter to enable and disable automatic column name aliasing for
interval_day_time_from_partsandinterval_year_month_from_partsfunctions.
错误修复¶
Fixed a bug that
DataFrameReader.xmlfails to parse XML files with undeclared namespaces whenignoreNamespaceisTrue.Added a fix for floating point precision discrepancies in
interval_day_time_from_parts.Fixed a bug where writing Snowpark pandas DataFrames on the pandas backend with a column multiindex to Snowflake with
to_snowflakewould raiseKeyError.Fixed a bug that
DataFrameReader.dbapi(Public Preview) is not compatible with oracledb 3.4.0.Fixed a bug where
modinwould unintentionally be imported during session initialization in some scenarios.Fixed a bug where
session.udf|udtf|udaf|sproc.registerfailed when an extra session argument was passed. These methods do not expect a session argument; please remove it if provided.
改进¶
The default maximum length for inferred StringType columns during schema inference in
DataFrameReader.dbapiis now increased from 16 MB to 128 MB in parquet file--based ingestion.
依赖项更新¶
Updated dependency of
snowflake-connector-python>=3.17,<5.0.0.
Snowpark pandas API 更新¶
新功能¶
Added support for the
dtypesparameter ofpd.get_dummies.Added support for
nuniqueindf.pivot_table,df.agg, and other places where aggregate functions can be used.Added support for
DataFrame.interpolateandSeries.interpolatewith the "linear", "ffill"/"pad", and "backfill"/bfill" methods. These use the SQLINTERPOLATE_LINEAR,INTERPOLATE_FFILL, andINTERPOLATE_BFILLfunctions (Public Preview).
改进¶
Improved performance of
Series.to_snowflakeandpd.to_snowflake(series)for large data by uploading data via a parquet file. You can control the dataset size at which Snowpark pandas switches to parquet with the variablemodin.config.PandasToSnowflakeParquetThresholdBytes.Enhanced autoswitching functionality from Snowflake to native pandas for methods with unsupported argument combinations:
get_dummies()withdummy_na=True,drop_first=True, or customdtypeparameterscumsum(),cummin(),cummax()withaxis=1(column-wise operations)skew()withaxis=1ornumeric_only=Falseparametersround()withdecimalsparameter as a Seriescorr()withmethod!=pearsonparameter
Set
cte_optimization_enabledto True for all Snowpark pandas sessions.Add support for the following in faster pandas:
isinisnaisnullnotnanotnullstr.containsstr.startswithstr.endswithstr.slicedt.datedt.timedt.hourdt.minutedt.seconddt.microseconddt.nanoseconddt.yeardt.monthdt.daydt.quarterdt.is_month_startdt.is_month_enddt.is_quarter_startdt.is_quarter_enddt.is_year_startdt.is_year_enddt.is_leap_yeardt.days_in_monthdt.daysinmonthsort_valuesloc(setting columns)to_datetimedropinvertduplicatedilocheadcolumns(e.g., df.columns = ["A", "B"])aggminmaxcountsummeanmedianstdvargroupby.agggroupby.mingroupby.maxgroupby.countgroupby.sumgroupby.meangroupby.mediangroupby.stdgroupby.vardrop_duplicates
Reuse row count from the relaxed query compiler in
get_axis_len.
错误修复¶
Fixed a bug where the row count was not cached in the ordered DataFrame each time
count_rows()was called.
Version 1.40.0: October 6, 2025¶
新功能¶
Added a new module
snowflake.snowpark.secretsthat provides Python wrappers for accessing Snowflake Secrets within Python UDFs and stored procedures that execute inside Snowflake.get_generic_secret_stringget_oauth_access_tokenget_secret_typeget_username_passwordget_cloud_provider_token
Added support for the following scalar functions in
functions.py:Conditional expression functions:
boolandboolnotboolorboolxorboolor_aggdecodegreatest_ignore_nullsleast_ignore_nullsnullifnvl2regr_valx
Semi-structured and structured date functions:
array_remove_atas_booleanmap_deletemap_insertmap_pickmap_size
String & binary functions:
chrhex_decode_binary
Numeric functions:
div0null
Differential privacy functions:
dp_interval_highdp_interval_low
Context functions:
last_query_idlast_transaction
Geospatial functions:
h3_cell_to_boundaryh3_cell_to_childrenh3_cell_to_children_stringh3_cell_to_parenth3_cell_to_pointh3_compact_cellsh3_compact_cells_stringsh3_coverageh3_coverage_stringsh3_get_resolutionh3_grid_diskh3_grid_distanceh3_int_to_stringh3_polygon_to_cellsh3_polygon_to_cells_stringsh3_string_to_inth3_try_grid_pathh3_try_polygon_to_cellsh3_try_polygon_to_cells_stringsh3_uncompact_cellsh3_uncompact_cells_stringshaversineh3_grid_pathh3_is_pentagonh3_is_valid_cellh3_latlng_to_cellh3_latlng_to_cell_stringh3_point_to_cellh3_point_to_cell_stringh3_try_coverageh3_try_coverage_stringsh3_try_grid_distancest_areast_asewkbst_asewktst_asgeojsonst_aswkbst_aswktst_azimuthst_bufferst_centroidst_collectst_containsst_coveredbyst_coversst_differencest_dimension
错误修复¶
Fixed a bug that caused
DataFrame.limit()to fail if the executed SQL contained parameter binding when used in non-stored-procedure/udxf environments.Added an experimental fix for a bug in schema query generation that could cause invalid sql to be generated when using nested structured types.
Fixed multiple bugs in
DataFrameReader.dbapi(Public Preview):Fixed UDTF ingestion failure with
pyodbcdriver caused by unprocessed row data.Fixed SQL Server query input failure due to incorrect select query generation.
Fixed UDTF ingestion not preserving column nullability in the output schema.
Fixed an issue that caused the program to hang during multithreaded Parquet based ingestion when a data fetching error occurred.
Fixed a bug in schema parsing when custom schema strings used upper-cased data type names (
NUMERIC,NUMBER,DECIMAL,VARCHAR,STRING,TEXT).
Fixed a bug in
Session.create_dataframewhere schema string parsing failed when using upper-cased data type names (e.g.,NUMERIC,NUMBER,DECIMAL,VARCHAR,STRING,TEXT).
改进¶
Improved
DataFrameReader.dbapi(Public Preview) so it doesn't retry on non-retryable errors, such as SQL syntax error on external data source query.Removed unnecessary warnings about local package version mismatch when using
session.read.option('rowTag', <tag_name>).xml(<stage_file_path>)orxpathfunctions.Improved
DataFrameReader.dbapi(Public Preview) reading performance by setting the defaultfetch_sizeparameter value to 100000.Improved error message for XSD validation failure when reading XML files using
session.read.option('rowValidationXSDPath', <xsd_path>).xml(<stage_file_path>).
Snowpark pandas API 更新¶
依赖项更新¶
Updated the supported
modinversions to >=0.36.0 and <0.38.0 (was >= 0.35.0 and <0.37.0).
新功能¶
Added support for
DataFrame.queryfor DataFrames with single-level indexes.Added support for
DataFrameGroupby.__len__andSeriesGroupBy.__len__.
改进¶
Hybrid execution mode is now enabled by default. Certain operations on smaller data now automatically execute in native pandas in-memory. Use
from modin.config import AutoSwitchBackend; AutoSwitchBackend.disable()to turn this off and force all execution to occur in Snowflake.Added a session parameter
pandas_hybrid_execution_enabledto enable/disable hybrid execution as an alternative to usingAutoSwitchBackend.Removed an unnecessary
SHOW OBJECTSquery issued fromread_snowflakeunder certain conditions.When hybrid execution is enabled,
pd.merge,pd.concat,DataFrame.merge, andDataFrame.joincan now move arguments to backends other than those among the function arguments.Improved performance of
DataFrame.to_snowflakeandpd.to_snowflake(dataframe)for large data by uploading data via a parquet file. You can control the dataset size at which Snowpark pandas switches to parquet with the variablemodin.config.PandasToSnowflakeParquetThresholdBytes.
Version 1.39.1: September 25, 2025¶
错误修复¶
Added an experimental fix for a bug in schema query generation that could cause invalid SQL to be genrated when using nested structured types.
Version 1.39.0: September 17, 2025¶
新功能¶
Downgraded to level
logging.DEBUG - 1the log message saying that the SnowparkDataFramereference of an internalDataFrameReferenceobject has changed.Eliminate duplicate parameter check queries for casing status when retrieving the session.
Retrieve DataFrame row counts through object metadata to avoid a COUNT(*) query (performance)
Added support for applying the Snowflake Cortex function
Complete.Introduce faster pandas: Improved performance by deferring row position computation.
The following operations are currently supported and can benefit from the optimization:
read_snowflake,repr,loc,reset_index,merge, and binary operations.If a lazy object (e.g., DataFrame or Series) depends on a mix of supported and unsupported operations, the optimization will not be used.
Updated the error message for when Snowpark pandas is referenced within
apply.Added a session parameter
dummy_row_pos_optimization_enabledto enable/disable dummy row position optimization in faster pandas.
依赖项更新¶
Updated the supported
modinversions to >=0.35.0 and <0.37.0 (was previously >= 0.34.0 and <0.36.0).
错误修复¶
Fixed an issue with
drop_duplicateswhere the same data source could be read multiple times in the same query but in a different order each time, resulting in missing rows in the final result. The fix ensures that the data source is read only once.Fixed a bug with hybrid execution mode where an
AssertionErrorwas unexpectedly raised by certain indexing operations.
Snowpark 本地测试更新¶
新功能¶
Added support to allow patching
functions.ai_complete.
Version 1.38.0: September 4, 2025¶
新功能¶
在
functions.py中添加了对以下 AI 驱动的功能的支持:ai_extractai_parse_documentai_transcribe
Added time travel support for querying historical data:
Session.table()now supports time travel parameters:time_travel_modestatementoffsettimestamptimestamp_typestream
DataFrameReader.table()supports the same time travel parameters as direct arguments.DataFrameReadersupports time travel via option chaining (e.g.,session.read.option("time_travel_mode", "at").option("offset", -60).table("my_table")).
Added support for specifying the following parameters to
DataFrameWriter.copy_into_locationfor validation and writing data to external locations:validation_modestorage_integrationcredentialsencryption
Added support for
Session.directoryandSession.read.directoryto retrieve the list of all files on a stage with metadata.Added support for
DataFrameReader.jdbc(Private Preview)that allows the JDBC driver to ingest external data sources.Added support for
FileOperation.copy_filesto copy files from a source location to an output stage.Added support for the following scalar functions in
functions.py:all_user_namesbitandbitand_aggbitorbitor_aggbitxorbitxor_aggcurrent_account_namecurrent_clientcurrent_ip_addresscurrent_role_typecurrent_organization_namecurrent_organization_usercurrent_secondary_rolescurrent_transactiongetbit
错误修复¶
Fixed the
_repr_ofTimestampTypeto match the actual subtype it represents.Fixed a bug in
DataFrameReader.dbapithatUDTFingestion does not work in stored procedures.Fixed a bug in schema inference that caused incorrect stage prefixes to be used.
改进¶
Enhanced error handling in
DataFrameReader.dbapithread-based ingestion to prevent unnecessary operations, which improves resource efficiency.Bumped cloudpickle dependency to also support
cloudpickle==3.1.1in addition to previous versions.Improved
DataFrameReader.dbapi(Public Preview) ingestion performance for PostgreSQL and MySQL by using a server-side cursor to fetch data.
Snowpark Pandas API 更新¶
新功能¶
Completed support for the following functions on the "Pandas" and "Ray" backends:
pd.read_snowflake()pd.to_iceberg()pd.to_pandas()pd.to_snowpark()pd.to_snowflake()DataFrame.to_iceberg()DataFrame.to_pandas()DataFrame.to_snowpark()DataFrame.to_snowflake()Series.to_iceberg()Series.to_pandas()Series.to_snowpark()Series.to_snowflake()on the "Pandas" and "Ray" backends. Previously, only some of these functions and methods were supported on the Pandas backend.
Added support for
Index.get_level_values().
改进¶
Set the default transfer limit in hybrid execution for data leaving Snowflake to 100k, which can be overridden with the
SnowflakePandasTransferThresholdenvironment variable. This configuration is appropriate for scenarios with two available engines, "pandas" and "Snowflake," on relational workloads.Improved the import error message by adding
--upgradetopip install "snowflake-snowpark-python[modin]"in the message.Reduced the telemetry messages from the modin client by pre-aggregating into five-second windows and only keeping a narrow band of metrics that are useful for tracking hybrid execution and native pandas performance.
Set the initial row count only when hybrid execution is enabled, which reduces the number of queries issued for many workloads.
Added a new test parameter for integration tests to enable hybrid execution.
错误修复¶
Raised
NotImplementedErrorinstead ofAttributeErroron attempting to call Snowflake extension functions/methodsto_dynamic_table(),cache_result(),to_view(),create_or_replace_dynamic_table(), andcreate_or_replace_view()on DataFrames or series using the pandas or ray backends.
Version 1.37.0: August 18, 2025¶
新功能¶
Added support for the following
xpathfunctions infunctions.py:xpathxpath_stringxpath_booleanxpath_intxpath_floatxpath_doublexpath_longxpath_short
Added support for the
use_vectorized_scannerparameter in theSession.write_arrow()function.DataFrame profiler adds the following information about each query:
describe query time,execution time, andsql query text. To view this information, callsession.dataframe_profiler.enable()and callget_execution_profileon a DataFrame.Added support for
DataFrame.col_ilike.Added support for non-blocking stored procedure calls that return
AsyncJobobjects.Added the
block: bool = Trueparameter toSession.call(). Whenblock=False, returns anAsyncJobinstead of blocking until completion.Added the
block: bool = Trueparameter toStoredProcedure.__call__()for async support across both named and anonymous stored procedures.Added
Session.call_nowait()that is equivalent toSession.call(block=False).
错误修复¶
Fixed a bug in CTE optimization stage where
deepcopyof internal plans would cause a memory spike when a DataFrame is created locally usingsession.create_dataframe()using large input data.Fixed a bug in
DataFrameReader.parquetwhere theignore_caseoption in theinfer_schema_optionswas not respected.Fixed a bug where
to_pandas()had a different format of column name when the query result format is set toJSONandARROW.
弃用¶
Deprecated
pkg_resources.
依赖项更新¶
Added a dependency on
protobuf<6.32
Snowpark Pandas API 更新¶
新功能¶
Added support for efficient transfer of data between Snowflake and <Ray (https://www.ray.io/) with the
DataFrame.set_backendmethod. The installed version ofmodinmust be at least 0.35.0, andraymust be installed.
依赖项更新¶
Updated the supported modin versions to >=0.34.0 and <0.36.0 (was previously >= 0.33.0 and <0.35.0).
Added support for pandas 2.3 when the installed modin version is 0.35.0 or greater.
错误修复¶
Fixed an issue in hybrid execution mode (Private Preview) where
pd.to_datetimeandpd.to_timedeltawould unexpectedly raiseIndexError.Fixed a bug where
pd.explain_switchwould raiseIndexErroror returnNoneif called before any potential switch operations were performed.
Version 1.36.0: August 5, 2025¶
新功能¶
Session.create_dataframenow accepts keyword arguments that are forwarded in the internal call toSession.write_pandasorSession.write_arrowwhen creating a DataFrame from a pandas DataFrame or apyarrowtable.Added new APIs for AsyncJob:
AsyncJob.is_failed()returns a bool indicating whether a job has failed. Can be used in combination withAsyncJob.is_done()to determine if a job is finished and erred.AsyncJob.status()returns a string representing the current query status (such as, "RUNNING", "SUCCESS", "FAILED_WITH_ERROR") for detailed monitoring without callingresult().
Added a DataFrame profiler. To use, you can call
get_execution_profile()on your desired DataFrame. This profiler reports the queries executed to evaluate a DataFrame and statistics about each of the query operators. Currently an experimental feature.在
functions.py中添加了对以下函数的支持:ai_sentiment
Updated the interface for the
context.configure_development_featuresexperimental feature. All development features are disabled by default unless explicitly enabled by the user.
改进¶
Hybrid execution row estimate improvements and a reduction of eager calls.
Added a new configuration variable to control transfer costs out of Snowflake when using hybrid execution.
Added support for creating permanent and immutable UDFs/UDTFs with DataFrame/Series/GroupBy.apply, map, and transform by passing the
snowflake_udf_paramskeyword argument.Added support for
mapping np.uniqueto DataFrame and Series inputs usingpd.unique.
错误修复¶
Fixed an issue where the Snowpark pandas plugin would unconditionally disable
AutoSwitchBackendeven when users have explicitly configured it programmatically or with environment variables.
版本 1.35.0:2025 年 7 月 24 日¶
新功能¶
在
functions.py中添加了对以下函数的支持:ai_embedtry_parse_json
改进¶
改进了
DataFrameReader.dbapi`(非公开预览版)中的 :code:`query参数,因此无需在查询前后加括号。改进了在 :code:`DataFrameReader.dbapi`(非公开预览版)中推理目标数据源架构时引发异常的错误体验。
错误修复¶
修复了
DataFrameReader.dbapi`(非公开预览版)中的以下错误:在 Python 存储过程中会导致 :code:`dbapi失败,并显示进程退出代码 1。修复了
DataFrameReader.dbapi`(非公开预览版)中 :code:`custom_schema接受非法架构的错误。修复了
DataFrameReader.dbapi`(非公开预览版)中的一个错误,即:code:`custom_schema在连接到 Postgres 和 MySQL 时无法正常工作。修复了架构推理中导致外部暂存区失败的错误。
Snowpark 本地测试更新¶
新功能¶
增加了对使用
SnowflakeFile读取文件的本地测试支持。测试支持使用本地文件路径、Snow URL 语义 (snow://...)、本地测试框架暂存区和 Snowflake 暂存区 (@stage/file_path)。
版本 1.34.0:2025 年 7 月 14 日¶
新功能¶
向
DataFrameReader添加了新选项TRY_CAST。如果TRY_CAST为True,在加载数据时列会封装在TRY_CAST语句中,而非执行硬性转换。在
DataFrameReader的INFER_SCHEMA_OPTIONS中添加了一个新选项USE_RELAXED_TYPES。当设置为True时,该选项会将所有字符串转换为最大长度字符串,并将所有数值类型转换为DoubleType。新增了可调试性改进,以主动验证 DataFrame 模式元数据。可通过
snowflake.snowpark.context.configure_development_features()启用。添加了一个新函数:code:
snowflake.snowpark.dataframe.map_in_pandas,允许用户在数据帧上映射函数。映射函数以 Pandas DataFrames 的迭代器作为输入,并提供一个 pandas DataFrame 作为输出。添加了
ttl cache来描述查询。在 15 秒间隔内重复的查询会使用缓存值,而非重新向 Snowflake 发出查询。向
DataFrameReader.dbapi(PrPr) 添加了一个fetch_with_process参数,用于启用多重处理,以支持本地引入中的数据提取。默认情况下,本地引入使用多线程。多重处理可以提高 Parquet 文件生成等受 CPU 限制的任务的性能。添加了新函数
snowflake.snowpark.functions.model,允许用户调用模型的方法。
改进¶
添加了对使用 XSD 架构进行行验证的支持,在使用
rowTag选项读取带行标签的 XML 文件时,可利用rowValidationXSDPath选项实现。改进了
session.table().sample()的 SQL 生成,以生成扁平化的 SQL 语句。添加了支持,
functions.explode现可将复杂列表达式作为输入。添加了可调试性改进,以显示 SQL 编译错误对应于哪些 Python 行。使用
snowflake.snowpark.context.configure_development_features()启用。此功能还依赖于在会话中启用的 AST 集合,可以使用session.ast_enabled = True来实现。从包含 DML/DDL 查询的 Snowpark DataFrame 调用
to_snowpark_pandas():code:时,设置enforce_ordering=True,而非抛出NotImplementedError。
错误修复¶
修复了创建 Iceberg 表时因冗余验证导致的错误。
修复了 :code:`DataFrameReader.dbapi`(非公开预览版)中的一个错误,即关闭游标或连接可能会意外引发错误并终止程序。
修复了在
DataFrame.select()中使用表函数时,输出列与输入 DataFrame 的列匹配导致列名歧义的错误。当 DataFrame 列作为Column对象提供时,此项改进会发挥作用。修复了 DecimalTypes 列中存在 NULL 时,会将该列转换为 FloatTypes 并导致精度损失的错误。
Snowpark 本地测试更新¶
修复了处理窗口函数时导致结果索引不正确的错误。
将标量数字传递给
fillna时,Snowflake 将忽略非数字列,而非产生错误。
Snowpark Pandas API 更新¶
新功能¶
添加了对
DataFrame.to_excel和Series.to_excel的支持。添加了对
pd.read_feather、pd.read_orc和pd.read_stata的支持。添加了对
pd.explain_switch()的支持,以返回有关混合执行决策的调试信息。当全局 modin 后端为
Pandas时,支持pd.read_snowflake。添加了对
pd.to_dynamic_table、pd.to_iceberg和pd.to_view的支持。
改进¶
添加了对 API 调用和混合引擎切换的 modin 遥测。
当
modin或pandas版本不符合要求时,为 Snowflake 笔记本用户显示更有帮助的错误消息。在混合执行模式(非公开预览版)中,为成本函数新增了数据类型保护,用于检查数据类型兼容性。
在混合执行模式(非公开预览版)中,对于许多未在 Pandas on Snowflake 中直接实现的方法,新增了自动切换到 Pandas 后端的功能。
为 Pandas on Snowflake 遥测设置了
type和其他标准字段。
依赖项更新¶
添加了
tqdm和ipywidgets作为依赖项,以便用户在 modin 后端之间切换时可查看进度条。将支持的
modin版本更新为 >=0.33.0 和 <0.35.0 (was previously >= 0.32.0 和 <0.34.0)。
错误修复¶
修复了混合执行模式(非公开预览版)中的一个错误,即某些序列操作会引发
TypeError: numpy.ndarray object is not callable。修复了混合执行模式(非公开预览版)中的一个错误,即在 Pandas 后端对 modin 对象调用
np.where等numpy操作会引发AttributeError。此修复需要modin版本 0.34.0 或更高版本。修复了
df.melt中的一个问题,此问题会导致值应用额外的后缀。
版本 1.33.0(2025 年 6 月 19 日)¶
新功能¶
在 :code:`DataFrameWriter.dbapi`(非公开预览版)中添加了对 MySQL 的支持,用于 Parquet 和基于 UDTF 的引入。
在 :code:`DataFrameReader.dbapi`(非公开预览版)中添加了对 PostgreSQL 的支持,用于 Parquet 和基于 UDTF 的引入。
在 :code:`DataFrameWriter.dbapi`(非公开预览版)中添加了对 Databricks 的支持,用于基于 UDTF 的引入,同时与其他对 Databricks 支持的提及进行了整合。
添加了对
DataFrameReader的支持,支持在启用INFER_SCHEMA的情况下读取文件时使用PATTERN。在
functions.py中添加了对以下 AI 驱动的功能的支持:ai_completeai_similarityai_summarize_agg`(原为 :code:`summarize_agg)ai_classify的不同配置选项
添加了使用
rowTag选项读取带有行标签的 XML 文件时对更多选项的支持:添加了对使用
ignoreNamespace选项从列名中移除命名空间前缀的支持。添加了对使用
attributePrefix选项在结果表中为属性列指定前缀的支持。添加了对使用
excludeAttributes选项从 XML 元素中排除属性的支持。添加了当一个没有子元素的元素中包含属性时,使用
valueTag选项为其值指定列名的支持。添加了使用
nullValue选项,指定要视为 null 的值的支持。添加了对使用
charset选项指定 XML 文件的字符编码的支持。添加了对使用
ignoreSurroundingWhitespace选项忽略 XML 元素中周围空白的支持。
在
Session.call中添加了对参数return_dataframe的支持,可用于将函数的返回类型设置为DataFrame对象。向
Dataframe.describe添加了一个名为strings_include_math_stats的新实参,它会触发stddev和mean来计算字符串列。在
DataFrame.lineage.trace中添加了对于从DGQL检索沿袭时检索Edge.properties的支持。向
DataFrameWriter.save_as_table中添加了一个table_exists参数,允许指定表是否已经存在。这允许跳过可能很昂贵的表查找。
错误修复¶
修复了
DataFrameReader.dbapi`(非公开预览版)中 :code:`create_connection定义为与多重处理不兼容的本地函数的错误。修复了
DataFrameReader.dbapi`(非公开预览版)中的一个错误,即 Databricks :code:`TIMESTAMP类型被转换为 SnowflakeTIMESTAMP_NTZ类型,但本应是TIMESTAMP_LTZ类型。修复了
DataFrameReader.json中的一个错误,该错误使用同一读取器对象重复读取,导致生成错误引用的列。修复了
DataFrame.to_pandas()中的一个错误,该错误在转换并非源自 select 语句的 DataFrame 时会删除列名。修复了一个错误,即当 DataFrame 包含 UDTF 且 UDTF 中的
SELECT *未被正确解析时,DataFrame.create_or_replace_dynamic_table会引发错误。修复了无法在函数的 values 子句中使用强制类型转换列的错误。
改进¶
改进了输入 Pandas DataFrame 没有列时,
Session.create_dataframe()和Session.write_pandas()的错误消息。改进了
DataFrame.select,使其能更好地处理实参包含一个表函数时,其输出列与当前 DataFrame 的列发生冲突的情况。通过这项改进,如果用户在df.select("col1", "col2", table_func(...))中提供非冲突列作为字符串实参,Snowpark 客户端生成的查询不会引发不明确的列错误。改进了 :code:`DataFrameReader.dbapi`(非公开预览版),支持使用基于内存中的 Parquet 引入,以提高性能和安全性。
改进了
DataFrameReader.dbapi`(非公开预览版),支持在复制到表的操作中使用 :code:`MATCH_BY_COLUMN_NAME=CASE_SENSITIVE。
Snowpark 本地测试更新¶
新功能¶
在本地文件测试中添加了对 Snow URLs (
snow://) 的支持。
错误修复¶
修复了
Column.isin中会导致对已联接或先前筛选的数据进行错误筛选的错误。修复了
snowflake.snowpark.functions.concat_ws中的一个错误,该错误会导致结果使用不正确的索引。
Snowpark Pandas API 更新¶
依赖项更新¶
将
modin依赖项约束从 0.32.0 更新为 >=0.32.0、<0.34.0。使用 Snowpark Pandas 测试的最新版本为modin0.33.1。
新功能¶
添加了对 混合执行(非公开预览版) 的支持。通过运行
from modin.config import AutoSwitchBackend; AutoSwitchBackend.enable(),Pandas on Snowflake 会自动选择是在本地还是在 Snowflake 上运行特定的 Pandas 操作。此功能默认禁用。
改进¶
对于
DataFrame.to_view、Series.to_view、DataFrame.to_dynamic_table和Series.to_dynamic_table,将index参数的默认值设置为False。为表创建函数添加了
iceberg_version选项。减少了许多操作的查询次数,包括
insert、repr和groupby,这些操作先前会发出查询,以检索输入数据的大小。
错误修复¶
修复了
Series.where中的一个错误,即当other为未命名的Series时会出现问题。
版本 1.32.0(2025 年 5 月 15 日)¶
改进¶
调用 Snowflake 系统过程不会执行额外的
describe procedure调用来检查该过程的返回类型。增加了对
Session.create_dataframe()`(使用暂存区 URL 和 :code:`FILE数据类型)的支持。增加了在使用
session.read.option('mode', <mode>), option('rowTag', <tag_name>).xml(<stage_file_path>)读取 XML 文件时,通过不同模式处理损坏的 XML 记录的支持。目前支持PERMISSIVE、DROPMALFORMED和FAILFAST。改进了在文件中找不到指定
ROWTAG内容时,XML 读取器的错误消息。改进了查询生成,使
Dataframe.drop使用SELECT * EXCLUDE ()排除已删除列。设置session.conf.set("use_simplified_query_generation", True)以启用此功能。为
StructType.from_json添加了对VariantType的支持。
错误修复¶
修复了 :code:`DataFrameWriter.dbapi`(非公开预览版)中的一个错误,该错误导致外部数据库中的 unicode 或置于双引号之间的列名因引号不正确而导致错误。
修复了嵌套
OBJECT数据中的命名字段在包含空格时可能导致错误的错误。
Snowpark 本地测试更新¶
错误修复¶
修复了
snowflake.snowpark.functions.rank不遵守排序方向的错误。修复了
snowflake.snowpark.functions.to_timestamp_*中会导致筛选数据结果不正确的错误。
Snowpark Pandas API 更新¶
新功能¶
添加了对
Series.str.get、Series.str.slice和Series.str.__getitem__(Series.str[...]) 中字典值的支持。添加了对
DataFrame.to_html的支持。添加了对
DataFrame.to_string和Series.to_string的支持。添加了对使用
pd.read_csv从 S3 桶读取文件的支持。
改进¶
将
iceberg_config设为DataFrame.to_iceberg和Series.to_iceberg的必要参数。
版本 1.31.0(2025 年 4 月 24 日)¶
新功能¶
添加了对
StoredProcedure.register():code:中execute_as实参的restricted caller权限的支持。添加了对
DataFrame.to_pandas()中非 select 语句的支持。为
Session.add_packages、Session.add_requirements、Session.get_packages、Session.remove_package和Session.clear_packages添加了对artifact_repository参数的支持。添加了通过 :code:`session.read.option('rowTag', <tag_name>).xml(<stage_file_path>)`(实验性)使用行标记读取 XML 文件的支持。
每条 XML 记录都作为单独的行提取。
该记录中的每个字段都成为一个单独的
VARIANT类型列,可以使用点表示法进一步查询,例如col(a.b.c)。
添加了对
DataFrameReader.dbapi(PrPr) 的更新:添加了通过将多个提取的数据合并到单个 Parquet 文件中来优化性能的
fetch_merge_count参数。添加了对 Databricks 的支持。
添加了对使用 Snowflake UDTF 进行引入的支持。
在 :code:`functions.py`(非公开预览版)中添加了对以下 AI 功能的支持:
promptai_filter`(添加了对 :code:`prompt()函数和镜像文件的支持,并将第二个实参名称从expr更改为file)ai_classify
改进¶
针对
DataFrame.to_snowpark_pandas,将relaxed_ordering参数重命名为enforce_ordering。此外,新的默认值为enforce_ordering=False,与先前的默认值relaxed_ordering=False具有相反的效果。通过将默认
fetch_size参数值设置为 1000,提高了DataFrameReader.dbapi(PrPr) 读取性能。通过建议可能匹配的标识符,改进无效标识符 SQL 错误的错误消息。
减少了使用
session.table从 Snowflake 表创建 DataFrame 时发出的描述查询的数量。提高了
DataFrameAnalyticsFunctions.time_series_agg()的性能和准确性。
错误修复¶
修复了数据透视列和汇总列相同时,
DataFrame.group_by().pivot().agg中的一个错误。修复了
DataFrameReader.dbapi(PrPr) 中的一个错误,即create_connection返回不支持的驱动程序类型的连接对象时会引发TypeError。修复了
df.limit(0)调用无法正常应用的错误。修复了
DataFrameWriter.save_as_table中使用追加模式时导致保留名称引发错误的错误。
弃用¶
已弃用对 Python3.8 的支持。
在
DataFrameAnalyticsFunctions.time_series_agg()中已弃用sliding_interval实参。
Snowpark 本地测试更新¶
新功能¶
为
Window.range_between添加了对间隔表达式的支持。添加了对
array_construct函数的支持。
错误修复¶
修复了本地测试中的一个错误,即在通过导入执行存储过程期间,无意中复制临时
__pycache__目录。修复了本地测试中导致
Column.like调用结果不正确的错误。修复了本地测试中导致
Column.getItem和snowpark.snowflake.functions.get引发IndexError而非返回null的错误。修复了本地测试中
df.limit(0)调用无法正常应用的错误。修复了本地测试中执行
Table.merge时合并到空表会导致异常的错误。
Snowpark pandas API 更新¶
依赖项更新¶
将
modin从 0.30.1 更新到了 0.32.0。添加了对
numpy2.0 及更高版本的支持。
新功能¶
添加了对
DataFrame.create_or_replace_view和Series.create_or_replace_view的支持。添加了对
DataFrame.create_or_replace_dynamic_table和Series.create_or_replace_dynamic_table的支持。添加了对
DataFrame.to_view和Series.to_view的支持。添加了对
DataFrame.to_dynamic_table和Series.to_dynamic_table的支持。为
DataFrame.groupby.resample添加了对聚合max、mean、median、min和sum的支持。添加了对使用以下方式读取暂存区文件的支持:
pd.read_excelpd.read_htmlpd.read_picklepd.read_saspd.read_xml
添加了对
DataFrame.to_iceberg和Series.to_iceberg的支持。添加了对
Series.str.len中字典值的支持。
改进¶
通过避免昂贵的透视步骤来提高
DataFrame.groupby.apply和Series.groupby.apply的性能。为
OrderedDataFrame增加了行数上限的估计值,以更好地切换引擎。这可能会导致查询次数增加。将
enforce_ordering中的relaxed_ordering参数重命名为pd.read_snowflake。此外,新的默认值为enforce_ordering=False,与先前的默认值relaxed_ordering=False具有相反的效果。
错误修复¶
修复了读取 Iceberg 表和
enforce_ordering=True时pd.read_snowflake的错误。
版本 1.30.0(2025 年 3 月 27 日)¶
新功能¶
引入
relaxed_ordering参数,从而添加了对:code:Dataframe.to_snowpark_pandas中放宽的一致性和排序保证的支持。DataFrameReader.dbapi`(预览版)现在可接受:code:`session_init_statement参数的字符串列表,允许在会话初始化期间执行多个 SQL 语句。
改进¶
相较于为
fractions中的每个关键字创建 UNION ALL 子查询的旧方法,改进了:code:Dataframe.stat.sample_by的查询生成,可生成单个平面查询,并能很好地通过大型fractions字典进行扩展。设置session.conf.set("use_simplified_query_generation", True)以启用此功能。在将 Parquet 文件复制到表中时启用矢量化选项,从而提高
DataFrameReader.dbapi的性能。通过以下方式改进了
DataFrame.random_split的查询生成。可以通过设置session.conf.set("use_simplified_query_generation", True)来启用它们:无需在输入数据帧的内部实现中使用
cache_result,从而实现了纯粹的惰性数据帧操作。seed实参现在可在多次调用和会话中重复表现出预期行为。
在
include_decimal设置为True的情况下,DataFrame.fillna和:code:DataFrame.replace现在均支持将int和float纳入Decimal列。在
files.py中添加了以下 UDF 和存储过程函数的文档,因为它们已经正式发布。SnowflakeFile.writeSnowflakeFile.writelinesSnowflakeFile.writeable
对于
SnowflakeFile和SnowflakeFile.open()的文档进行了细微修改。
错误修复¶
修复了以下函数的一个会引发错误的错误。
.cast()应用于其输出:from_jsonsize
Snowpark 本地测试更新¶
错误修复¶
修复了聚合中的一个错误,该错误会导致空组仍产生行。
修复了
Dataframe.except_中的一个错误,该错误会导致不正确地删除行。修复了在对筛选出的行执行类型转换时导致
to_timestamp失败的一个错误。
Snowpark pandas API 更新¶
新功能¶
在
Series.str.__getitem__(Series.str[...]) 中添加了对列表值的支持。在 GROUP BY 操作中添加了对
pd.Grouper对象的支持。在指定freq时,支持sort、closed、label和convention实参的默认值;如为start或start_day,则支持origin。引入新参数
relaxed_ordering,在pd.read_snowflake中为指定数据源(例如表和视图)和查询数据源添加了对放宽的一致性和排序保证的支持。
改进¶
一旦发现设置了
QUOTED_IDENTIFIERS_IGNORE_CASE,就会发出警告,要求用户将其取消设置。改进了在
index=True时,对DataFrame.to_snowflake和Series.to_snowflake中缺失的index_label的处理方式。索引列使用系统定义的标签,而不会引发ValueError。改进了在函数名称不受支持时,
groupby、DataFrame或Series.agg的错误消息。
Snowpark 本地测试更新¶
改进¶
一旦发现设置了
QUOTED_IDENTIFIERS_IGNORE_CASE,就会发出警告,要求用户将其取消设置。改进了在
index=True时,对DataFrame.to_snowflake和Series.to_snowflake中缺失的index_label的处理方式。索引列使用系统定义的标签,而不会引发ValueError。改进了在函数名称不受支持时,
groupby or DataFrame or Series.agg的错误消息。
版本 1.29.1(2025 年 3 月 12 日)¶
错误修复¶
修复了 :code:`DataFrameReader.dbapi`(非公开预览版)中一个导致无法在存储过程和 Snowbooks 中使用的错误。
版本 1.29.0(2025 年 3 月 5 日)¶
新功能¶
在 :file:`functions.py`(非公开预览版)中添加了对以下 AI 功能的支持:
ai_filterai_aggsummarize_agg
在 :file:`functions.py`(非公开预览版)中添加了对新的 FILE SQL 类型的支持,以及以下相关函数:
fl_get_content_type
fl_get_etag
fl_get_file_type
fl_get_last_modified
fl_get_relative_path
fl_get_scoped_file_url
fl_get_size
fl_get_stage
fl_get_stage_file_url
fl_is_audio
fl_is_compressed
fl_is_document
fl_is_image
fl_is_video添加了使用工件库(非公开预览版)从 PyPi 导入第三方包的支持:
在注册存储过程或用户定义的函数时,使用关键字实参
artifact_repository和packages分别指定工件存储库和包。支持的 APIs 如下:
Session.sproc.register
Session.udf.register
Session.udaf.register
Session.udtf.register
functions.sproc
functions.udf
functions.udaf
functions.udtf
functions.pandas_udf
functions.pandas_udtf
改进¶
改进了注册存储过程时的版本验证警告,以确保
snowflake-snowpark-python包的兼容性。现在,只有当主要版本或次要版本不匹配时才会触发警告,错误修复版本差异不会再生成警告。升级了 cloudpickle 的依赖项,使其除了支持以前的版本外,还支持
cloudpickle==3.0.0。
错误修复¶
修复了以下错误:在禁用线程安全会话的情况下,创建包含大量值的数据帧时会引发
Unsupported feature 'SCOPED_TEMPORARY'.错误。修复了以下错误:如果通过读取暂存文件创建了 DataFrame,且 CTE 优化已启用,则
df.describe会引发内部 SQL 执行错误。修复了以下错误:使用
session.conf.set("use_simplified_query_generation", True)启用简化查询生成时,df.order_by(A).select(B).distinct()会生成无效的 SQL。
默认禁用简化查询生成。
Snowpark pandas API 更新¶
改进¶
改进了表不存在时的
pd.to_snowflake、DataFrame.to_snowflake和Series.to_snowflake错误消息。改进了
pd.to_snowflake、DataFrame.to_snowflake和Series.to_snowflake中if_exists参数 docstring 的可读性。改进了所有使用 UDFs 与 Snowpark 对象的 pandas 函数的错误消息。
错误修复¶
修复了
Series.rename_axis中的一个错误,该错误会引发AttributeError。修复了
pd.get_dummies默认不忽略 NULL/NaN 值的错误。修复了一个错误,即重复调用
pd.get_dummies会导致“列名重复错误”。修复了
pd.get_dummies中的一个错误,即传递列列表会在输出 DataFrame 中生成不正确的列标签。更新了
pd.get_dummies,以返回 bool 值而非 int 值。
Snowpark 本地测试更新¶
新功能¶
在
range_between窗口函数中添加了对字面量的支持。
版本 1.28.0(2025 年 2 月 20 日)¶
新功能¶
在
functions.py中添加了对以下函数的支持normalrandn
向
Dataframe.union_by_name和Dataframe.union_all_by_name添加了对allow_missing_columns参数的支持。
改进¶
改进了随机对象名称的生成,以避免冲突。
改进了
Dataframe.distinct的查询生成,以生成 SELECT DISTINCT,而不必在执行 SELECT 时对所有列进行 GROUP BY。要禁用此功能,请设置session.conf.set("use_simplified_query_generation", False)。
弃用¶
已弃用 Snowpark Python 函数
snowflake_cortex_summarize。用户可以安装snowflake-ml-python并改为使用:code:snowflake.cortex.summarize函数。已弃用 Snowpark Python 函数
snowflake_cortex_sentiment。用户可以安装snowflake-ml-python并改为使用:code:snowflake.cortex.sentiment函数。
错误修复¶
修复了以下错误:对于生成多个查询的 DataFrames,会话级查询标签会被堆栈跟踪覆盖。现在,只有在
session.conf.set("collect_stacktrace_in_query_tag", True)的情况下,才会将查询标签设置为堆栈跟踪。修复了
Session._write_pandas中的以下错误:在写入 Snowpark pandas 对象时,错误地将use_logical_type参数传递给Session._write_modin_pandas_helper。修复了选项 SQL 生成中的一个错误,该错误可能导致多个值的格式不正确。
修复了
Session.catalog中的一个错误,该错误导致无法正确处理数据库或架构的空字符串,并生成错误的 SQL 语句。
实验功能¶
添加了将 pyarrow 表写入 Snowflake 表的支持。
Snowpark pandas API 更新¶
新功能¶
添加了对应用 Snowflake Cortex 函数
Summarize和Sentiment的支持。在
Series.str.get中添加了对列表值的支持。
错误修复¶
修复了
apply中的一个错误,该错误会导致 kwargs 无法正确传入应用的函数。
Snowpark 本地测试更新¶
新功能¶
- 添加了对以下函数的支持
hourminute
向 CSV 读取器添加了对 NULL_IF 参数的支持。
添加了在加载 CSVs 时,对
date_format、datetime_format和timestamp_format选项的支持。
错误修复¶
修复了
DataFrame.join中的一个错误,该错误会导致列的类型设置不正确。修复了
when语句中的一个错误,该错误会在otherwise子句中导致不正确的结果。
版本 1.27.0(2025 年 2 月 5 日)¶
新功能¶
在 functions.py 中添加了对以下函数的支持:
array_reversedivnullmap_catmap_contains_keymap_keysnullifzerosnowflake_cortex_sentimentacoshasinhatanhbit_lengthbitmap_bit_positionbitmap_bucket_numberbitmap_construct_aggcbrtequal_nullfrom_jsonifnulllocaltimestampmax_bymin_bynth_valuenvloctet_lengthpositionregr_avgxregr_avgyregr_countregr_interceptregr_r2regr_sloperegr_sxxregr_sxyregr_syytry_to_binarybase64base64_decode_stringbase64_encodeeditdistancehexhex_encodeinstrlog1plog2log10percentile_approxunbase64添加了在调用
DataFrame.create_dataframe时,对指定架构字符串(包括隐式结构语法)的支持。添加了对
DataFrameWriter.insert_into/insertInto的支持。此方法还支持本地测试模式。添加了对
DataFrame.create_temp_view的支持,以创建临时视图。如果视图已经存在,则操作将会失败。在函数
map_cat和map_concat中添加了对多列的支持。添加了一个
keep_column_order选项,用于在DataFrame.with_column和DataFrame.with_columns中保持原始列顺序。添加了列类型转换选项,允许在
StructType列中重命名或添加字段。为
ArrayType添加了对contains_null parameter的支持。添加了以下支持:对通过从暂存区中读取文件创建的 DataFrame 执行:code:
DataFrame.create_or_replace_temp_view,从而创建临时视图。向
MapType添加了对value_contains_null参数的支持。为遥测添加了交互能力,可指示当前环境是否为交互式环境。
允许原生应用程序中的
session.file.get从当前版本读取以 / 开头的文件路径添加了在
DataFrame.pivot之后使用多个聚合函数的支持。
实验功能¶
添加了
Session.catalog类,用于管理 Snowflake 对象。可通过Session.catalog访问。snowflake.core是该功能需要的依赖项。
在读取暂存区中的 JSON 文件时,允许一个或多个用户输入架构。
添加了在调用
DataFrame.create_dataframe时,对指定架构字符串(包括隐式结构语法)的支持。
改进¶
已更新
README.md,以包括有关如何使用cosign验证包签名的说明。
错误修复¶
修复了本地测试模式下的一个错误,该错误会导致列中应包含 0 时却包含 None。
修复了
StructField.from_json中的一个错误,该错误导致无法正确解析带有tzinfo的TimestampTypes。修复了
function date_format中的一个错误,该错误会在输入列为日期类型或时间戳类型时导致错误。修复了 DataFrame 中的一个错误,该错误允许在不可为 null 的列中插入 null 值。
修复了函数
replace和lit中的一个错误,该错误会在传递列表达式对象时引发类型提示断言错误。修复了
pandas_udf和pandas_udtf中会话参数被错误地忽略的错误。修复了一个错误,在通过
session.call调用系统函数时,该错误会引发错误的类型转换。
Snowpark pandas API 更新¶
新功能¶
添加了对
Series.str.ljust和Series.str.rjust的支持。添加了对
Series.str.center的支持。添加了对
Series.str.pad的支持。添加了对应用 Snowpark Python 函数
snowflake_cortex_sentiment的支持。添加了对
DataFrame.map的支持。添加了对
DataFrame.from_dict和DataFrame.from_records的支持。添加了对结构类型列中混合大小写字段名的支持。
添加了对
SeriesGroupBy.unique的支持添加了对
Series.dt.strftime的支持,支持使用以下指令:%d:以零填充十进制数字形式表示的日期。
%m:以零填充十进制数字形式表示的月份。
%Y:以十进制数字形式表示世纪的年份。
%H:以零填充十进制数字形式表示的小时(24 小时制时钟)。
%M:以零填充十进制数字形式表示的分钟。
%S:以零填充十进制数字形式表示的秒钟。
%f:以零填充到 6 位的十进制数形式表示的微秒。
%j:以零填充十进制数字形式表示的一年当中的第几天。
%X:对于区域设置而言适当的时间表示法。
%%:“%”字面量字符。
添加了对
Series.between的支持。在
DataFrameGroupBy.apply中添加了对include_groups=False的支持。在
Series.str.split中添加了对expand=True的支持。添加了对
DataFrame.pop和Series.pop的支持。在
DataFrameGroupBy.agg和SeriesGroupBy.agg中添加了对first和last的支持。添加了对
Index.drop_duplicates的支持。在
pd.pivot_table()、DataFrame.pivot_table()和pd.crosstab()中添加了对聚合"count"、"median"、np.median、"skew"、"std"、np.std"var"和np.var的支持。
改进¶
通过尽可能将 numpy 函数映射到 Snowpark 函数,提高了
DataFrame.map、Series.apply和Series.map方法的性能。添加了
DataFrame.map的文档。通过尽可能将 numpy 函数映射到 Snowpark 函数,提高了
DataFrame.apply的性能。添加了有关 Snowpark Pandas 与 scikit-learn 之间的互操作性程度的文档。
如果未提供类型提示,则推断
Series.map、Series.apply和DataFrame.map中函数的返回类型。为遥测添加了
call_count,用于计算方法调用,包括交换协议调用。