ANSI 合规性ANSI compliance

Spark SQL 提供两个试验性选项以支持符合 ANSI SQL 标准:spark.sql.ansi.enabledspark.sql.storeAssignmentPolicySpark SQL has two experimental options to support compliance with the ANSI SQL standard: spark.sql.ansi.enabled and spark.sql.storeAssignmentPolicy.

如果 spark.sql.ansi.enabled 设置为 true,Spark SQL 将遵循基本行为中的标准(例如,算术运算、类型转换、SQL 函数和 SQL 分析)。When spark.sql.ansi.enabled is set to true, Spark SQL follows the standard in basic behaviors (for example, arithmetic operations, type conversion, SQL functions and SQL parsing). 此外,在表中插入行时,Spark SQL 提供独立的选项来控制隐式强制转换行为。Moreover, Spark SQL has an independent option to control implicit casting behaviors when inserting rows in a table. 强制转换行为在标准为定义为存储分配规则。The casting behaviors are defined as store assignment rules in the standard.

spark.sql.storeAssignmentPolicy 设置为 ANSI 时,Spark SQL 将遵循 ANSI 存储分配规则。When spark.sql.storeAssignmentPolicy is set to ANSI, Spark SQL complies with the ANSI store assignment rules. 这是一个单独的配置,因为其默认值为 ANSI,而配置 spark.sql.ansi.enabled 默认处于禁用状态。This is a separate configuration because its default value is ANSI, while the configuration spark.sql.ansi.enabled is disabled by default.

下表对此行为进行了汇总:The following table summarizes the behavior:

属性名称Property Name 默认Default 含义Meaning
spark.sql.ansi.enabled falsefalse (试验)为 true 时,Spark 会尝试遵循 ANSI SQL 规范:(Experimental) When true, Spark attempts to conform to the ANSI SQL specification:

* 如果在对整数或十进制数字段进行任何操作时发生溢出,则会引发运行时异常。* Throws a runtime exception if an overflow occurs in any operation on an integer or decimal field.
* 禁止在 SQL 分析器中使用 ANSI SQL 的保留关键字作为标识符。* Forbids using the reserved keywords of ANSI SQL as identifiers in the SQL parser.
spark.sql.storeAssignmentPolicy ANSIANSI (试验)向具有不同数据类型的列中插入值时,Spark 会执行类型强制转换。(Experimental) When inserting a value into a column with a different data type, Spark performs type coercion. 类型强制转换规则有三种策略:ANSIlegacystrictThere are three policies for the type coercion rules: ANSI, legacy, and strict.

* ANSI:Spark 根据 ANSI SQL 执行类型强制转换。* ANSI: Spark performs the type coercion as per ANSI SQL. 实际上,此行为与 PostgreSQL 基本相同。In practice, the behavior is mostly the same as PostgreSQL. 它不允许某些不合理的类型转换,例如将字符串转换为 int 或将 double 转换为布尔。It disallows certain unreasonable type conversions such as converting string to int or double to boolean.
* legacy:Spark 允许类型强制转换,前提是它是有效的强制转换,这非常宽松。* legacy: Spark allows the type coercion as long as it is a valid Cast, which is very loose. 例如,允许将字符串转换为 int 或将 double 转换为布尔。For example, converting string to int or double to boolean is allowed. 它也是 Spark 2.x 中的唯一行为,并与 Hive 兼容。It is also the only behavior in Spark 2.x and it is compatible with Hive.
* strict:Spark 不允许类型强制转换过程出现任何可能的精度受损或数据截断,例如,不允许将 double 转换为 int 或将 decimal 转换为 double。* strict: Spark doesn’t allow any possible precision loss or data truncation in type coercion, for example, converting double to int or decimal to double is not allowed.

以下各子部分显示了启用 ANSI 模式时算术运算、类型转换和 SQL 分析的行为变更。The following subsections present behavior changes in arithmetic operations, type conversions, and SQL parsing when ANSI mode is enabled.

算术运算Arithmetic operations

