News

Snowpark Python 1.58.0 adds per-document token counts in private preview

Extraction schemas must rename top-level fields that collide with INPUT_TOKENS or OUTPUT_TOKENS. Snowflake also fixed a bug that caused schema-based reads to reject common image formats.

D
Nov 27, 2026 · 1 min read

Snowflake added per-document token counts to its private-preview document reader in Snowpark Python 1.58.0. When a read supplies a schema or prompt, DataFrameReader.documents() now reports by default how many tokens went into AI_COMPLETE and how many the model generated.

The new output columns, INPUT_TOKENS and OUTPUT_TOKENS, are reserved names. Extraction schemas using either name for a top-level field must rename it. Capitalization alone will not resolve the collision because the schema validator checks names in uppercase.

The document reader returns one row per staged document. A schema specifies which fields to extract, while a prompt on its own returns text. Without either option, AI_PARSE_DOCUMENT parses the file layout and the result omits the token columns.

When schema extraction takes several AI_COMPLETE calls, the extraction procedure adds up the usage reported for that file. The counts are NULL if no usage is reported. Snowflake describes the counts as a cost estimate because internal retries can make billed usage higher.

Snowflake also fixed a schema-based reading bug that caused the reader to reject .jpg, .jpeg, .png, .gif and .webp files as unsupported.

Separately, to_timestamp, to_char (also available as to_varchar), to_binary and try_to_binary accept a Snowpark Column or a Python string as the format argument. The release fixes a TypeError that the two binary functions could raise with a column format. Both functions now pass empty format strings through to Snowflake.

More news