全部產品
Search
文件中心

MaxCompute:與Hive、MySQL、Oracle內建函數對照表

更新時間:Jun 19, 2024

本文為您提供MaxCompute、Hive、MySQL以及Oracle的內建函數對照表,方便您根據Hive、MySQL、Oracle內建函數尋找對應的MaxCompute內建函數。

日期函數

MaxComputeHiveMySQLOracle
DATEADD
DATE_ADDDATE_ADDDATE_ADD
DATE_SUBDATE_SUBDATE_SUB
DATEDIFFDATEDIFFDATEDIFFMONTHS_BETWEEN
DATEPARTDATE_FORMATEXTRACT (DATETIME)
DATETRUNCTRUNCDATE_FORMATEXTRACT (DATETIME)
FROM_UNIXTIMEFROM_UNIXTIMEFROM_UNIXTIME
GETDATECURRENT_DATENOWCURRENT_DATE
ISDATESTR_TO_DATE(返回FALSE則說明不能轉換為DATE)
LASTDAYLAST_DAYLAST_DAYLAST_DAY
TO_DATETO_DATESTR_TO_DATEDATE
TO_CHARDATE_FORMATTO_CHAR (DATETIME)
UNIX_TIMESTAMPUNIX_TIMESTAMPUNIX_TIMESTAMP
WEEKDAYWEEKDAY
WEEKOFYEARWEEKOFYEARWEEKOFYEAR
ADD_MONTHSADD_MONTHSADDDATEADD_MONTHS
CURRENT_TIMESTAMPCURRENT_TIMESTAMPCURRENT_TIMESTAMPCURRENT_TIMESTAMP
DAYDAYDAYDAY
DAYOFMONTHDAYOFMONTHDAYOFMONTH
EXTRACTEXTRACTEXTRACTEXTRACT
FROM_UTC_TIMESTAMPFROM_UTC_TIMESTAMP
HOURHOURHOURHOUR
LAST_DAYLAST_DAYLAST_DAY
MINUTEMINUTEMINUTEMINUTE
MONTHMONTHMONTHMONTH
MONTHS_BETWEENMONTHS_BETWEENTIMESTAMPDIFFMONTHS_BETWEEN
NEXT_DAYNEXT_DAYNEXT_DAY
QUARTERQUARTERQUARTERQUARTER
SECONDSECONDSECOND
TO_MILLIS
YEARYEARYEAR
說明 預設模式為MaxCompute模式,如果要切換至Hive模式,執行如下命令切換。
--Project層級切換為Hive模式。
setproject odps.sql.hive.compatible=True;
--Session層級切換為Hive模式。
set odps.sql.hive.compatible=True;

數學函數

MaxComputeHiveMySQLOracle
ABSABSABSABS
ACOSACOSACOSACOS
ASINASINASINASIN
ATANATANATANATAN
CEILCEILCEILCEIL
CONVCONVCONV
COSCOSCOSCOS
COSHCOSHCOSH
COTCOTCOTCOT
EXPEXPEXPEXP
FLOORFLOORFLOORFLOOR
LNLNLNLN
LOGLOGLOGLOG
數學函數POWPOWPOWER
RANDRANDRAND
ROUNDROUNDROUNDROUND
SINSINSINSIN
SINHSINHSINH
SQRTSQRTSQRTSQRT
TANTANTANTAN
TANHTANHTANH
TRUNCTRUNCTRUNCATETRUNC
BINBINBINBITAND
CBRTCBRT
CORRCORRCORRCORR
DEGREESDEGREESDEGREESDEGREES
EE
FACTORIALFACTORIAL
FORMAT_NUMBERFORMAT_NUMBERFORMAT
HEXHEXHEXRAWTOHEX
LOG2LOG2LOG2LOG
LOG10LOG10LOG10LOG
PIPIPIPI
RADIANSRADIANSRADIANSRADIANS
SIGNSIGNSIGNSIGN
SHIFTLEFTSHIFTLEFT<<
SHIFTRIGHTSHIFTRIGHT>>
SHIFTRIGHTUNSIGNEDSHIFTRIGHTUNSIGNED>>>
UNHEXUNHEXUNHEXHEXTORAW
WIDTH_BUCKETWIDTH_BUCKETWIDTH_BUCKET
說明 預設模式為MaxCompute模式,如果要切換至Hive模式,執行如下命令切換。
--Project層級切換為Hive模式。
setproject odps.sql.hive.compatible=True;
--Session層級切換為Hive模式。
set odps.sql.hive.compatible=True;

