标量函数支持状态

qianmoQqianmoQ· 更新于 2026-10-02· 阅读 27 分钟· 0 次阅读

登录后可跨设备保存划线和私人笔记登录

标量函数支持状态

在 Spark 3.5 的 357 个标量函数中,Gluten 目前完整支持 247 个函数,部分支持 28 个函数。

Gluten 还完整支持 Spark 4.0 中新增的 2 个函数。

数组函数

Spark 函数Spark 表达式状态限制
arrayCreateArrayS
array_appendArrayAppendS
array_compactArrayCompactS
array_containsArrayContainsS
array_distinctArrayDistinctS
array_exceptArrayExceptS
array_insertArrayInsertS
array_intersectArrayIntersectS
array_joinArrayJoinS
array_maxArrayMaxS
array_minArrayMinS
array_positionArrayPositionS
array_prependArrayPrependS
array_removeArrayRemoveS
array_repeatArrayRepeatS
array_unionArrayUnionS
arrays_overlapArraysOverlapS
arrays_zipArraysZipS
flattenFlattenS
getGetS
sequenceSequence
shuffleShuffleS
sliceSliceS
sort_arraySortArrayS

位运算函数

Spark 函数Spark 表达式状态限制
&BitwiseAndS
^BitwiseXorS
bit_countBitwiseCountS
bit_getBitwiseGetS
getbitBitwiseGetS
shiftrightShiftRightS
shiftrightunsignedShiftRightUnsigned
\BitwiseOrS
~BitwiseNotS

集合函数

Spark 函数Spark 表达式状态限制
array_sizeArraySizeS
cardinalitySizeS
concatConcatS
reverseReverseS
sizeSizeS

条件函数

Spark 函数Spark 表达式状态限制
coalesceCoalesceS
ifIfS
ifnullNvlS
nanvlNaNvlS
nullifNullIfS
nvlNvlS
nvl2Nvl2S
whenCaseWhenS

转换函数

Spark 函数Spark 表达式状态限制
bigintS
binaryS
booleanS
castCastS
dateS
decimalS
doubleS
floatS
intS
smallintS
stringS
timestampS
tinyintS

CSV 函数

Spark 函数Spark 表达式状态限制
from_csvCsvToStructs
schema_of_csvSchemaOfCsv
to_csvStructsToCsv

日期与时间戳函数

Spark 函数Spark 表达式状态限制
add_monthsAddMonthsS
convert_timezoneConvertTimezone
curdateCurDateExpressionBuilder
current_dateCurrentDate
current_timestampCurrentTimestamp
current_timezoneCurrentTimeZone
date_addDateAddS
date_diffDateDiffS
date_formatDateFormatClassS
date_from_unix_dateDateFromUnixDateS
date_partDatePartExpressionBuilder
date_subDateSubS
date_truncTruncTimestampS
dateaddDateAddS
datediffDateDiffS
datepartDatePartExpressionBuilder
dayDayOfMonthS
daynameDayNameSSpark 4.0+
dayofmonthDayOfMonthS
dayofweekDayOfWeekS
dayofyearDayOfYearS
extractExtractS
from_unixtimeFromUnixTimeS
from_utc_timestampFromUTCTimestampS
hourHourS
last_dayLastDayS
localtimestampLocalTimestamp
make_dateMakeDateS
make_dt_intervalMakeDTInterval
make_intervalMakeInterval
make_timestampMakeTimestampS
make_timestamp_ltzMakeTimestampLTZExpressionBuilder
make_timestamp_ntzMakeTimestampNTZExpressionBuilder
make_ym_intervalMakeYMIntervalS
minuteMinuteS
monthMonthS
monthnameMonthNameSSpark 4.0+
months_betweenMonthsBetweenS
next_dayNextDayS
nowNow
quarterQuarterS
secondSecondS
session_windowSessionWindow
timestamp_microsMicrosToTimestampS
timestamp_millisMillisToTimestampS
timestamp_secondsSecondsToTimestampPS
to_dateParseToDate
to_timestampParseToTimestamp
to_timestamp_ltzParseToTimestampLTZExpressionBuilder
to_timestamp_ntzParseToTimestampNTZExpressionBuilder
to_unix_timestampToUnixTimestampPS
to_utc_timestampToUTCTimestampS
truncTruncDateS
try_to_timestampTryToTimestampExpressionBuilder
unix_dateUnixDateS
unix_microsUnixMicrosS
unix_millisUnixMillisS
unix_secondsUnixSecondsS
unix_timestampUnixTimestampS
weekdayWeekDayS
weekofyearWeekOfYearS
windowTimeWindow
window_timeWindowTime
yearYearS