在 Spark SQL 中,默认情况下,不会检查对数值类型(十进制数除外)执行的算术运算是否溢出。In Spark SQL, arithmetic operations performed on numeric types (with the exception of decimal) are not checked for overflows by default. 这意味着,如果某个操作导致溢出,则结果与 Java 或 Scala 程序中相应的操作结果相同(例如,如果 2 个整数的和大于可表示的最大值,则结果为负数)。This means that in case an operation causes overflows, the result is the same with the corresponding operation in a Java or Scala program (For example, if the sum of 2 integers is higher than the maximum value representable, the result is a negative number). 另一方面,对于十进制数溢出,Spark SQL 会返回 NULL。On the other hand, Spark SQL returns null for decimal overflows. spark.sql.ansi.enabled 设置为 true,并且数值和间隔算术运算中发生溢出时,它会在运行时引发算术异常。When spark.sql.ansi.enabled is set to true and an overflow occurs in numeric and interval arithmetic operations, it throws an arithmetic exception at runtime.

-- `spark.sql.ansi.enabled=true`
SELECT 2147483647 + 1;
java.lang.ArithmeticException: integer overflow

-- `spark.sql.ansi.enabled=false`
SELECT 2147483647 + 1;
+----------------+
|(2147483647 + 1)|
+----------------+
|     -2147483648|
+----------------+

类型转换Type conversion

Spark SQL 具有三种类型的转换:显式强制转换、类型强制转换和存储分配转换。Spark SQL has three kinds of type conversions: explicit casting, type coercion, and store assignment casting. spark.sql.ansi.enabled 设置为 true 时,通过 CAST 语法进行显式强制转换会在标准中定义的非法强制转换模式下引发运行时异常,例如将字符串转换为整数。When spark.sql.ansi.enabled is set to true, explicit casting by CAST syntax throws a runtime exception for illegal cast patterns defined in the standard, e.g. casts from a string to an integer. 另一方面,通过 spark.sql.storeAssignmentPolicy=ANSI 启用 ANSI 模式时,INSERT INTO 语法会引发分析异常。On the other hand, INSERT INTO syntax throws an analysis exception when the ANSI mode enabled via spark.sql.storeAssignmentPolicy=ANSI.

目前,ANSI 模式仅影响显式强制转换和分配强制转换。Currently, the ANSI mode affects explicit casting and assignment casting only. 在将来的版本中,类型强制转换的行为可能会随其他两种类型转换规则一起更改。In future releases, the behavior of type coercion might change along with the other two type conversion rules.

-- Examples of explicit casting

-- `spark.sql.ansi.enabled=true`
SELECT CAST('a' AS INT);
java.lang.NumberFormatException: invalid input syntax for type numeric: a

SELECT CAST(2147483648L AS INT);
java.lang.ArithmeticException: Casting 2147483648 to int causes overflow

-- `spark.sql.ansi.enabled=false` (This is a default behavior)
SELECT CAST('a' AS INT);
+--------------+
|CAST(a AS INT)|
+--------------+
|          null|
+--------------+

SELECT CAST(2147483648L AS INT);
+-----------------------+
|CAST(2147483648 AS INT)|
+-----------------------+
|            -2147483648|
+-----------------------+

-- Examples of store assignment rules
CREATE TABLE t (v INT);

-- `spark.sql.storeAssignmentPolicy=ANSI`
INSERT INTO t VALUES ('1');
org.apache.spark.sql.AnalysisException: Cannot write incompatible data to table '`default`.`t`':
- Cannot safely cast 'v': string to int;

-- `spark.sql.storeAssignmentPolicy=LEGACY` (This is a legacy behavior until Spark 2.x)
INSERT INTO t VALUES ('1');
SELECT * FROM t;
+---+
|  v|
+---+
|  1|
+---+

SQL 函数SQL functions

在 ANSI 模式 (spark.sql.ansi.enabled=true) 下,某些 SQL 函数的行为可能会有所不同。The behavior of some SQL functions can be different under ANSI mode (spark.sql.ansi.enabled=true).

  • size:在 ANSI 模式下,对于 NULL 输入,此函数将返回 NULL。size: This function returns null for null input under ANSI mode.

SQL 关键字SQL keywords

