You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/11/03 21:15:13 UTC

[GitHub] [superset] mccushjack commented on a change in pull request #15930: fix: Teradata connection fixes

mccushjack commented on a change in pull request #15930:
URL: https://github.com/apache/superset/pull/15930#discussion_r742341433



##########
File path: superset/db_engine_specs/teradata.py
##########
@@ -14,13 +14,114 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+
+from dataclasses import dataclass  # pylint: disable=wrong-import-order
+from enum import Enum
+from typing import List, Optional, Set
+from urllib import parse
+
 from superset.db_engine_specs.base import BaseEngineSpec, LimitMethod
 
+import sqlparse
+from sqlparse.sql import (
+    Identifier,
+    IdentifierList,
+    Parenthesis,
+    remove_quotes,
+    Token,
+    TokenList,
+)
+from sqlparse.tokens import Keyword, Name, Punctuation, String, Whitespace
+from sqlparse.utils import imt
+
+"""
+from typing import List, Optional, TYPE_CHECKING
+
+if TYPE_CHECKING:
+    # prevent circular imports
+    from superset.models.core import Database
+"""
+
+def _extract_limit_from_query_td(statement: TokenList) -> Optional[int]:
+    td_limit_keywork = set(["TOP", "SAMPLE"])
+    str_statement = str(statement)
+    str_statement = str_statement.replace('\n', ' ').replace('\r', '')
+    token = str(str_statement).rstrip().split(' ')
+    token = list(filter(None, token))
+    limit = None
+
+    for i in range(len(token)):
+        if any(limitword in token[i].upper() for limitword in td_limit_keywork):
+            if len(token) - 1 > i:
+                try:
+                    limit = int(token[i + 1])
+                except ValueError:
+                    limit = None
+                break
+    return limit
+
+
+class ParsedQuery_td:

Review comment:
       Thanks, @betodealmeida should I create test_teradata in superset/tests/unit_tests/db_engine_specs/




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org