Hash Functions

Spark FunctionsSpark ExpressionsStatusRestrictions
crc32Crc32S
hashMurmur3HashS
md5Md5S
shaSha1S
sha1Sha1S
sha2Sha2S
xxhash64XxHash64S

JSON Functions

Spark Functions Spark Expressions Status Restrictions

from_json JsonToStructs PS 在 Velox 中不支持 ‘spark.sql.caseSensitive = true’ 的 from_json
在 Velox 中不支持 ‘spark.sql.json.enablePartialResults = false’ 的 from_json
在 Velox 中不支持带 corrupt record 列的 from_json
在 Velox 中不支持带重复键的 from_json
在 Velox 中不支持带 options 的 from_json

get_json_object GetJsonObject S  

json_array_length LengthOfJsonArray S  

json_object_keys JsonObjectKeys S  

json_tuple JsonTuple S  

schema_of_json SchemaOfJson    

to_json StructsToJson PS 当 ‘spark.sql.caseSensitive = false’ 时,to_json 对字段名为大写的结构体会产生意外结果
在 Velox 中不支持带 options 的 to_json

Lambda Functions

Spark FunctionsSpark ExpressionsStatusRestrictions
aggregateArrayAggregateS
array_sortArraySortS
existsArrayExistsS
filterArrayFilterS
forallArrayForAllS
map_filterMapFilterS
map_zip_withMapZipWithS
reduceArrayAggregateS
transformArrayTransformS
transform_keysTransformKeysS
transform_valuesTransformValuesS
zip_withZipWithS

Map Functions

Spark 函数Spark 表达式状态限制
element_atElementAtS
mapCreateMapPS
map_concatMapConcatPS
map_contains_keyMapContainsKeyS
map_entriesMapEntriesS
map_from_arraysMapFromArraysS
map_from_entriesMapFromEntriesS
map_keysMapKeysS
map_valuesMapValuesS
str_to_mapStringToMapPSVelox 后端仅支持 spark.sql.mapKeyDedupPolicy = EXCEPTION
try_element_atTryElementAt

数学函数

Spark 函数Spark 表达式状态限制
%RemainderS
*MultiplyS
+AddS
-SubtractS
/DivideS
absAbsS
acosAcosS
acoshAcoshS
asinAsinS
asinhAsinhS
atanAtanS
atan2Atan2S
atanhAtanhS
binBinS
broundBRound
cbrtCbrtS
ceilCeilExpressionBuilderPS
ceilingCeilExpressionBuilderPS
convConvS
cosCosS
coshCoshS
cotCotS
cscCscS
degreesToDegreesS
divIntegralDivideS
eEulerNumberS
expExpS
expm1Expm1S
factorialFactorialS
floorFloorExpressionBuilderPS
greatestGreatestS
hexHexS
hypotHypotS
leastLeastS
lnLog
logLogarithmS
log10Log10S
log1pLog1pS
log2Log2S
modRemainderS
negativeUnaryMinusS
piPiS
pmodPmodS
positiveUnaryPositiveS
powPowS
powerPowS
radiansToRadians
randRandS
randnRandnS
randomRandS
rintRintS
roundRoundS
secSecS
shiftleftShiftLeftS
signSignumS
signumSignumS
sinSin
sinhSinhS
sqrtSqrtS
tanTanS
tanhTanhS
try_addTryAddPS
try_divideTryDivide
try_multiplyTryMultiply
try_subtractTrySubtract
unhexUnhexS
width_bucketWidthBucketS

杂项函数