如果 spark.sql.ansi.enabled 为 true,Spark SQL 将使用 ANSI 模式分析器。When spark.sql.ansi.enabled is true, Spark SQL will use the ANSI mode parser. 在此模式下,Spark SQL 有两种关键字:In this mode, Spark SQL has two kinds of keywords:

  • 保留关键字:保留的关键字,不能用作表、视图、列、函数、别名等的标识符。Reserved keywords: Keywords that are reserved and can’t be used as identifiers for table, view, column, function, alias, etc.
  • 非保留关键字:仅在特定上下文中具有特殊含义的关键字,在其他上下文中可用作标识符。Non-reserved keywords: Keywords that have a special meaning only in particular contexts and can be used as identifiers in other contexts. 例如,EXPLAIN SELECT ... 是一个命令,但 EXPLAIN 在其他位置可用作标识符。For example, EXPLAIN SELECT ... is a command, but EXPLAIN can be used as identifiers in other places.

禁用 ANSI 模式时,Spark SQL 有两种关键字:When the ANSI mode is disabled, Spark SQL has two kinds of keywords:

  • 非保留关键字:与 ANSI 模式处于启用状态下的定义相同。Non-reserved keywords: Same definition as the one when the ANSI mode enabled.
  • 严格非保留关键字:非保留关键字的 strict 版本,无法用作表别名。Strict-non-reserved keywords: A strict version of non-reserved keywords, which cannot be used as table alias.

默认情况下,spark.sql.ansi.enabled 为 false。By default spark.sql.ansi.enabled is false.

下面是 Spark SQL 中所有关键字的列表。Below is a list of all the keywords in Spark SQL.