視窗函數

MaxComputeHiveMySQLOracle
COUNTCOUNTCOUNTCOUNT
AVGAVGAVGAVG
MAXMAXMAXMAX
MINMINMINMIN
MEDIANMEDIAN
STDDEVSTDDEVSTDDEV
STDDEV_SAMPSTDDEV_SAMPSTDDEV_SAMP
SUMSUMSUMSUM
DENSE_RANKDENSE_RANKDENSE_RANKDENSE_RANK
RANKRANKRANKRANK
LAGLAGLAGLAG
LEADLEADLEADLEAD
PERCENT_RANKPERCENT_RANKPERCENT_RANKPERCENT_RANK
ROW_NUMBERROW_NUMBERROW_NUMBERROW_NUMBER
CLUSTER_SAMPLE
CUME_DISTCUME_DISTCUME_DISTCUME_DIST
NTILENTILENTILENTILE

彙總函式

MaxComputeHiveMySQLOracle
AVGAVGAVGAVG
COUNTCOUNTCOUNTCOUNT
COUNT_IF
MAXMAXMAXMAX
MINMINMINMIN
MEDIANMEDIAN
STDDEVSTDDEVSTDDEVSTDDEV
STDDEV_SAMPSTDDEV_SAMPSTDDEV_SAMPSTDDEV_SAMP
SUMSUMSUMSUM
WM_CONCATGROUP_CONCATWM_CONCAT
ANY_VALUE
APPROX_DISTINCT
ARG_MAX
ARG_MIN
COLLECT_LISTCOLLECT LISTCOLLECT
COLLECT_SETCOLLECT SETCOLLECT
COVAR_POPCOVAR_POPCOVAR_POP
COVAR_SAMPCOVAR_SAMPCOVAR_SAMP
NUMERIC_HISTOGRAMNUMERIC_HISTOGRAM
PERCENTILEPERCENTILE
PERCENTILE_APPROXPERCENTILE_APPROX
VARIANCE/VAR_POPVARIANCE/VAR_POPVAR_POPVARIANCE/VAR_POP
VAR_SAMPVAR_SAMPVAR_SAMPVAR_SAMP
說明 預設模式為MaxCompute模式,如果要切換至Hive模式,執行如下命令切換。
--Project層級切換為Hive模式。
setproject odps.sql.hive.compatible=True;
--Session層級切換為Hive模式。
set odps.sql.hive.compatible=True;

字串函數

MaxComputeHiveMySQLOracle
ASCIIASCIIASCIIASCII
CHAR_MATCHCOUNT
CHRCHRCHARCHR
CONCATCONCATCONCATCONCAT
ENCODEENCODE
FIND_IN_SETFIND_IN_SETFIND_IN_SET
FORMAT_NUMBERFORMAT_NUMBERFORMAT
FROM_JSON
GET_JSON_OBJECTGET_JSON_OBJECTJSON_EXTRACT
INSTRINSTRINSTRINSTR
IS_ENCODING
KEYVALUE
LENGTHLENGTHLENGTHLENGTH
LENGTHBLENGTHBLENGTHBLENGTHB
LOCATELOCATELOCATE
LTRIMLTRIMLTRIMLTRIM
MD5MD5MD5
PARSE_URLPARSE_URL
PARSE_URL_TUPLEPARSE_URL_TUPLE
REGEXP_COUNTREGEXP_COUNT
REGEXP_EXTRACTREGEXP_EXTRACT
REGEXP_INSTRREGEXP_INSTRREGEXP_INSTR
REGEXP_REPLACEREGEXP_REPLACEREGEXP_REPLACEREGEXP_REPLACE
REGEXP_SUBSTRREGEXP_SUBSTRREGEXP_SUBSTR
REPEATREPEATREPEATREPEAT
REVERSEREVERSEREVERSEREVERSE
RTRIMRTRIMRTRIMRTRIM
SPACESPACESPACESPACE
SPLIT_PART
SUBSTRSUBSTRSUBSTRSUBSTR
SUBSTRINGSUBSTRINGSUBSTRINGSUBSTR
TO_CHAR
TO_JSON
TOLOWERLOWERLOWERLOWER
TOUPPERUPPERUPPERUPPER
TRIMTRIMTRIMTRIM
URL_DECODE
URL_ENCODEPERCENTILE_CONT
CONCAT_WSCONCAT_WSCONCAT_WS
JSON_TUPLEJSON_TUPLE
LPADLPADLPADLPAD
RPADRPADRPADRPAD
REPLACEREPLACEREPLACEREPLACE
SOUNDEXSOUNDEXSOUNDEXSOUNDEX
SUBSTRING_INDEXSUBSTRING_INDEXSUBSTRING_INDEX
TRANSLATETRANSLATETRANSLATE
說明 預設模式為MaxCompute模式,如果要切換至Hive模式,執行如下命令切換。
--Project層級切換為Hive模式。
setproject odps.sql.hive.compatible=True;
--Session層級切換為Hive模式。
set odps.sql.hive.compatible=True;

