From b938d418d0edec0d2b477750858d2463428c3ec8 Mon Sep 17 00:00:00 2001 From: Dominik Przybysz Date: Fri, 15 Mar 2024 09:43:34 +0100 Subject: [PATCH 1/3] SNOW-1045676: Add missing reserved keywords --- .../client/jdbc/SnowflakeDatabaseMetaData.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java b/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java index 34df34067..9d8f8b83f 100644 --- a/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java +++ b/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java @@ -99,19 +99,19 @@ public class SnowflakeDatabaseMetaData implements DatabaseMetaData { + "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,CONSTRAINTS,COPY,CP,CREDENTIALS,D,DATA,DATABASES,DEFERRABLE," + + "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,FIRST,FN,FORCE,FORMAT," - + "FORMATS,FUNCTIONS,GRANTS,GSINSTANCE,GSINSTANCES,HELP,HIBERNATE,HINTS," - + "HISTORY,IDENTIFIED,IMMUTABLE,IMPORTED,INCIDENT,INCIDENTS,INFO,INITIALLY," + + "FORMATS,FUNCTIONS,GRANTS,GSCLUSTER,GSINSTANCE,GSINSTANCES,HELP,HIBERNATE,HINTS," + + "HISTORY,IDENTIFIED,ILIKE,IMMUTABLE,IMPORTED,INCIDENT,INCIDENTS,INFO,INITIALLY," + "ISSUES,KEEP,KEY,KEYS,LAST,LIMIT,LIST,LOAD,LOCATION,LOCK,LOCKS,LS,MANAGE,MAP,MATCHED," + "MATERIALIZED,MODIFY,MONITOR,MONITORS,NAME,NETWORK,NEXT,NORELY,NOTIFY,NOVALIDATE,NULLS,OBJECTS," - + "OFFSET,OJ,OPERATE,OPERATION,OPTION,OWNERSHIP,PARAMETERS,PARTIAL," - + "PERCENT,PLAN,PLUS,POLICIES,POLICY,POOL,PRESERVE,PRIVILEGES,PUBLIC,PURGE,PUT,QUIESCE," + + "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," + + "SOME,STAGE,STAGES,STATEMENT,STATISTICS,STOP,STORED,STRICT,STRUCT,SUSPEND,SUSPEND_IMMEDIATE,SWAP,SWITCH,T," + "TABLES,TEMP,TEMPORARY,TRANSACTION,TRANSACTIONS,TRANSIENT,TRIGGERS,TRUNCATE,TS,TYPE,UNDROP,UNLOCK,UNSET," + "UPGRADE,USAGE,USE,USERS,UTC,UTCTIMESTAMP,VALIDATE,VARIABLES,VERSION,VIEWS,VOLATILE,VOLUME," + "VOLUMES,WAREHOUSE,WAREHOUSES,WARN,WORK,WRITE,ZONE,INCREMENT,MINUS,REGEXP,RLIKE"; From 3e1516dd1b11f5769e49591a161267c1a4434e50 Mon Sep 17 00:00:00 2001 From: Dominik Przybysz Date: Wed, 24 Apr 2024 13:28:11 +0200 Subject: [PATCH 2/3] SNOW-1045676: Add more missing keywords --- .../client/jdbc/SnowflakeDatabaseMetaData.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java b/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java index 9d8f8b83f..da7da23d2 100644 --- a/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java +++ b/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java @@ -94,26 +94,26 @@ public class SnowflakeDatabaseMetaData implements DatabaseMetaData { // These are keywords not in SQL2003 standard private static final String notSQL2003Keywords = - "ACCOUNT,DATABASE,SCHEMA,VIEW,ISSUE,DATE_PART,EXTRACT," + "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,FIRST,FN,FORCE,FORMAT," - + "FORMATS,FUNCTIONS,GRANTS,GSCLUSTER,GSINSTANCE,GSINSTANCES,HELP,HIBERNATE,HINTS," - + "HISTORY,IDENTIFIED,ILIKE,IMMUTABLE,IMPORTED,INCIDENT,INCIDENTS,INFO,INITIALLY," - + "ISSUES,KEEP,KEY,KEYS,LAST,LIMIT,LIST,LOAD,LOCATION,LOCK,LOCKS,LS,MANAGE,MAP,MATCHED," - + "MATERIALIZED,MODIFY,MONITOR,MONITORS,NAME,NETWORK,NEXT,NORELY,NOTIFY,NOVALIDATE,NULLS,OBJECTS," + + "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," - + "SOME,STAGE,STAGES,STATEMENT,STATISTICS,STOP,STORED,STRICT,STRUCT,SUSPEND,SUSPEND_IMMEDIATE,SWAP,SWITCH,T," - + "TABLES,TEMP,TEMPORARY,TRANSACTION,TRANSACTIONS,TRANSIENT,TRIGGERS,TRUNCATE,TS,TYPE,UNDROP,UNLOCK,UNSET," - + "UPGRADE,USAGE,USE,USERS,UTC,UTCTIMESTAMP,VALIDATE,VARIABLES,VERSION,VIEWS,VOLATILE,VOLUME," + + "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"; private final Connection connection; From f55d1d6cc2de17d65a1862c53d84100621f4162e Mon Sep 17 00:00:00 2001 From: Dominik Przybysz Date: Fri, 26 Apr 2024 11:47:43 +0200 Subject: [PATCH 3/3] SNOW-1045676: Narrow list of Snowflake keywords --- .../jdbc/SnowflakeDatabaseMetaData.java | 66 +++++++++++++------ .../client/jdbc/DatabaseMetaDataLatestIT.java | 9 +++ 2 files changed, 54 insertions(+), 21 deletions(-) diff --git a/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java b/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java index da7da23d2..d79fd1b7c 100644 --- a/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java +++ b/src/main/java/net/snowflake/client/jdbc/SnowflakeDatabaseMetaData.java @@ -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; diff --git a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataLatestIT.java b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataLatestIT.java index e3659df39..d3176f8b2 100644 --- a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataLatestIT.java +++ b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataLatestIT.java @@ -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); + } + } }