关键字Keyword Spark SQL ANSI 模式Spark SQL ANSI Mode Spark SQL 默认模式Spark SQL Default Mode SQL-2016SQL-2016
ADDADD non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
AFTERAFTER non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
ALLALL reservedreserved non-reservednon-reserved reservedreserved
ALTERALTER non-reservednon-reserved non-reservednon-reserved reservedreserved
分析ANALYZE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
ANDAND reservedreserved non-reservednon-reserved reservedreserved
ANTIANTI non-reservednon-reserved strict-non-reservedstrict-non-reserved non-reservednon-reserved
ANYANY reservedreserved non-reservednon-reserved reservedreserved
存档ARCHIVE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
ARRAYARRAY non-reservednon-reserved non-reservednon-reserved reservedreserved
ASAS reservedreserved non-reservednon-reserved reservedreserved
ASCASC non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
ATAT non-reservednon-reserved non-reservednon-reserved reservedreserved
AUTHORIZATIONAUTHORIZATION reservedreserved non-reservednon-reserved reservedreserved
BETWEENBETWEEN non-reservednon-reserved non-reservednon-reserved reservedreserved
BOTHBOTH reservedreserved non-reservednon-reserved reservedreserved
BUCKETBUCKET non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
BUCKETSBUCKETS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
BYBY non-reservednon-reserved non-reservednon-reserved reservedreserved
CACHECACHE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
CASCADECASCADE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
CASECASE reservedreserved non-reservednon-reserved reservedreserved
CASTCAST reservedreserved non-reservednon-reserved reservedreserved
更改CHANGE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
CHECKCHECK reservedreserved non-reservednon-reserved reservedreserved
CLEARCLEAR non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
CLUSTERCLUSTER non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
CLUSTEREDCLUSTERED non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
CODEGENCODEGEN non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
COLLATECOLLATE reservedreserved non-reservednon-reserved reservedreserved
COLLECTIONCOLLECTION non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
COLUMNCOLUMN reservedreserved non-reservednon-reserved reservedreserved
COLUMNSCOLUMNS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
COMMENTCOMMENT non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
COMMITCOMMIT non-reservednon-reserved non-reservednon-reserved reservedreserved
COMPACTCOMPACT non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
COMPACTIONSCOMPACTIONS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
COMPUTECOMPUTE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
CONCATENATECONCATENATE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
CONSTRAINTCONSTRAINT reservedreserved non-reservednon-reserved reservedreserved
COSTCOST non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
CREATECREATE reservedreserved non-reservednon-reserved reservedreserved
CROSSCROSS reservedreserved strict-non-reservedstrict-non-reserved reservedreserved
CUBECUBE non-reservednon-reserved non-reservednon-reserved reservedreserved
CURRENTCURRENT non-reservednon-reserved non-reservednon-reserved reservedreserved
CURRENT_DATECURRENT_DATE reservedreserved non-reservednon-reserved reservedreserved
CURRENT_TIMECURRENT_TIME reservedreserved non-reservednon-reserved reservedreserved
CURRENT_TIMESTAMPCURRENT_TIMESTAMP reservedreserved non-reservednon-reserved reservedreserved
CURRENT_USERCURRENT_USER reservedreserved non-reservednon-reserved reservedreserved
DATADATA non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
DATABASEDATABASE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
数据库DATABASES non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
DAYDAY reservedreserved non-reservednon-reserved reservedreserved
DBPROPERTIESDBPROPERTIES non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
DEFINEDDEFINED non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
删除DELETE non-reservednon-reserved non-reservednon-reserved reservedreserved
DELIMITEDDELIMITED non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
DESCDESC non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
DESCRIBEDESCRIBE non-reservednon-reserved non-reservednon-reserved reservedreserved
DFSDFS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
DIRECTORIESDIRECTORIES non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
目录DIRECTORY non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
DISTINCTDISTINCT reservedreserved non-reservednon-reserved reservedreserved
DISTRIBUTEDISTRIBUTE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
DIVDIV non-reservednon-reserved non-reservednon-reserved 非关键字not a keyword
DROPDROP non-reservednon-reserved non-reservednon-reserved reservedreserved
ELSEELSE reservedreserved non-reservednon-reserved reservedreserved
EndEND reservedreserved non-reservednon-reserved reservedreserved
ESCAPEESCAPE reservedreserved non-reservednon-reserved reservedreserved
ESCAPEDESCAPED non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
EXCEPTEXCEPT reservedreserved strict-non-reservedstrict-non-reserved reservedreserved
EXCHANGEEXCHANGE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
EXISTSEXISTS non-reservednon-reserved non-reservednon-reserved reservedreserved
EXPLAINEXPLAIN non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
EXPORTEXPORT non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
EXTENDEDEXTENDED non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
EXTERNALEXTERNAL non-reservednon-reserved non-reservednon-reserved reservedreserved
EXTRACTEXTRACT non-reservednon-reserved non-reservednon-reserved reservedreserved
FALSEFALSE reservedreserved non-reservednon-reserved reservedreserved
FETCHFETCH reservedreserved non-reservednon-reserved reservedreserved
字段FIELDS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
FILTERFILTER reservedreserved non-reservednon-reserved reservedreserved
FILEFORMATFILEFORMAT non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
FIRSTFIRST non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
FOLLOWINGFOLLOWING non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
FORFOR reservedreserved non-reservednon-reserved reservedreserved
FOREIGNFOREIGN reservedreserved non-reservednon-reserved reservedreserved
FORMATFORMAT non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
FORMATTEDFORMATTED non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
FROMFROM reservedreserved non-reservednon-reserved reservedreserved
FULLFULL reservedreserved strict-non-reservedstrict-non-reserved reservedreserved
FUNCTIONFUNCTION non-reservednon-reserved non-reservednon-reserved reservedreserved
FUNCTIONSFUNCTIONS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
GLOBALGLOBAL non-reservednon-reserved non-reservednon-reserved reservedreserved
GRANTGRANT reservedreserved non-reservednon-reserved reservedreserved
GROUPGROUP reservedreserved non-reservednon-reserved reservedreserved
GROUPINGGROUPING non-reservednon-reserved non-reservednon-reserved reservedreserved
HAVINGHAVING reservedreserved non-reservednon-reserved reservedreserved
HOURHOUR reservedreserved non-reservednon-reserved reservedreserved
IFIF non-reservednon-reserved non-reservednon-reserved 非关键字not a keyword
IGNOREIGNORE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
IMPORTIMPORT non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
ININ reservedreserved non-reservednon-reserved reservedreserved
INDEXINDEX non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
索引INDEXES non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
INNERINNER reservedreserved strict-non-reservedstrict-non-reserved reservedreserved
INPATHINPATH non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
INPUTFORMATINPUTFORMAT non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
INSERTINSERT non-reservednon-reserved non-reservednon-reserved reservedreserved
INTERSECTINTERSECT reservedreserved strict-non-reservedstrict-non-reserved reservedreserved
INTERVALINTERVAL non-reservednon-reserved non-reservednon-reserved reservedreserved
INTOINTO reservedreserved non-reservednon-reserved reservedreserved
ISIS reservedreserved non-reservednon-reserved reservedreserved
ITEMS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
JOINJOIN reservedreserved strict-non-reservedstrict-non-reserved reservedreserved
密钥KEYS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
LASTLAST non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
LATERALLATERAL non-reservednon-reserved non-reservednon-reserved reservedreserved
LAZYLAZY non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
LEADINGLEADING reservedreserved non-reservednon-reserved reservedreserved
LEFTLEFT reservedreserved strict-non-reservedstrict-non-reserved reservedreserved
LIKELIKE non-reservednon-reserved non-reservednon-reserved reservedreserved
LIMITLIMIT non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
LINESLINES non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
列表LIST non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
LOADLOAD non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
LOCALLOCAL non-reservednon-reserved non-reservednon-reserved reservedreserved
LOCATIONLOCATION non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
LOCKLOCK non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
LOCKSLOCKS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
LOGICALLOGICAL non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
MACROMACRO non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
MAPMAP non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
MATCHEDMATCHED non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
MERGEMERGE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
MINUSMINUS non-reservednon-reserved strict-non-reservedstrict-non-reserved non-reservednon-reserved
MINUTEMINUTE reservedreserved non-reservednon-reserved reservedreserved
MONTHMONTH reservedreserved non-reservednon-reserved reservedreserved
MSCKMSCK non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
命名空间NAMESPACE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
命名空间NAMESPACES non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
NATURALNATURAL reservedreserved strict-non-reservedstrict-non-reserved reservedreserved
NO non-reservednon-reserved non-reservednon-reserved reservedreserved
NOTNOT reservedreserved non-reservednon-reserved reservedreserved
NullNULL reservedreserved non-reservednon-reserved reservedreserved
NULLSNULLS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
OFOF non-reservednon-reserved non-reservednon-reserved reservedreserved
ONON reservedreserved strict-non-reservedstrict-non-reserved reservedreserved
ONLYONLY reservedreserved non-reservednon-reserved reservedreserved
OPTIONOPTION non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
OPTIONSOPTIONS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
OR reservedreserved non-reservednon-reserved reservedreserved
ORDERORDER reservedreserved non-reservednon-reserved reservedreserved
OUTOUT non-reservednon-reserved non-reservednon-reserved reservedreserved
OUTEROUTER reservedreserved non-reservednon-reserved reservedreserved
OUTPUTFORMATOUTPUTFORMAT non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
OVEROVER non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
OVERLAPSOVERLAPS reservedreserved non-reservednon-reserved reservedreserved
OVERLAYOVERLAY non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
OVERWRITEOVERWRITE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
PARTITIONPARTITION non-reservednon-reserved non-reservednon-reserved reservedreserved
PARTITIONEDPARTITIONED non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
分区PARTITIONS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
PERCENTPERCENT non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
PIVOTPIVOT non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
PLACINGPLACING non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
POSITIONPOSITION non-reservednon-reserved non-reservednon-reserved reservedreserved
PRECEDINGPRECEDING non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
PRIMARYPRIMARY reservedreserved non-reservednon-reserved reservedreserved
PRINCIPALSPRINCIPALS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
PROPERTIESPROPERTIES non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
PURGEPURGE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
QUERYQUERY non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
RANGERANGE non-reservednon-reserved non-reservednon-reserved reservedreserved
RECORDREADERRECORDREADER non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
RECORDWRITERRECORDWRITER non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
RECOVERRECOVER non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
REDUCEREDUCE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
REFERENCESREFERENCES reservedreserved non-reservednon-reserved reservedreserved
REFRESHREFRESH non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
REGEXPREGEXP non-reservednon-reserved non-reservednon-reserved 非关键字not a keyword
RENAMERENAME non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
REPAIRREPAIR non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
REPLACEREPLACE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
RESETRESET non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
RESTRICTRESTRICT non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
REVOKEREVOKE non-reservednon-reserved non-reservednon-reserved reservedreserved
RIGHTRIGHT reservedreserved strict-non-reservedstrict-non-reserved reservedreserved
RLIKERLIKE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
ROLEROLE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
ROLESROLES non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
ROLLBACKROLLBACK non-reservednon-reserved non-reservednon-reserved reservedreserved
ROLLUPROLLUP non-reservednon-reserved non-reservednon-reserved reservedreserved
ROWROW non-reservednon-reserved non-reservednon-reserved reservedreserved
ROWSROWS non-reservednon-reserved non-reservednon-reserved reservedreserved
SCHEMASCHEMA non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
SCHEMASSCHEMAS non-reservednon-reserved non-reservednon-reserved 非关键字not a keyword
SECONDSECOND reservedreserved non-reservednon-reserved reservedreserved
SELECTSELECT reservedreserved non-reservednon-reserved reservedreserved
SEMISEMI non-reservednon-reserved strict-non-reservedstrict-non-reserved non-reservednon-reserved
SEPARATEDSEPARATED non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
SERDESERDE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
SERDEPROPERTIESSERDEPROPERTIES non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
SESSION_USERSESSION_USER reservedreserved non-reservednon-reserved reservedreserved
SETSET non-reservednon-reserved non-reservednon-reserved reservedreserved
SETSSETS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
SHOWSHOW non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
SKEWEDSKEWED non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
SOMESOME reservedreserved non-reservednon-reserved reservedreserved
SORTSORT non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
SORTEDSORTED non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
STARTSTART non-reservednon-reserved non-reservednon-reserved reservedreserved
STATISTICSSTATISTICS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
STOREDSTORED non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
STRATIFYSTRATIFY non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
STRUCTSTRUCT non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
SUBSTRSUBSTR non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
SUBSTRINGSUBSTRING non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
TABLETABLE reservedreserved non-reservednon-reserved reservedreserved
TABLESTABLES non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
TABLESAMPLETABLESAMPLE non-reservednon-reserved non-reservednon-reserved reservedreserved
TBLPROPERTIESTBLPROPERTIES non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
TEMPTEMP non-reservednon-reserved non-reservednon-reserved 非关键字not a keyword
TEMPORARYTEMPORARY non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
已终止TERMINATED non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
THENTHEN reservedreserved non-reservednon-reserved reservedreserved
TIMETIME reservedreserved non-reservednon-reserved reservedreserved
TOTO reservedreserved non-reservednon-reserved reservedreserved
TOUCHTOUCH non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
TRAILINGTRAILING reservedreserved non-reservednon-reserved reservedreserved
TRANSACTIONTRANSACTION non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
TRANSACTIONSTRANSACTIONS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
TRANSFORMTRANSFORM non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
TRIMTRIM non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
TRUETRUE non-reservednon-reserved non-reservednon-reserved reservedreserved
TRUNCATETRUNCATE non-reservednon-reserved non-reservednon-reserved reservedreserved
TYPETYPE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
UNARCHIVEUNARCHIVE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
UNBOUNDEDUNBOUNDED non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
UNCACHEUNCACHE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
UNIONUNION reservedreserved strict-non-reservedstrict-non-reserved reservedreserved
UNIQUEUNIQUE reservedreserved non-reservednon-reserved reservedreserved
未知UNKNOWN reservedreserved non-reservednon-reserved reservedreserved
UNLOCKUNLOCK non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
UNSETUNSET non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
UPDATEUPDATE non-reservednon-reserved non-reservednon-reserved reservedreserved
USEUSE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
USERUSER reservedreserved non-reservednon-reserved reservedreserved
USINGUSING reservedreserved strict-non-reservedstrict-non-reserved reservedreserved
VALUESVALUES non-reservednon-reserved non-reservednon-reserved reservedreserved
VIEWVIEW non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
VIEWSVIEWS non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved
WHENWHEN reservedreserved non-reservednon-reserved reservedreserved
WHEREWHERE reservedreserved non-reservednon-reserved reservedreserved
WINDOWWINDOW non-reservednon-reserved non-reservednon-reserved reservedreserved
WITHWITH reservedreserved non-reservednon-reserved reservedreserved
YEARYEAR reservedreserved non-reservednon-reserved reservedreserved
ZONEZONE non-reservednon-reserved non-reservednon-reserved non-reservednon-reserved