Skip to content

Commit

Permalink
SNOW-1045676: Narrow list of Snowflake keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dprzybysz committed Apr 29, 2024
1 parent 3e1516d commit f55d1d6
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,27 +94,51 @@ public class SnowflakeDatabaseMetaData implements DatabaseMetaData {

// These are keywords not in SQL2003 standard
private static final String notSQL2003Keywords =
"ACCOUNT,ASOF,DATABASE,SCHEMA,VIEW,ISSUE,DATE_PART,EXTRACT,"
+ "POSITION,TRY_CAST,BIT,DATETIME,NUMBERC,OBJECT,BYTEINT,STRING,TEXT,"
+ "TIMESTAMPLTZ,TIMESTAMPNTZ,TIMESTAMPTZ,TIMESTAMP_LTZ,TIMESTAMP_NTZ,TIMESTAMP_TZ,TINYINT,"
+ "VARBINARY,VARIANT,ACCOUNTS,ACTION,ACTIVATE,ASC,AUTOINCREMENT,BEFORE,"
+ "BUILTIN,BYTE,CACHE,CHANGE,CLEAREPCACHE,CLONE,CLUSTER,CLUSTERS,COLUMNS,COMMENT,"
+ "COMPRESSION,CONNECTION,CONSTRAINTS,COPY,CP,CREDENTIALS,D,DATA,DATABASES,DEFERRABLE,"
+ "DEFERRED,DELIMITED,DESC,DIRECTORY,DISABLE,DUAL,ENABLE,ENFORCED,"
+ "EXCLUSIVE,EXPLAIN,EXPORTED,FAIL,FIELDS,FILE,FILES,FIXED,FIRST,FN,FOLLOWING,FORCE,FORMAT,"
+ "FORMATS,FUNCTIONS,GRANTS,GSCLUSTER,GSINSTANCE,GSINSTANCES,GSPACKAGE,HELP,HIBERNATE,HINTS,"
+ "HISTORY,IDENTIFIED,IDENTIFIER,ILIKE,IMMUTABLE,IMPORTED,INCIDENT,INCIDENTS,INFO,INITIALLY,"
+ "ISSUES,KEEP,KEY,KEYS,LAST,LIMIT,LIST,LOAD,LOCATION,LOCK,LOCKS,LONG,LS,MANAGE,MAP,MATCHED,MATCH_CONDITION,"
+ "MATERIALIZED,MODIFY,MONITOR,MONITORS,NAME,NETWORK,NEXT,NORELY,NOTIFY,NOVALIDATE,NULLS,NUMBER,OBJECTS,"
+ "OFFSET,OJ,OPERATE,OPERATION,OPTION,ORGANIZATION,OWNERSHIP,PARAMETERS,PARTIAL,"
+ "PERCENT,PLAN,PLUS,POLICIES,POLICY,POOL,PRESERVE,PRIVILEGES,PUBLIC,PURGE,PUT,QUALIFY,QUIESCE,"
+ "READ,RECLUSTER,REFERENCE,RELY,REMOVE,RENAME,REPLACE,REPLACE_FAIL,RESOURCE,"
+ "RESTART,RESTORE,RESTRICT,RESUME,REWRITE,RM,ROLE,ROLES,RULE,SAMPLE,SCHEMAS,SEMI,"
+ "SEQUENCE,SEQUENCES,SERVER,SERVERS,SESSION,SETLOGLEVEL,SETS,SFC,SHARE,SHARED,SHARES,SHOW,SHUTDOWN,SIMPLE,SORT,"
+ "STAGE,STAGES,STATEMENT,STATISTICS,STOP,STORED,STRICT,STRUCT,SUSPEND,SUSPEND_IMMEDIATE,SWAP,SWITCH,T,"
+ "TABLES,TEMP,TEMPORARY,TRANSACTION,TRANSACTIONS,TRANSIENT,TRANSIT,TRIGGERS,TRUNCATE,TS,TYPE,UNDROP,UNLOCK,"
+ "UNSET,UPGRADE,USAGE,USE,USERS,UTC,UTCTIMESTAMP,VALIDATE,VARIABLES,VECTOR,VERSION,VIEWS,VOLATILE,VOLUME,"
+ "VOLUMES,WAREHOUSE,WAREHOUSES,WARN,WORK,WRITE,ZONE,INCREMENT,MINUS,REGEXP,RLIKE";
String.join(
",",
"ACCOUNT",
"ASOF",
"BIT",
"BYTEINT",
"CONNECTION",
"DATABASE",
"DATETIME",
"DATE_PART",
"FIXED",
"FOLLOWING",
"GSCLUSTER",
"GSPACKAGE",
"IDENTIFIER",
"ILIKE",
"INCREMENT",
"ISSUE",
"LONG",
"MAP",
"MATCH_CONDITION",
"MINUS",
"NUMBER",
"OBJECT",
"ORGANIZATION",
"QUALIFY",
"REFERENCE",
"REGEXP",
"RLIKE",
"SAMPLE",
"SCHEMA",
"STRING",
"TEXT",
"TIMESTAMPLTZ",
"TIMESTAMPNTZ",
"TIMESTAMPTZ",
"TIMESTAMP_LTZ",
"TIMESTAMP_NTZ",
"TIMESTAMP_TZ",
"TINYINT",
"TRANSIT",
"TRY_CAST",
"VARIANT",
"VECTOR",
"VIEW");

private final Connection connection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2333,4 +2333,13 @@ public void testGetJDBCVersion() throws SQLException {
assertEquals(2, metaData.getJDBCMinorVersion());
}
}

/** Added in > 3.15.1 */
@Test
public void testKeywordsCount() throws SQLException {
try (Connection connection = getConnection()) {
DatabaseMetaData metaData = connection.getMetaData();
assertEquals(43, metaData.getSQLKeywords().split(",").length);
}
}
}

0 comments on commit f55d1d6

Please sign in to comment.