databricks-ai-functions

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Databricks AI Functions

Databricks AI Functions

Overview

概述

Databricks AI Functions are built-in SQL and PySpark functions that call Foundation Model APIs directly from your data pipelines — no model endpoint setup, no API keys, no boilerplate. They operate on table columns as naturally as
UPPER()
or
LENGTH()
, and are optimized for batch inference at scale.
Always prefer a task-specific function over
ai_query
.
Reach for
ai_query
only when no task function fits (custom/external endpoints, multimodal, or JSON beyond
ai_extract
's limits). Every function below shares a baseline: DBR 15.1+ (notebooks) / 15.4 ML LTS (batch), not on SQL Warehouse Classic, and region must support AI Functions — the Prereqs column lists only what's additional.
Cost & speed — each call is an LLM inference (slow and billed per token). Run a function once per row and persist the result to a Delta table; never re-invoke it on every downstream query. In demos, avoid generating tables with millions of rows — sample the input when needed so the demo runs quickly. Materialize once, then query the cheap Delta output.
The Function column links to the in-repo deep reference (full options, schemas, examples); Docs links to the official page.
FunctionTaskInputOutputExtra prereqsDocs
ai_analyze_sentiment
Sentiment scoring
content STRING
STRING
positive
/
negative
/
neutral
/
mixed
, or
NULL
ai_classify
Fixed-label routing
content STRING|VARIANT
,
labels
(2–500),
[options MAP]
VARIANT
{response:[label], error_message}
ai_extract
Entity / field extraction
content STRING|VARIANT
,
schema STRING
(JSON),
[options MAP]
VARIANT
{response:{…}, error_message, metadata}
≤256 fields, ≤12 nesting levels
ai_fix_grammar
Grammar correction
content STRING
STRING
(corrected)
ai_gen
Free-form generation
prompt STRING
STRING
ai_mask
PII redaction
content STRING
,
labels ARRAY<STRING>
STRING
(entities →
[MASKED]
)
ai_similarity
Semantic similarity
expr1 STRING
,
expr2 STRING
FLOAT
(0.0–1.0)
ai_summarize
Summarization
content STRING
,
[max_words INT]
(0 = uncapped)
STRING
Public Preview; English-tuned
ai_translate
Translation
content STRING
,
to_lang STRING
STRING
Langs: en, fr, de, hi, it, pt, es, th
ai_parse_document
Parse PDF / Office / images
content BINARY
,
[Map('version','2.0', …)]
VARIANT
— pages, elements, error_status
DBR 17.3+; ≤500 pages / 100 MB
ai_prep_search
RAG chunking from parsed docs
parsed VARIANT
,
[options MAP]
VARIANT
{document:{contents, pages, source_uri}, error_status}
DBR 18.2+ (serverless env v3+)
ai_query
Any serving endpoint (built-in foundation or custom), multimodal, complex JSON (last resort)
endpoint STRING
,
request STRING|STRUCT
,
[returnType]
,
[failOnError BOOL]
,
[modelParameters STRUCT]
,
[responseFormat STRING]
,
[files]
Parsed response; with
failOnError => false
a
STRUCT{response, errorMessage}
Pro/Serverless warehouse;
CAN QUERY
on endpoint
ai_forecast
Time series forecasting (table-valued)
observed TABLE
,
horizon
,
time_col
,
value_col
,
[group_col]
,
[prediction_interval_width]
,
[frequency]
,
[seed]
,
[parameters]
Rows: time/group cols + per value
{v}_forecast
,
{v}_upper
,
{v}_lower
(DOUBLE)
Pro/Serverless warehouse; Public Preview
Models run under Apache 2.0 or LLAMA 3.3 Community License — you are responsible for compliance.
Databricks AI Functions是内置的SQL和PySpark函数,可直接从数据流水线中调用Foundation Model API——无需设置模型端点、无需API密钥、无需冗余代码。它们像
UPPER()
LENGTH()
一样自然地作用于表列,并且针对大规模批量推理进行了优化。
优先使用特定任务函数而非
ai_query
仅当没有合适的任务函数时才使用
ai_query
(自定义/外部端点、多模态或超出
ai_extract
限制的JSON)。以下所有函数都有基线要求:DBR 15.1+(笔记本)/ 15.4 ML LTS(批量),不支持SQL Warehouse Classic,且区域必须支持AI Functions——“额外 prerequisites”列仅列出额外要求。
成本与速度——每次调用都是一次LLM推理(速度慢且按token计费)。 对每行数据仅运行一次函数,并将结果持久化到Delta表中;切勿在每个下游查询中重新调用。在演示中,避免生成包含数百万行的表——必要时对输入进行采样,以便演示快速运行。先物化结果,再查询低成本的Delta输出。
“Function”列链接到仓库内的详细参考(完整选项、模式、示例);“Docs”列链接到官方页面。
函数任务输入输出额外 prerequisites文档
ai_analyze_sentiment
情感评分
content STRING
STRING
positive
/
negative
/
neutral
/
mixed
,或
NULL
ai_classify
固定标签路由
content STRING|VARIANT
,
labels
(2–500),
[options MAP]
VARIANT
{response:[label], error_message}
ai_extract
实体/字段提取
content STRING|VARIANT
,
schema STRING
(JSON),
[options MAP]
VARIANT
{response:{…}, error_message, metadata}
≤256个字段,≤12层嵌套
ai_fix_grammar
语法修正
content STRING
STRING
(修正后内容)
ai_gen
自由格式生成
prompt STRING
STRING
ai_mask
PII脱敏
content STRING
,
labels ARRAY<STRING>
STRING
(实体替换为
[MASKED]
ai_similarity
语义相似度
expr1 STRING
,
expr2 STRING
FLOAT
(0.0–1.0)
ai_summarize
文本摘要
content STRING
,
[max_words INT]
(0表示无上限)
STRING
公开预览版;针对英文优化
ai_translate
文本翻译
content STRING
,
to_lang STRING
STRING
支持语言:en、fr、de、hi、it、pt、es、th
ai_parse_document
PDF/Office/图片解析
content BINARY
,
[Map('version','2.0', …)]
VARIANT
— pages、elements、error_status
DBR 17.3+;≤500页/100 MB
ai_prep_search
解析文档的RAG分块
parsed VARIANT
,
[options MAP]
VARIANT
{document:{contents, pages, source_uri}, error_status}
DBR 18.2+(serverless环境v3+)
ai_query
任意服务端点(内置基础模型或自定义模型)、多模态、复杂JSON(最后选择
endpoint STRING
,
request STRING|STRUCT
,
[returnType]
,
[failOnError BOOL]
,
[modelParameters STRUCT]
,
[responseFormat STRING]
,
[files]
解析后的响应;当
failOnError => false
时返回
STRUCT{response, errorMessage}
Pro/Serverless仓库;对端点拥有
CAN QUERY
权限
ai_forecast
时间序列预测(表值函数)
observed TABLE
,
horizon
,
time_col
,
value_col
,
[group_col]
,
[prediction_interval_width]
,
[frequency]
,
[seed]
,
[parameters]
行数据:时间/分组列 + 每个值对应的
{v}_forecast
{v}_upper
{v}_lower
(DOUBLE类型)
Pro/Serverless仓库;公开预览版
模型基于Apache 2.0或LLAMA 3.3社区许可证运行——您需负责合规性。

Patterns

使用模式

Chain task functions to enrich a column in one pass.
ai_classify
/
ai_extract
return a VARIANT — read it with the colon operator (
:response
):
sql
SELECT id,
  ai_analyze_sentiment(content)                                                   AS sentiment,
  ai_summarize(content, 30)                                                       AS summary,
  ai_classify(content, '["technical","billing","other"]', map('version','2.0')):response[0]::STRING AS category,
  ai_extract(content, '["product","error_code","date"]', map('version','2.0')):response:product::STRING AS product,
  ai_fix_grammar(content)                                                         AS content_clean
FROM raw_feedback;
In PySpark, call any of these inside
expr(...)
:
df.withColumn("category", expr("ai_classify(content, '[\"a\",\"b\"]', map('version','2.0')):response[0]::STRING"))
— and read VARIANT fields via
selectExpr("col:response:field::STRING AS field")
.
PII redaction before storage
ai_mask(content, ARRAY(entity_types))
returns text with entities →
[MASKED]
.
sql
SELECT ai_mask(message, array('person','email','phone','address')) AS message_safe FROM raw_messages;
Semantic matching / dedup
ai_similarity
returns 0–1; self-join and threshold:
sql
SELECT a.id, b.id, ai_similarity(a.name, b.name) AS score
FROM companies a JOIN companies b ON a.id < b.id
WHERE ai_similarity(a.name, b.name) > 0.85;
Forecasting — table-valued; one row per future period (+ per group). Full param/group/interval forms → 3-ai-forecast.md:
sql
SELECT * FROM ai_forecast(
    observed => TABLE(SELECT date, sales FROM daily_sales),
    horizon => '2026-12-31', time_col => 'date', value_col => 'sales');
-- Returns: date, sales_forecast, sales_upper, sales_lower
Nested JSON via
ai_query
(last resort — only past
ai_extract
's limits) — parse the response with
from_json
. Model names, multimodal
files =>
,
modelParameters
, SQL UDF → 2-ai-query.md:
sql
SELECT from_json(
    ai_query('databricks-claude-sonnet-4',
        concat('Extract invoice as JSON with nested line_items array: ', text_blocks),
        responseFormat => '{"type":"json_object"}', failOnError => false).response,
    'STRUCT<numero:STRING, total:DOUBLE, line_items:ARRAY<STRUCT<code:STRING, qty:DOUBLE>>>'
) AS invoice
FROM parsed_documents;
Document parsing (
ai_parse_document
) and RAG chunking (
ai_prep_search
) get their own staged pipeline below.
链式调用任务函数,一次性丰富列数据。
ai_classify
/
ai_extract
返回VARIANT类型——使用冒号运算符(
:response
)读取:
sql
SELECT id,
  ai_analyze_sentiment(content)                                                   AS sentiment,
  ai_summarize(content, 30)                                                       AS summary,
  ai_classify(content, '["technical","billing","other"]', map('version','2.0')):response[0]::STRING AS category,
  ai_extract(content, '["product","error_code","date"]', map('version','2.0')):response:product::STRING AS product,
  ai_fix_grammar(content)                                                         AS content_clean
FROM raw_feedback;
PySpark中,可在
expr(...)
内调用任意上述函数:
df.withColumn("category", expr("ai_classify(content, '[\"a\",\"b\"]', map('version','2.0')):response[0]::STRING"))
——并通过
selectExpr("col:response:field::STRING AS field")
读取VARIANT字段。
存储前进行PII脱敏——
ai_mask(content, ARRAY(entity_types))
返回实体替换为
[MASKED]
的文本。
sql
SELECT ai_mask(message, array('person','email','phone','address')) AS message_safe FROM raw_messages;
语义匹配/去重——
ai_similarity
返回0–1之间的值;自连接并设置阈值:
sql
SELECT a.id, b.id, ai_similarity(a.name, b.name) AS score
FROM companies a JOIN companies b ON a.id < b.id
WHERE ai_similarity(a.name, b.name) > 0.85;
预测——表值函数;每个未来周期(+每个分组)对应一行数据。完整参数/分组/区间形式请查看→ 3-ai-forecast.md
sql
SELECT * FROM ai_forecast(
    observed => TABLE(SELECT date, sales FROM daily_sales),
    horizon => '2026-12-31', time_col => 'date', value_col => 'sales');
-- 返回:date, sales_forecast, sales_upper, sales_lower
通过
ai_query
处理嵌套JSON
(最后选择——仅当超出
ai_extract
限制时使用)——使用
from_json
解析响应。模型名称、多模态
files =>
modelParameters
、SQL UDF请查看→ 2-ai-query.md
sql
SELECT from_json(
    ai_query('databricks-claude-sonnet-4',
        concat('Extract invoice as JSON with nested line_items array: ', text_blocks),
        responseFormat => '{"type":"json_object"}', failOnError => false).response,
    'STRUCT<numero:STRING, total:DOUBLE, line_items:ARRAY<STRUCT<code:STRING, qty:DOUBLE>>>'
) AS invoice
FROM parsed_documents;
文档解析(
ai_parse_document
)和RAG分块(
ai_prep_search
)的流水线将在下方单独介绍。

Document Processing Pipeline

文档处理流水线

Chain AI Functions stage-by-stage into Delta tables for batch document processing. The example is written as a Spark Declarative Pipeline (SDP / Lakeflow / DLT)
CREATE OR REFRESH STREAMING TABLE
with
STREAM(...)
sources. To run the same logic standalone in a notebook / SQL warehouse, swap each
CREATE OR REFRESH STREAMING TABLE x AS
for
CREATE OR REPLACE TABLE x AS
and drop the
STREAM(...)
wrappers. In SDP Python it's
@dp.table
with
from pyspark import pipelines as dp
.
sql
-- Stage 1 — parse binary docs (any type), filter parse errors
CREATE OR REFRESH STREAMING TABLE raw_parsed AS
SELECT path,
  concat_ws('\n', transform(parsed:document:elements, e -> e:content::STRING)) AS text_blocks,
  parsed:error_status AS parse_error
FROM (
  SELECT path, ai_parse_document(content, map('version','2.0')) AS parsed
  FROM STREAM read_files('/Volumes/my_catalog/doc_processing/landing/', format => 'binaryFile')
)
WHERE parsed:error_status IS NULL;

-- Stage 2 — classify document type (cheap, no endpoint selection)
CREATE OR REFRESH STREAMING TABLE classified_docs AS
SELECT *,
  ai_classify(text_blocks, '["invoice","purchase_order","receipt","contract","other"]', map('version','2.0')):response[0]::STRING AS doc_type
FROM STREAM raw_parsed;

-- Stage 3 — extract fields; ai_extract returns a VARIANT, read fields with `:`
CREATE OR REFRESH STREAMING TABLE extracted AS
SELECT path, doc_type,
  result:response:invoice_number::STRING AS invoice_number,
  result:response:vendor_name::STRING    AS vendor_name,
  result:response:total_amount::DOUBLE   AS total_amount,
  result:error_message::STRING           AS extract_error
FROM (
  SELECT *, ai_extract(text_blocks,
    '{"invoice_number":{"type":"string"},"vendor_name":{"type":"string"},"total_amount":{"type":"number"}}',
    map('version','2.0')) AS result
  FROM STREAM classified_docs WHERE doc_type = 'invoice' AND text_blocks IS NOT NULL
);
In a batch job, route the per-row error to a sidecar table instead of letting it crash the run: keep
ai_extract
's
result:error_message
(VARIANT, colon-accessed, as above), and for
ai_query
pass
failOnError => false
and check
ai_response.errorMessage
(a STRUCT field, dot-accessed). See 2-ai-query.md.
将AI Functions按阶段链式调用,构建Delta表以进行批量文档处理。示例以Spark声明式流水线(SDP / Lakeflow / DLT)编写——使用
CREATE OR REFRESH STREAMING TABLE
STREAM(...)
源。要在
笔记本/SQL仓库
中单独运行相同逻辑,请将每个
CREATE OR REFRESH STREAMING TABLE x AS
替换为
CREATE OR REPLACE TABLE x AS
并移除
STREAM(...)
包装器。在SDP Python中则使用
@dp.table
搭配
from pyspark import pipelines as dp
sql
-- 阶段1 — 解析二进制文档(任意类型),过滤解析错误
CREATE OR REFRESH STREAMING TABLE raw_parsed AS
SELECT path,
  concat_ws('\n', transform(parsed:document:elements, e -> e:content::STRING)) AS text_blocks,
  parsed:error_status AS parse_error
FROM (
  SELECT path, ai_parse_document(content, map('version','2.0')) AS parsed
  FROM STREAM read_files('/Volumes/my_catalog/doc_processing/landing/', format => 'binaryFile')
)
WHERE parsed:error_status IS NULL;

-- 阶段2 — 对文档类型进行分类(低成本,无需选择端点)
CREATE OR REFRESH STREAMING TABLE classified_docs AS
SELECT *,
  ai_classify(text_blocks, '["invoice","purchase_order","receipt","contract","other"]', map('version','2.0')):response[0]::STRING AS doc_type
FROM STREAM raw_parsed;

-- 阶段3 — 提取字段;ai_extract返回VARIANT类型,使用`:`读取字段
CREATE OR REFRESH STREAMING TABLE extracted AS
SELECT path, doc_type,
  result:response:invoice_number::STRING AS invoice_number,
  result:response:vendor_name::STRING    AS vendor_name,
  result:response:total_amount::DOUBLE   AS total_amount,
  result:error_message::STRING           AS extract_error
FROM (
  SELECT *, ai_extract(text_blocks,
    '{"invoice_number":{"type":"string"},"vendor_name":{"type":"string"},"total_amount":{"type":"number"}}',
    map('version','2.0')) AS result
  FROM STREAM classified_docs WHERE doc_type = 'invoice' AND text_blocks IS NOT NULL
);
在批量作业中,将每行的错误路由到副表,而非让作业崩溃:保留
ai_extract
result:error_message
(VARIANT类型,通过冒号访问,如上所示),对于
ai_query
则传入
failOnError => false
并检查
ai_response.errorMessage
(STRUCT字段,通过点访问)。请查看2-ai-query.md

Custom RAG Pipeline — Parse → Prep → Index

自定义RAG流水线 — 解析→预处理→索引

For retrieval rather than field extraction:
ai_parse_document
ai_prep_search
(semantic chunking + context enrichment, DBR 18.2+) → Vector Search Delta Sync index.
ai_prep_search
returns
chunk_id
,
chunk_to_retrieve
, and
chunk_to_embed
(enriched with title/headers/page) — embed
chunk_to_embed
, return
chunk_to_retrieve
to the LLM.
Shown standalone; in an SDP swap
CREATE OR REPLACE TABLE
for
CREATE OR REFRESH STREAMING TABLE
+
STREAM read_files(...)
.
sql
CREATE OR REPLACE TABLE parsed_chunks AS
WITH prepped AS (
  SELECT path AS source_path, ai_prep_search(ai_parse_document(content)) AS prep
  FROM read_files('/Volumes/my_catalog/doc_processing/docs/', format => 'binaryFile')
)
SELECT
  variant_get(chunk, '$.chunk_id',          'STRING') AS chunk_id,
  variant_get(chunk, '$.chunk_to_retrieve', 'STRING') AS chunk_to_retrieve,
  variant_get(chunk, '$.chunk_to_embed',    'STRING') AS chunk_to_embed,
  source_path
FROM prepped LATERAL VIEW explode(variant_get(prep, '$.document.contents', 'ARRAY<VARIANT>')) c AS chunk;
Then enable CDF (
ALTER TABLE parsed_chunks SET TBLPROPERTIES (delta.enableChangeDataFeed = true)
) and use the databricks-vector-search skill to build a Delta Sync index: PK
chunk_id
, embedding source
chunk_to_embed
, return
chunk_to_retrieve
.
Beyond batch:
  • Ask questions over the output — point a Genie Agent at the resulting Delta table for natural-language querying instead of hand-written SQL; see the databricks-genie-agents skill.
  • Low-latency / serving — to expose this as a real-time, governed endpoint (e.g. register a model to Unity Catalog and serve it), use the databricks-model-serving skill.
  • Production incremental ingestion — for a runnable end-to-end streaming
    ai_parse_document
    job (checkpoints,
    trigger(availableNow=True)
    ), see databricks/bundle-examples · job_with_ai_parse_document.
如果是用于检索而非字段提取:
ai_parse_document
ai_prep_search
(语义分块+上下文增强,DBR 18.2+)→ Vector Search Delta Sync索引。
ai_prep_search
返回
chunk_id
chunk_to_retrieve
chunk_to_embed
(包含标题/页眉/页码的增强内容)——
chunk_to_embed
进行嵌入,将
chunk_to_retrieve
返回给LLM
。以下为独立运行示例;在SDP中请将
CREATE OR REPLACE TABLE
替换为
CREATE OR REFRESH STREAMING TABLE
+
STREAM read_files(...)
sql
CREATE OR REPLACE TABLE parsed_chunks AS
WITH prepped AS (
  SELECT path AS source_path, ai_prep_search(ai_parse_document(content)) AS prep
  FROM read_files('/Volumes/my_catalog/doc_processing/docs/', format => 'binaryFile')
)
SELECT
  variant_get(chunk, '$.chunk_id',          'STRING') AS chunk_id,
  variant_get(chunk, '$.chunk_to_retrieve', 'STRING') AS chunk_to_retrieve,
  variant_get(chunk, '$.chunk_to_embed',    'STRING') AS chunk_to_embed,
  source_path
FROM prepped LATERAL VIEW explode(variant_get(prep, '$.document.contents', 'ARRAY<VARIANT>')) c AS chunk;
然后启用CDF(
ALTER TABLE parsed_chunks SET TBLPROPERTIES (delta.enableChangeDataFeed = true)
),并使用**databricks-vector-search**技能构建Delta Sync索引:主键
chunk_id
,嵌入源
chunk_to_embed
,返回
chunk_to_retrieve
超越批量处理:
  • 对输出进行提问——将Genie Agent指向生成的Delta表,通过自然语言查询而非手写SQL;请查看**databricks-genie-agents**技能。
  • 低延迟/服务化——要将其作为实时、受管控的端点暴露(例如将模型注册到Unity Catalog并提供服务),请使用**databricks-model-serving**技能。
  • 生产级增量 ingestion——如需可运行的端到端流式
    ai_parse_document
    作业(包含检查点、
    trigger(availableNow=True)
    ),请查看databricks/bundle-examples · job_with_ai_parse_document

Reference Files

参考文件

  • 1-task-functions.md — Deep reference for every task-specific function: full options/schemas (e.g.
    ai_extract
    v2.1 citations + confidence scores,
    ai_classify
    multilabel,
    ai_parse_document
    options + output schema,
    ai_prep_search
    chunk schema) and non-trivial examples. The Overview table above links to each function's section directly.
  • 2-ai-query.md
    ai_query
    complete reference: all parameters, structured output with
    responseFormat
    , multimodal
    files =>
    , UDF patterns, and error handling
  • 3-ai-forecast.md
    ai_forecast
    parameters, single-metric, multi-group, multi-metric, and confidence interval patterns
  • 1-task-functions.md — 所有特定任务函数的详细参考:完整选项/模式(例如
    ai_extract
    v2.1引用+置信度分数、
    ai_classify
    多标签、
    ai_parse_document
    选项+输出模式、
    ai_prep_search
    分块模式)和非 trivial 示例。上方的概述表格直接链接到每个函数的章节。
  • 2-ai-query.md
    ai_query
    完整参考:所有参数、使用
    responseFormat
    的结构化输出、多模态
    files =>
    、UDF模式和错误处理
  • 3-ai-forecast.md
    ai_forecast
    参数、单指标、多分组、多指标和置信区间模式

Common Issues

常见问题

IssueSolution
ai_parse_document
not found
Requires DBR 17.3+. Check cluster runtime.
ai_prep_search
not found
Requires DBR 18.2+ (serverless env v3+).
explode()
fails on a VARIANT
explode
needs ARRAY — cast first:
explode(variant_get(prep, '$.document.contents', 'ARRAY<VARIANT>'))
.
Embedding the wrong RAG columnEmbed
chunk_to_embed
(context-enriched); return
chunk_to_retrieve
to the LLM.
ai_forecast
fails
Requires Pro or Serverless SQL warehouse — not available on Classic or Starter.
All functions return NULLInput column is NULL. Filter with
WHERE col IS NOT NULL
before calling.
ai_translate
fails for a language
Supported (8): English (
en
), French (
fr
), German (
de
), Hindi (
hi
), Italian (
it
), Portuguese (
pt
), Spanish (
es
), Thai (
th
) —
to_lang
takes the code or the full name (see references/1-task-functions.md). Use
ai_query
with a multilingual model for others.
ai_classify
returns unexpected labels
Use clear, mutually exclusive label names. Fewer labels (2–5) produces more reliable results.
ai_query
raises on some rows in a batch job
Add
failOnError => false
— returns a STRUCT with
.response
and
.errorMessage
(dot-accessed) instead of raising.
Batch job runs slowlyUse DBR 15.4 ML LTS cluster (not serverless or interactive) for optimized batch inference throughput.
问题解决方案
ai_parse_document
未找到
需要DBR 17.3+。检查集群运行时版本。
ai_prep_search
未找到
需要DBR 18.2+(serverless环境v3+)。
explode()
在VARIANT类型上执行失败
explode
需要ARRAY类型——先转换:
explode(variant_get(prep, '$.document.contents', 'ARRAY<VARIANT>'))
嵌入了错误的RAG列
chunk_to_embed
(上下文增强内容)进行嵌入;将
chunk_to_retrieve
返回给LLM。
ai_forecast
执行失败
需要Pro或Serverless SQL仓库——不支持Classic或Starter版本。
所有函数返回NULL输入列为NULL。调用前使用
WHERE col IS NOT NULL
过滤。
ai_translate
对某语言执行失败
支持8种语言:英语(
en
)、法语(
fr
)、德语(
de
)、印地语(
hi
)、意大利语(
it
)、葡萄牙语(
pt
)、西班牙语(
es
)、泰语(
th
)——
to_lang
接受代码或完整名称(请查看references/1-task-functions.md)。如需其他语言,请使用
ai_query
搭配多语言模型。
ai_classify
返回意外标签
使用清晰、互斥的标签名称。标签数量越少(2–5个),结果越可靠。
ai_query
在批量作业中对某些行报错
添加
failOnError => false
——返回包含
.response
.errorMessage
(通过点访问)的STRUCT,而非抛出错误。
批量作业运行缓慢使用DBR 15.4 ML LTS集群(而非serverless或交互式集群)以优化批量推理吞吐量。