{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/3909","labels_url":"https://api.github.com/repos/apache/spark/issues/3909/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/3909/comments","events_url":"https://api.github.com/repos/apache/spark/issues/3909/events","html_url":"https://github.com/apache/spark/pull/3909","id":53498102,"number":3909,"title":"[SPARK-5009][SQL][Bug FIx] allCaseVersions leads to stackoverflow.","user":{"login":"OopsOutOfMemory","id":6489401,"avatar_url":"https://avatars.githubusercontent.com/u/6489401?v=3","gravatar_id":"","url":"https://api.github.com/users/OopsOutOfMemory","html_url":"https://github.com/OopsOutOfMemory","followers_url":"https://api.github.com/users/OopsOutOfMemory/followers","following_url":"https://api.github.com/users/OopsOutOfMemory/following{/other_user}","gists_url":"https://api.github.com/users/OopsOutOfMemory/gists{/gist_id}","starred_url":"https://api.github.com/users/OopsOutOfMemory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OopsOutOfMemory/subscriptions","organizations_url":"https://api.github.com/users/OopsOutOfMemory/orgs","repos_url":"https://api.github.com/users/OopsOutOfMemory/repos","events_url":"https://api.github.com/users/OopsOutOfMemory/events{/privacy}","received_events_url":"https://api.github.com/users/OopsOutOfMemory/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-01-06T09:49:33Z","updated_at":"2015-01-07T05:14:08Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/3909","html_url":"https://github.com/apache/spark/pull/3909","diff_url":"https://github.com/apache/spark/pull/3909.diff","patch_url":"https://github.com/apache/spark/pull/3909.patch"},"body":"Currently, we use `allCaseVersion` function to match all possible case versions of  `Keyword` that user passing into to sql query, like `SelecT * From SRc ` is also allowed in query syntax.\r\n\r\nA stackoverflow exception  appears when `Keyword` is too long since `allCaseVersion` will generate 2^`Keyword.length` case versions. i.e. `Keyword(\"SERDEPROPERTIES\")`  will generate 2^15 = 32768 possible case version.  This make __implicit function__   `asParser` throws the SO exception.\r\n\r\nI think it is unnecessary to generate all kinds of case versions, this will cause SO when keyword is too long and also do extra computing to generate all case versions of a given keyword.\r\n\r\nSo I'd like to replace the `allCaseVersions` matching `Keyword` with a more simpler way,  and this also can prevent SO exception, speed up parsing. \r\n\r\nissues description is here: https://issues.apache.org/jira/browse/SPARK-5009\r\n"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/68979911","html_url":"https://github.com/apache/spark/pull/3909#issuecomment-68979911","issue_url":"https://api.github.com/repos/apache/spark/issues/3909","id":68979911,"user":{"login":"chenghao-intel","id":2367031,"avatar_url":"https://avatars.githubusercontent.com/u/2367031?v=3","gravatar_id":"","url":"https://api.github.com/users/chenghao-intel","html_url":"https://github.com/chenghao-intel","followers_url":"https://api.github.com/users/chenghao-intel/followers","following_url":"https://api.github.com/users/chenghao-intel/following{/other_user}","gists_url":"https://api.github.com/users/chenghao-intel/gists{/gist_id}","starred_url":"https://api.github.com/users/chenghao-intel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenghao-intel/subscriptions","organizations_url":"https://api.github.com/users/chenghao-intel/orgs","repos_url":"https://api.github.com/users/chenghao-intel/repos","events_url":"https://api.github.com/users/chenghao-intel/events{/privacy}","received_events_url":"https://api.github.com/users/chenghao-intel/received_events","type":"User","site_admin":false},"created_at":"2015-01-07T05:14:08Z","updated_at":"2015-01-07T05:14:08Z","body":"@OopsOutOfMemory seems some other Parsers have the same bug, I've created the #3924 to refactor the code first. And will create another PR for the bug fixing, probably we can discuss the code then."}}