Spark 函数Spark 表达式状态限制
aes_decryptAesDecrypt
aes_encryptAesEncrypt
assert_trueAssertTrueS
bitmap_bit_positionBitmapBitPosition
bitmap_bucket_numberBitmapBucketNumber
bitmap_countBitmapCount
current_catalogCurrentCatalog
current_databaseCurrentDatabase
current_schemaCurrentDatabase
current_userCurrentUser
equal_nullEqualNullS
hll_sketch_estimateHllSketchEstimate
hll_unionHllUnion
input_file_block_lengthInputFileBlockLength
input_file_block_startInputFileBlockStart
input_file_nameInputFileName
java_methodCallMethodViaReflection
monotonically_increasing_idMonotonicallyIncreasingID
reflectCallMethodViaReflection
spark_partition_idSparkPartitionIDS
try_aes_decryptTryAesDecrypt
typeofTypeOf
userCurrentUser
uuidUuidS
versionSparkVersionS
\\S

谓词函数

Spark 函数Spark 表达式状态限制
!NotS
!=S
<LessThanS
<=LessThanOrEqualS
<=>EqualNullSafeS
<>S
=EqualToS
==EqualToS
>GreaterThanS
>=GreaterThanOrEqualS
andAndS
betweenS
caseS
ilikeILikeS
inInPS
isnanIsNaNS
isnotnullIsNotNullS
isnullIsNullS
likeLikeS
notNotS
orOrS
regexpRLikePS不支持前后环视
regexp_likeRLikePS不支持前后环视
rlikeRLikePS不支持前后环视

字符串函数

Spark 函数 Spark 表达式 状态 限制

ascii Ascii S

base64 Base64 PS 不支持禁用 chunkBase64String 的 base64

bit_length BitLength S

btrim StringTrimBoth S

char Chr S

char_length Length S

character_length Length S

chr Chr S

concat_ws ConcatWs S

contains ContainsExpressionBuilder PS 不支持 BinaryType

decode Decode

elt Elt

encode Encode

endswith EndsWithExpressionBuilder PS 不支持 BinaryType

find_in_set FindInSet S

format_number FormatNumber PS format_number 仅支持 tinyint、smallint、integer、bigint、float 和 double 类型输入;Velox 不支持 DecimalType 输入
Velox 不支持使用字符串格式参数(如 ‘#,###.##’)的 format_number;仅支持整数形式的小数位数

format_string FormatString

initcap InitCap S

instr StringInstr S

lcase Lower S

left Left S

len Length S

length Length S

levenshtein Levenshtein S

locate StringLocate S

lower Lower S

lpad LPadExpressionBuilder PS 不支持 BinaryType

ltrim StringTrimLeft S

luhn_check Luhncheck S

mask MaskExpressionBuilder S  

octet_length OctetLength    

overlay Overlay S  

position StringLocate S  

printf FormatString    

regexp_count RegExpCount    

regexp_extract RegExpExtract PS 不支持环视断言

regexp_extract_all RegExpExtractAll PS 不支持环视断言

regexp_instr RegExpInStr PS 不支持环视断言,忽略分组索引

regexp_replace RegExpReplace PS 不支持环视断言

regexp_substr RegExpSubStr    

repeat StringRepeat S  

replace StringReplace S  

right Right S  

rpad RPadExpressionBuilder PS 不支持 BinaryType

rtrim StringTrimRight S  

sentences Sentences    

soundex SoundEx S  

space StringSpace    

split StringSplit S  

split_part SplitPart S  

startswith StartsWithExpressionBuilder PS 不支持 BinaryType

substr Substring PS  

substring Substring PS  

substring_index SubstringIndex S  

to_binary ToBinary    

to_char ToCharacter    

to_number ToNumber    

to_varchar ToCharacter    

translate StringTranslate S  

trim StringTrim S  

try_to_binary TryToBinary    

try_to_number TryToNumber    

ucase Upper S  

unbase64 UnBase64 PS 不支持带 failOnError 的 unbase64

upper Upper S  

结构体函数

Spark 函数Spark 表达式状态限制
named_structCreateNamedStructS
structS

URL 函数

Spark 函数Spark 表达式状态限制
parse_urlParseUrl
url_decodeUrlDecodeS
url_encodeUrlEncodeS

XML 函数

Spark 函数Spark 表达式状态限制
xpathXPathList
xpath_booleanXPathBoolean
xpath_doubleXPathDouble
xpath_floatXPathFloat
xpath_intXPathInt
xpath_longXPathLong
xpath_numberXPathDouble
xpath_shortXPathShort
xpath_stringXPathString

评论

登录后参与评论

正在加载评论…