其他函數

MaxComputeHiveMySQLOracle
BASE64BASE64TO_BASE64UTL_ENCODE.BASE64_ENCODE
BETWEEN AND運算式BETWEEN ANDBETWEEN ANDBETWEEN AND
CASE WHEN運算式CASE WHENCASE WHENCASE WHEN
CASTCASTCASTCAST
COALESCECOALESCECOALESCECOALESCE
COMPRESSCOMPRESSUTL_COMPRESS.LZ_COMPRESS
CRC32CRC32CRC32
DECODEDECODEDECODE
DECOMPRESSUNCOMPRESSUTL_COMPRESS.LZ_UNCOMPRESS
GET_IDCARD_AGE
GET_IDCARD_BIRTHDAY
GET_IDCARD_SEX
GET_USER_IDCURRENT_USERCURRENT_USERUID
GREATESTGREATESTGREATEST
HASHHASHORA_HASH
IFIFIFIF
LEASTLEASTLEASTLEAST
MAX_PT
NULLIFNULLIFNULLIFNULLIF
NVLNVLIFNULL
ORDINAL
PARTITION_EXISTS
SAMPLE
SHASHASHA
SHA1SHA1SHA1
SHA2SHA2SHA2
其他函數SIGNSIGNSIGN
其他函數SPLITSPLIT
STACKSTACK
STR_TO_MAPSTR_TO_MAP
TABLE_EXISTS
TRANS_ARRAY
TRANS_COLS
UNBASE64UNBASE64FROM_BASE64UTL_ENCODE.BASE64_DECODE
UNIQUE_ID
UUIDUUIDUID
說明 預設模式為MaxCompute模式,如果要切換至Hive模式,執行如下命令切換。
--Project層級切換為Hive模式。
setproject odps.sql.hive.compatible=True;
--Session層級切換為Hive模式。
set odps.sql.hive.compatible=True;

複雜類型函數

函數類別MaxComputeHiveMySQLOracle
ARRAYALL_MATCH
ANY_MATCH
ARRAYARRAY
ARRAY_CONTAINSARRAY_CONTAINS
ARRAY_DISTINCT
ARRAY_EXCEPT
ARRAY_INTERSECT
ARRAY_JOIN
ARRAY_MAX
ARRAY_MIN
ARRAY_POSITION
ARRAY_REMOVE
ARRAY_REDUCE
ARRAY_REPEAT
ARRAY_SORT
ARRAY_UNION
ARRAYS_OVERLAP
ARRAYS_ZIP
CONCATCONCAT
EXPLODEEXPLODE
FILTER
INDEX[]運算子
POSEXPLODEPOSEXPLODE
SIZESIZE
SLICE
SORT_ARRAYSORT_ARRAY
TRANSFORM
ZIP_WITH
MAPEXPLODEEXPLODE
INDEX[]運算子
MAPMAP
MAP_CONCAT
MAP_ENTRIES
MAP_FILTER
MAP_FROM_ARRAYS
MAP_FROM_ENTRIES
MAP_KEYSMAP_KEYS
MAP_VALUESMAP_VALUES
MAP_ZIP_WITH
SIZESIZE
TRANSFORM_KEYS
TRANSFORM_VALUES
STRUCTFIELD.運算子
INLINEINLINE
STRUCTSTRUCT
NAMED_STRUCT
JSONFROM_JSON
GET_JSON_OBJECTGET_JSON_OBJECTJSON_EXTRACT
JSON_TUPLEJSON_TUPLE
TO_JSON
說明 預設模式為MaxCompute模式,如果要切換至Hive模式,執行如下命令切換。
--Project層級切換為Hive模式。
setproject odps.sql.hive.compatible=True;
--Session層級切換為Hive模式。
set odps.sql.hive.compatible=True;