Skip to content

Commit

Permalink
Change sparkSQL keywords (#2401)
Browse files Browse the repository at this point in the history
* rename method

* Function activation cleanup

* rollback file changes

* Change spark keywords

* Change spark keywords

* Fix test
  • Loading branch information
Yasirmod17 authored Oct 23, 2023
1 parent 3181ab9 commit 7cb53a0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 264 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function <<test.Test>> meta::pure::executionPlan::tests::sparkSQL::testFilterEqu
' (\n'+
' type = TDS[(Time, Integer, INT, "")]\n'+
' resultColumns = [("Time", INT)]\n'+
' sql = select "root"."time" as "Time" from interactionTable as "root" where ((${optionalVarPlaceHolderOperationSelector(optionalID![], \'"root".ID = ${varPlaceHolderToString(optionalID![] "\\\'" "\\\'" {"\\\'" : "\\\'\\\'"} "null")}\', \'"root".ID is null\')}) and (${optionalVarPlaceHolderOperationSelector(optionalActive![], \'case when "root"."active" = \\\'Y\\\' then \\\'true\\\' else \\\'false\\\' end = ${varPlaceHolderToString(optionalActive![] "\\\'" "\\\'" {} "null")}\', \'case when "root"."active" = \\\'Y\\\' then \\\'true\\\' else \\\'false\\\' end is null\')}))\n'+
' sql = select "root"."time" as "Time" from interactionTable as "root" where ((${optionalVarPlaceHolderOperationSelector(optionalID![], \'"root".ID = ${varPlaceHolderToString(optionalID![] "\\\'" "\\\'" {"\\\'" : "\\\'\\\'"} "null")}\', \'"root".ID is null\')}) and (${optionalVarPlaceHolderOperationSelector(optionalActive![], \'case when "root".active = \\\'Y\\\' then \\\'true\\\' else \\\'false\\\' end = ${varPlaceHolderToString(optionalActive![] "\\\'" "\\\'" {} "null")}\', \'case when "root".active = \\\'Y\\\' then \\\'true\\\' else \\\'false\\\' end is null\')}))\n'+
' connection = DatabaseConnection(type = "SparkSQL")\n'+
' )\n'+
' )\n'+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,349 +307,118 @@ function meta::relational::functions::sqlQueryToString::sparkSQL::loadValuesToDb

function <<access.private>> meta::relational::functions::sqlQueryToString::sparkSQL::sparkReservedWords():String[*]
{
//Based on
// http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc38151.1510/html/iqrefbb/Alhakeywords.htm
// and
// http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc38151.1601/doc/html/san1278452828146.html

//Based on ANSI SQL standard
// https://learn.microsoft.com/en-us/azure/databricks/sql/language-manual/sql-ref-reserved-words

[
'active',
'add',
'algorithm',
'all',
'alter',
'and',
'any',
'append',
'array',
'as',
'asc',
'attach',
'auto',
'backup',
'begin',
'at',
'authorization',
'between',
'bigint',
'binary',
'bit',
'bottom',
'break',
'both',
'by',
'calibrate',
'calibration',
'call',
'cancel',
'capability',
'cascade',
'case',
'cast',
'certificate',
'char',
'char_convert',
'character',
'check',
'checkpoint',
'checksum',
'clientport',
'close',
'columns',
'comment',
'collate',
'column',
'commit',
'committed',
'comparisons',
'compressed',
'computes',
'conflict',
'connect',
'constraint',
'contains',
'continue',
'convert',
'create',
'cross',
'cube',
'current',
'current_date',
'current_time',
'current_timestamp',
'current_user',
'cursor',
'date',
'datetimeoffset',
'dbspace',
'dbspacename',
'deallocate',
'debug',
'dec',
'decimal',
'declare',
'decoupled',
'decrypted',
'default',
'delay',
'delete',
'deleting',
'density',
'desc',
'detach',
'deterministic',
'disable',
'distinct',
'do',
'double',
'describe',
'delete',
'drop',
'dynamic',
'elements',
'else',
'elseif',
'enable',
'encapsulated',
'encrypted',
'end',
'endif',
'escape',
'except',
'exception',
'exclude',
'exec',
'execute',
'existing',
'exists',
'explicit',
'express',
'externlogin',
'fastfirstrow',
'exist',
'external',
'extract',
'false',
'fetch',
'first',
'float',
'following',
'filter',
'for',
'force',
'foreign',
'forward',
'from',
'full',
'gb',
'goto',
'function',
'global',
'grant',
'group',
'grouping',
'having',
'hidden',
'history',
'holdlock',
'identified',
'if',
'in',
'inactive',
'index',
'index_lparen',
'inner',
'inout',
'input',
'insensitive',
'insert',
'inserting',
'install',
'instead',
'int',
'integer',
'integrated',
'intersect',
'interval',
'into',
'iq',
'is',
'isolation',
'jdk',
'join',
'json',
'kb',
'kerberos',
'key',
'lateral',
'leading',
'left',
'like',
'limit',
'lock',
'logging',
'login',
'long',
'match',
'mb',
'membership',
'merge',
'message',
'mode',
'modify',
'namespace',
'local',
'natural',
'nchar',
'new',
'no',
'noholdlock',
'nolock',
'not',
'notify',
'null',
'numeric',
'nvarchar',
'of',
'off',
'on',
'open',
'openstring',
'openxml',
'optimization',
'option',
'options',
'only',
'or',
'order',
'others',
'out',
'outer',
'over',
'pages',
'paglock',
'partial',
'overlaps',
'partition',
'passthrough',
'password',
'plan',
'preceding',
'precision',
'prepare',
'position',
'primary',
'print',
'privileges',
'proc',
'procedure',
'proxy',
'publication',
'raiserror',
'range',
'raw',
'readcommitted',
'readonly',
'readpast',
'readtext',
'readuncommitted',
'readwrite',
'real',
'recursive',
'reference',
'references',
'refresh',
'release',
'relocate',
'remote',
'remove',
'rename',
'reorganize',
'repeatable',
'repeatableread',
'reserve',
'resizing',
'resource',
'restore',
'restrict',
'return',
'revoke',
'right',
'rollback',
'rollup',
'root',
'row',
'rowlock',
'rows',
'rowtype',
'save',
'savepoint',
'schedule',
'scroll',
'secure',
'select',
'sensitive',
'serializable',
'service',
'session',
'session_user',
'set',
'setuser',
'share',
'smallint',
'soapaction',
'some',
'space',
'spatial',
'sqlcode',
'sqlstate',
'start',
'stop',
'subtrans',
'subtransaction',
'synchronize',
'syntax_error',
'table',
'tablock',
'tablockx',
'tb',
'temporary',
'tablesample',
'then',
'ties',
'time',
'timestamp',
'tinyint',
'to',
'top',
'tran',
'transaction',
'transactional',
'transfer',
'treat',
'tries',
'trigger',
'trailing',
'true',
'truncate',
'tsequal',
'unbounded',
'uncommitted',
'union',
'unique',
'uniqueidentifier',
'unknown',
'unnest',
'unsigned',
'update',
'updating',
'updlock',
'url',
'user',
'using',
'utc',
'validate',
'values',
'varbinary',
'varbit',
'varchar',
'variable',
'varray',
'varying',
'view',
'virtual',
'wait',
'waitfor',
'web',
'when',
'when',
'where',
'while',
'window',
'with',
'with_cube',
'with_lparen',
'with_rollup',
'withauto',
'within',
'word',
'work',
'writeserver',
'writetext',
'xlock',
'xml'
]
'with'
]
}

0 comments on commit 7cb53a0

Please sign in to comment.